Index: ui/aura/window_tree_host.h |
diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h |
index 0d09093bca14112928d511225b89288b22dd973c..26ca0fcb3ac32934b661928489ebfea930a2a585 100644 |
--- a/ui/aura/window_tree_host.h |
+++ b/ui/aura/window_tree_host.h |
@@ -11,6 +11,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "ui/aura/aura_export.h" |
#include "ui/base/cursor/cursor.h" |
+#include "ui/base/ime/input_method_delegate.h" |
#include "ui/events/event_source.h" |
#include "ui/gfx/native_widget_types.h" |
@@ -25,6 +26,7 @@ class Transform; |
namespace ui { |
class Compositor; |
class EventProcessor; |
+class InputMethod; |
class ViewProp; |
} |
@@ -39,9 +41,11 @@ class WindowTreeHostObserver; |
// WindowTreeHost bridges between a native window and the embedded RootWindow. |
// It provides the accelerated widget and maps events from the native os to |
// aura. |
-class AURA_EXPORT WindowTreeHost { |
+class AURA_EXPORT WindowTreeHost |
+ : public ui::internal::InputMethodDelegate, |
+ public ui::EventSource { |
public: |
- virtual ~WindowTreeHost(); |
+ ~WindowTreeHost() override; |
// Creates a new WindowTreeHost. The caller owns the returned value. |
static WindowTreeHost* Create(const gfx::Rect& bounds); |
@@ -116,6 +120,14 @@ class AURA_EXPORT WindowTreeHost { |
gfx::NativeCursor last_cursor() const { return last_cursor_; } |
+ // Gets the InputMethod instance, if NULL, creates & owns it. |
+ ui::InputMethod* GetInputMethod(); |
+ |
+ // Sets the InputMethod instance, and it is not owned by this WindowTreeHost. |
+ // This is to let some environment can have the singleton InputMethod |
+ // instance cross multiple WindowTreeHost's (e.g. Ash). |
+ void SetInputMethod(ui::InputMethod* input_method); |
+ |
// Returns the EventSource responsible for dispatching events to the window |
// tree. |
virtual ui::EventSource* GetEventSource() = 0; |
@@ -166,6 +178,13 @@ class AURA_EXPORT WindowTreeHost { |
// kCalled when the cursor visibility has changed. |
virtual void OnCursorVisibilityChangedNative(bool show) = 0; |
+ // Overridden from ui::internal::InputMethodDelegate: |
+ bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override; |
+ |
+ // Overridden from ui::EventSource: |
+ ui::EventProcessor* GetEventProcessor() override; |
+ ui::EventDispatchDetails DeliverEventToProcessor(ui::Event* event) override; |
+ |
private: |
friend class test::WindowTreeHostTestApi; |
@@ -192,6 +211,16 @@ class AURA_EXPORT WindowTreeHost { |
scoped_ptr<ui::ViewProp> prop_; |
+ // The InputMethod instance used to process key events. |
+ // If owned it, it is created in GetInputMethod() method; |
+ // If not owned it, it is passed in through SetInputMethod() method. |
+ ui::InputMethod* input_method_; |
+ |
+ // Whether the InputMethod instance is owned by this WindowTreeHost. |
+ // So that the destructor can determine whether to release the InputMethod |
+ // instance. |
+ bool owned_input_method_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); |
}; |