Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chromeos / ime / input_method_manager.h
index fefa0e1..b95f77c 100644 (file)
@@ -9,6 +9,7 @@
 #include <string>
 #include <vector>
 
+#include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
 #include "chromeos/chromeos_export.h"
 #include "chromeos/ime/input_method_descriptor.h"
@@ -19,6 +20,10 @@ namespace ui {
 class Accelerator;
 }  // namespace ui
 
+namespace user_manager {
+class User;
+}  // namespace user_manager
+
 namespace chromeos {
 class ComponentExtensionIMEManager;
 class InputMethodEngineInterface;
@@ -31,7 +36,7 @@ class ImeKeyboard;
 // InputMethodManager::Get().
 class CHROMEOS_EXPORT InputMethodManager {
  public:
-  enum State {
+  enum UISessionState {
     STATE_LOGIN_SCREEN = 0,
     STATE_BROWSER_SCREEN,
     STATE_LOCK_SCREEN,
@@ -61,6 +66,109 @@ class CHROMEOS_EXPORT InputMethodManager {
     virtual void CandidateWindowClosed(InputMethodManager* manager) = 0;
   };
 
+  class State : public base::RefCounted<InputMethodManager::State> {
+   public:
+    // Returns a copy of state.
+    virtual scoped_refptr<State> Clone() const = 0;
+
+    // Adds an input method extension. This function does not takes ownership of
+    // |instance|.
+    virtual void AddInputMethodExtension(
+        const std::string& extension_id,
+        const InputMethodDescriptors& descriptors,
+        InputMethodEngineInterface* instance) = 0;
+
+    // Removes an input method extension.
+    virtual void RemoveInputMethodExtension(
+        const std::string& extension_id) = 0;
+
+    // Changes the current input method to |input_method_id|. If
+    // |input_method_id|
+    // is not active, switch to the first one in the active input method list.
+    virtual void ChangeInputMethod(const std::string& input_method_id,
+                                   bool show_message) = 0;
+
+    // Adds one entry to the list of active input method IDs, and then starts or
+    // stops the system input method framework as needed.
+    virtual bool EnableInputMethod(
+        const std::string& new_active_input_method_id) = 0;
+
+    // Enables "login" keyboard layouts (e.g. US Qwerty, US Dvorak, French
+    // Azerty) that are necessary for the |language_code| and then switches to
+    // |initial_layouts| if the given list is not empty. For example, if
+    // |language_code| is "en-US", US Qwerty, US International, US Extended, US
+    // Dvorak, and US Colemak layouts would be enabled. Likewise, for Germany
+    // locale, US Qwerty which corresponds to the hardware keyboard layout and
+    // several keyboard layouts for Germany would be enabled.
+    // Only layouts suitable for login screen are enabled.
+    virtual void EnableLoginLayouts(
+        const std::string& language_code,
+        const std::vector<std::string>& initial_layouts) = 0;
+
+    // Filters current state layouts and leaves only suitable for lock screen.
+    virtual void EnableLockScreenLayouts() = 0;
+
+    // Returns a list of descriptors for all Input Method Extensions.
+    virtual void GetInputMethodExtensions(InputMethodDescriptors* result) = 0;
+
+    // Returns the list of input methods we can select (i.e. active) including
+    // extension input methods.
+    virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods()
+        const = 0;
+
+    // Returns the list of input methods we can select (i.e. active) including
+    // extension input methods.
+    // The same as GetActiveInputMethods but returns reference to internal list.
+    virtual const std::vector<std::string>& GetActiveInputMethodIds() const = 0;
+
+    // Returns the number of active input methods including extension input
+    // methods.
+    virtual size_t GetNumActiveInputMethods() const = 0;
+
+    // Returns the input method descriptor from the given input method id
+    // string.
+    // If the given input method id is invalid, returns NULL.
+    virtual const InputMethodDescriptor* GetInputMethodFromId(
+        const std::string& input_method_id) const = 0;
+
+    // Sets the list of extension IME ids which should be enabled.
+    virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) = 0;
+
+    // Sets current input method to login default (first owners, then hardware).
+    virtual void SetInputMethodLoginDefault() = 0;
+
+    // Sets current input method to login default with the given locale and
+    // layout info from VPD.
+    virtual void SetInputMethodLoginDefaultFromVPD(
+        const std::string& locale,
+        const std::string& layout) = 0;
+
+    // Switches the current input method (or keyboard layout) to the next one.
+    virtual bool SwitchToNextInputMethod() = 0;
+
+    // Switches the current input method (or keyboard layout) to the previous
+    // one.
+    virtual bool SwitchToPreviousInputMethod(
+        const ui::Accelerator& accelerator) = 0;
+
+    // Switches to an input method (or keyboard layout) which is associated with
+    // the |accelerator|.
+    virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) = 0;
+
+    // Gets the descriptor of the input method which is currently selected.
+    virtual InputMethodDescriptor GetCurrentInputMethod() const = 0;
+
+    // Updates the list of active input method IDs, and then starts or stops the
+    // system input method framework as needed.
+    virtual bool ReplaceEnabledInputMethods(
+        const std::vector<std::string>& new_active_input_method_ids) = 0;
+
+   protected:
+    friend base::RefCounted<InputMethodManager::State>;
+
+    virtual ~State();
+  };
+
   virtual ~InputMethodManager() {}
 
   // Gets the global instance of InputMethodManager. Initialize() must be called
@@ -77,7 +185,7 @@ class CHROMEOS_EXPORT InputMethodManager {
   static CHROMEOS_EXPORT void Shutdown();
 
   // Get the current UI session state (e.g. login screen, lock screen, etc.).
-  virtual State GetState() = 0;
+  virtual UISessionState GetUISessionState() = 0;
 
   // Adds an observer to receive notifications of input method related
   // changes as desribed in the Observer class above.
@@ -94,80 +202,9 @@ class CHROMEOS_EXPORT InputMethodManager {
   virtual scoped_ptr<InputMethodDescriptors>
       GetSupportedInputMethods() const = 0;
 
-  // Returns the list of input methods we can select (i.e. active) including
-  // extension input methods.
-  virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods() const = 0;
-
-  // Returns the list of input methods we can select (i.e. active) including
-  // extension input methods.
-  // The same as GetActiveInputMethods but returns reference to internal list.
-  virtual const std::vector<std::string>& GetActiveInputMethodIds() const = 0;
-
-  // Returns the number of active input methods including extension input
-  // methods.
-  virtual size_t GetNumActiveInputMethods() const = 0;
-
-  // Returns the input method descriptor from the given input method id string.
-  // If the given input method id is invalid, returns NULL.
-  virtual const InputMethodDescriptor* GetInputMethodFromId(
-      const std::string& input_method_id) const = 0;
-
-  // Changes the current input method to |input_method_id|. If |input_method_id|
-  // is not active, switch to the first one in the active input method list.
-  virtual void ChangeInputMethod(const std::string& input_method_id) = 0;
-
-  // Enables "login" keyboard layouts (e.g. US Qwerty, US Dvorak, French
-  // Azerty) that are necessary for the |language_code| and then switches to
-  // |initial_layouts| if the given list is not empty. For example, if
-  // |language_code| is "en-US", US Qwerty, US International, US Extended, US
-  // Dvorak, and US Colemak layouts would be enabled. Likewise, for Germany
-  // locale, US Qwerty which corresponds to the hardware keyboard layout and
-  // several keyboard layouts for Germany would be enabled.
-  // Only layouts suitable for login screen are enabled.
-  virtual void EnableLoginLayouts(
-      const std::string& language_code,
-      const std::vector<std::string>& initial_layouts) = 0;
-
   // Activates the input method property specified by the |key|.
   virtual void ActivateInputMethodMenuItem(const std::string& key) = 0;
 
-  // Updates the list of active input method IDs, and then starts or stops the
-  // system input method framework as needed.
-  virtual bool ReplaceEnabledInputMethods(
-      const std::vector<std::string>& new_active_input_method_ids) = 0;
-
-  // Adds one entry to the list of active input method IDs, and then starts or
-  // stops the system input method framework as needed.
-  virtual bool EnableInputMethod(
-      const std::string& new_active_input_method_id) = 0;
-
-  // Adds an input method extension. This function does not takes ownership of
-  // |instance|.
-  virtual void AddInputMethodExtension(
-      const std::string& extension_id,
-      const InputMethodDescriptors& descriptors,
-      InputMethodEngineInterface* instance) = 0;
-
-  // Removes an input method extension.
-  virtual void RemoveInputMethodExtension(const std::string& extension_id) = 0;
-
-  // Returns a list of descriptors for all Input Method Extensions.
-  virtual void GetInputMethodExtensions(InputMethodDescriptors* result) = 0;
-
-  // Sets the list of extension IME ids which should be enabled.
-  virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) = 0;
-
-  // Sets current input method to login default (first owners, then hardware).
-  virtual void SetInputMethodLoginDefault() = 0;
-
-  // Sets current input method to login default with the given locale and
-  // layout info from VPD.
-  virtual void SetInputMethodLoginDefaultFromVPD(
-      const std::string& locale, const std::string& layout) = 0;
-
-  // Gets the descriptor of the input method which is currently selected.
-  virtual InputMethodDescriptor GetCurrentInputMethod() const = 0;
-
   virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const = 0;
 
   virtual bool IsAltGrUsedByCurrentInputMethod() const = 0;
@@ -182,23 +219,21 @@ class CHROMEOS_EXPORT InputMethodManager {
   // Returns a ComponentExtentionIMEManager object.
   virtual ComponentExtensionIMEManager* GetComponentExtensionIMEManager() = 0;
 
-  // Switches the current input method (or keyboard layout) to the next one.
-  virtual bool SwitchToNextInputMethod() = 0;
-
-  // Switches the current input method (or keyboard layout) to the previous one.
-  virtual bool SwitchToPreviousInputMethod(
-      const ui::Accelerator& accelerator) = 0;
-
-  // Switches to an input method (or keyboard layout) which is associated with
-  // the |accelerator|.
-  virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) = 0;
-
   // If keyboard layout can be uset at login screen
   virtual bool IsLoginKeyboard(const std::string& layout) const = 0;
 
   // Migrates the input method id to extension-based input method id.
   virtual bool MigrateInputMethods(
       std::vector<std::string>* input_method_ids) = 0;
+
+  // Returns new empty state for the |profile|.
+  virtual scoped_refptr<State> CreateNewState(Profile* profile) = 0;
+
+  // Returns active state.
+  virtual scoped_refptr<InputMethodManager::State> GetActiveIMEState() = 0;
+
+  // Replaces active state.
+  virtual void SetState(scoped_refptr<State> state) = 0;
 };
 
 }  // namespace input_method