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

Unified Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.h

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 4 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: chrome/browser/chromeos/input_method/input_method_manager_impl.h
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.h b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
index 54698e400be37fecc4bbeed613df313fabfd0fd2..4db24406f694d549521e3045a869d450747d0358 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -30,13 +30,48 @@ class ImeKeyboard;
class InputMethodManagerImpl : public InputMethodManager,
public CandidateWindowController::Observer {
public:
+ class State : public InputMethodManager::State {
+ public:
+ State();
+
+ // Init new state as a copy of other.
+ void InitFrom(const State& other);
+
+ std::string Dump() const;
+
+ std::string state_name;
+
+ // The input method which was/is selected.
+ InputMethodDescriptor previous_input_method_;
+ InputMethodDescriptor current_input_method_;
+ // The active input method ids cache.
+ std::vector<std::string> active_input_method_ids_;
+
+ // For screen locker. When the screen is locked, |previous_input_method_|,
+ // |current_input_method_|, and |active_input_method_ids_| above are copied
+ // to these "saved" variables.
+ InputMethodDescriptor saved_previous_input_method_;
+ InputMethodDescriptor saved_current_input_method_;
+ std::vector<std::string> saved_active_input_method_ids_;
+
+ // The engine map:
+ // { input_method_id : Engine }.
Shu Chen 2014/08/07 15:40:19 s/input_method_id/extension_id
Alexander Alekseev 2014/08/13 10:14:15 Done.
+ typedef std::map<std::string, InputMethodEngineInterface*> EngineMap;
+ EngineMap engine_map_;
Shu Chen 2014/08/07 15:40:19 The engine_map_ is not profile based now, and it's
Alexander Alekseev 2014/08/13 10:14:15 Done.
+
+ protected:
+ friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
+ virtual ~State();
+ };
+
// Constructs an InputMethodManager instance. The client is responsible for
- // calling |SetState| in response to relevant changes in browser state.
+ // calling |SetUISessionState| in response to relevant changes in browser
+ // state.
explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate);
virtual ~InputMethodManagerImpl();
- // Receives notification of an InputMethodManager::State transition.
- void SetState(State new_state);
+ // Receives notification of an InputMethodManager::UISessionState transition.
+ void SetUISessionState(UISessionState new_ui_session);
// InputMethodManager override:
virtual void InitializeComponentExtension() OVERRIDE;
@@ -93,6 +128,11 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual bool MigrateInputMethods(
std::vector<std::string>* input_method_ids) OVERRIDE;
+ virtual scoped_refptr<InputMethodManager::State> CreateNewState(
+ const std::string& debug_name) const OVERRIDE;
+ virtual void SetState(
+ scoped_refptr<InputMethodManager::State> state) OVERRIDE;
+
// Sets |candidate_window_controller_|.
void SetCandidateWindowControllerForTesting(
CandidateWindowController* candidate_window_controller);
@@ -138,11 +178,14 @@ class InputMethodManagerImpl : public InputMethodManager,
const std::vector<std::string>& input_method_ids,
const std::string& current_input_method_id);
- // Change system input method.
- // Returns true if the system input method is changed.
- bool ChangeInputMethodInternal(const std::string& input_method_id,
+ // Change system input method and inform observers. Doesn't modify state.
+ void ChangeInputMethodInternal(const InputMethodDescriptor& input_method_id,
bool show_message);
+ // Change system input method.
+ void LookupAndChangeInputMethodInternal(const std::string& input_method_id,
+ bool show_message);
+
// Loads necessary component extensions.
// TODO(nona): Support dynamical unloading.
void LoadNecessaryComponentExtensions();
@@ -159,27 +202,16 @@ class InputMethodManagerImpl : public InputMethodManager,
scoped_ptr<InputMethodDelegate> delegate_;
// The current browser status.
- State state_;
+ UISessionState ui_session_;
// A list of objects that monitor the manager.
ObserverList<InputMethodManager::Observer> observers_;
ObserverList<CandidateWindowObserver> candidate_window_observers_;
- // The input method which was/is selected.
- InputMethodDescriptor previous_input_method_;
- InputMethodDescriptor current_input_method_;
- // The active input method ids cache.
- std::vector<std::string> active_input_method_ids_;
-
// The list of enabled extension IMEs.
std::vector<std::string> enabled_extension_imes_;
- // For screen locker. When the screen is locked, |previous_input_method_|,
- // |current_input_method_|, and |active_input_method_ids_| above are copied
- // to these "saved" variables.
- InputMethodDescriptor saved_previous_input_method_;
- InputMethodDescriptor saved_current_input_method_;
- std::vector<std::string> saved_active_input_method_ids_;
+ scoped_refptr<InputMethodManagerImpl::State> state_;
// Extra input methods that have been explicitly added to the menu, such as
// those created by extension.
@@ -204,9 +236,6 @@ class InputMethodManagerImpl : public InputMethodManager,
base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_;
- // The engine map from extension_id to an engine.
- std::map<std::string, InputMethodEngineInterface*> engine_map_;
-
DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
};

Powered by Google App Engine
This is Rietveld 408576698