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

Unified Diff: views/ime/text_input_type_tracker.h

Issue 7217008: Use input method to control visibility of virtual keyboard (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 9 years, 5 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
« no previous file with comments | « views/ime/input_method_win.cc ('k') | views/ime/text_input_type_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/ime/text_input_type_tracker.h
diff --git a/views/ime/text_input_type_tracker.h b/views/ime/text_input_type_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..ecd16fdbfb0765f8569376db03409a7b8f8f9273
--- /dev/null
+++ b/views/ime/text_input_type_tracker.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 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 VIEWS_IME_TEXT_INPUT_TYPE_TRACKER_H_
+#define VIEWS_IME_TEXT_INPUT_TYPE_TRACKER_H_
+#pragma once
+
+#include "base/memory/singleton.h"
+#include "base/observer_list.h"
+#include "ui/base/ime/text_input_type.h"
+
+namespace views {
+
+class Widget;
+
+// This interface should be implemented by classes that want to be notified when
+// the text input type of the focused widget is changed or the focused widget is
+// changed.
+class TextInputTypeObserver {
+ public:
+ // This function will be called, when the text input type of focused |widget|
+ // is changed or the the widget is getting/losing focus.
+ virtual void TextInputTypeChanged(ui::TextInputType type, Widget* widget) = 0;
+
+ protected:
+ virtual ~TextInputTypeObserver() {}
+};
+
+// This class is for tracking the text input type of focused widget.
+class TextInputTypeTracker {
+ public:
+ // Returns the singleton instance.
+ static TextInputTypeTracker* GetInstance();
+
+ // Adds/removes a TextInputTypeObserver |observer| to the set of
+ // active observers.
+ void AddTextInputTypeObserver(TextInputTypeObserver* observer);
+ void RemoveTextInputTypeObserver(TextInputTypeObserver* observer);
+
+ // views::InputMethod should call this function with new text input |type| and
+ // the |widget| associated with the input method, when the text input type
+ // is changed.
+ // Note: The widget should have focus or is losing focus.
+ void OnTextInputTypeChanged(ui::TextInputType type, Widget* widget);
+
+ private:
+ TextInputTypeTracker();
+ ~TextInputTypeTracker();
+
+ ObserverList<TextInputTypeObserver> text_input_type_observers_;
+
+ friend struct DefaultSingletonTraits<TextInputTypeTracker>;
+ DISALLOW_COPY_AND_ASSIGN(TextInputTypeTracker);
+};
+
+} // namespace views
+
+#endif // VIEWS_IME_TEXT_INPUT_TYPE_TRACKER_H_
« no previous file with comments | « views/ime/input_method_win.cc ('k') | views/ime/text_input_type_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698