summaryrefslogtreecommitdiff
path: root/chromium/components/spellcheck/renderer/spellcheck_panel.h
blob: 18c9c4e2f15d3f0beb4c9021c916a8a8c0e176a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PANEL_H
#define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PANEL_H

#include "base/macros.h"
#include "components/spellcheck/spellcheck_build_features.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h"
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"

#if !BUILDFLAG(HAS_SPELLCHECK_PANEL)
#error "This file shouldn't be compiled without spellcheck panel."
#endif

class SpellCheckPanel
    : public content::RenderViewObserver,
      public content::RenderViewObserverTracker<SpellCheckPanel>,
      public blink::WebSpellCheckClient {
 public:
  explicit SpellCheckPanel(content::RenderView* render_view);
  ~SpellCheckPanel() override;

  // RenderViewObserver implementation.
  bool OnMessageReceived(const IPC::Message& message) override;

 private:
  // RenderViewObserver implementation.
  void OnDestruct() override;

  // blink::WebSpellCheckClient implementation.
  void ShowSpellingUI(bool show) override;
  bool IsShowingSpellingUI() override;
  void UpdateSpellingUIWithMisspelledWord(
      const blink::WebString& word) override;

  void OnAdvanceToNextMisspelling();
  void OnToggleSpellPanel(bool is_currently_visible);

  // True if the browser is showing the spelling panel for us.
  bool spelling_panel_visible_;

  DISALLOW_COPY_AND_ASSIGN(SpellCheckPanel);
};

#endif