Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: ui/aura/window_tree_host.h

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0f1510f8148dd45489a8c32f58306e47eedf4196 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,10 @@ 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 +119,17 @@ 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);
+
+ // Overridden from ui::internal::InputMethodDelegate:
+ bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override;
+
// Returns the EventSource responsible for dispatching events to the window
// tree.
virtual ui::EventSource* GetEventSource() = 0;
@@ -166,6 +180,10 @@ class AURA_EXPORT WindowTreeHost {
// kCalled when the cursor visibility has changed.
virtual void OnCursorVisibilityChangedNative(bool show) = 0;
+ // Overridden from ui::EventSource:
+ ui::EventProcessor* GetEventProcessor() override;
+ ui::EventDispatchDetails DeliverEventToProcessor(ui::Event* event) override;
+
private:
friend class test::WindowTreeHostTestApi;
@@ -192,6 +210,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);
};

Powered by Google App Engine
This is Rietveld 408576698