summaryrefslogtreecommitdiffstats
path: root/components/html_viewer/ime_controller.h
blob: 740b5c5eca15365521be4340a5a1ac0b39dc0ee6 (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
49
50
51
52
// Copyright 2015 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_HTML_VIEWER_IME_CONTROLLER_H_
#define COMPONENTS_HTML_VIEWER_IME_CONTROLLER_H_

#include "third_party/WebKit/public/web/WebTextInputInfo.h"

namespace blink {
class WebGestureEvent;
class WebWidget;
}

namespace mus {
class Window;
}

namespace html_viewer {

// This class is used by HTMLWidgetRootLocal and HTMLWidgetLocalRoot for
// handling IME related stuff.
class ImeController {
 public:
  ImeController(mus::Window* window, blink::WebWidget* widget);
  ~ImeController();

  // Methods called by WebWidget overrides.
  void ResetInputMethod();
  void DidHandleGestureEvent(const blink::WebGestureEvent& event,
                             bool event_cancelled);
  void DidUpdateTextOfFocusedElementByNonUserInput();
  void ShowImeIfNeeded();

 private:
  // Update text input state from WebWidget to mus::Window. If the focused
  // element is editable and |show_ime| is True, the software keyboard will be
  // shown.
  void UpdateTextInputState(bool show_ime);

  // Not owned objects.
  mus::Window* window_;
  blink::WebWidget* widget_;

  blink::WebTextInputInfo text_input_info_;

  DISALLOW_COPY_AND_ASSIGN(ImeController);
};

}  // namespace html_viewer

#endif  // COMPONENTS_HTML_VIEWER_IME_CONTROLLER_H_