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

Side by Side Diff: chrome/browser/chromeos/input_method/ibus_controller_impl.h

Issue 11558017: Decouple input_method from BrowserThread (and content/). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build failure. Created 7 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
7 7
8 #include <gio/gio.h> // GAsyncResult and related types. 8 #include <gio/gio.h> // GAsyncResult and related types.
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h"
13 #include "base/process_util.h" 14 #include "base/process_util.h"
14 #include "chrome/browser/chromeos/input_method/ibus_controller_base.h" 15 #include "chrome/browser/chromeos/input_method/ibus_controller_base.h"
15 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" 16 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
16 #include "chromeos/dbus/ibus/ibus_panel_service.h" 17 #include "chromeos/dbus/ibus/ibus_panel_service.h"
17 18
19 namespace base {
20 class SequencedTaskRunner;
21 } // namespace base
22
18 namespace ui { 23 namespace ui {
19 class InputMethodIBus; 24 class InputMethodIBus;
20 } // namespace ui 25 } // namespace ui
21 26
22 namespace chromeos { 27 namespace chromeos {
23 namespace input_method { 28 namespace input_method {
24 29
25 struct InputMethodConfigValue; 30 struct InputMethodConfigValue;
26 struct InputMethodProperty; 31 struct InputMethodProperty;
27 typedef std::vector<InputMethodProperty> InputMethodPropertyList; 32 typedef std::vector<InputMethodProperty> InputMethodPropertyList;
28 33
29 // The IBusController implementation. 34 // The IBusController implementation.
30 class IBusControllerImpl : public IBusControllerBase, 35 class IBusControllerImpl : public IBusControllerBase,
31 public ibus::IBusPanelPropertyHandlerInterface { 36 public ibus::IBusPanelPropertyHandlerInterface {
32 public: 37 public:
33 IBusControllerImpl(); 38 // Creates an IBusController. All public methods must be invoked in the
39 // context of |default_task_runner|. |worker_task_runner| will be used to
40 // execute potentially blocking file tasks.
41 IBusControllerImpl(
42 const scoped_refptr<base::SequencedTaskRunner>& default_task_runner,
43 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner);
34 virtual ~IBusControllerImpl(); 44 virtual ~IBusControllerImpl();
35 45
36 // IBusController overrides: 46 // IBusController overrides:
37 virtual bool Start() OVERRIDE; 47 virtual bool Start() OVERRIDE;
38 virtual void Reset() OVERRIDE; 48 virtual void Reset() OVERRIDE;
39 virtual bool Stop() OVERRIDE; 49 virtual bool Stop() OVERRIDE;
40 virtual bool ChangeInputMethod(const std::string& id) OVERRIDE; 50 virtual bool ChangeInputMethod(const std::string& id) OVERRIDE;
41 virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE; 51 virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE;
42 52
43 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for 53 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for
44 // unit testing. 54 // unit testing.
45 static bool FindAndUpdatePropertyForTesting( 55 static bool FindAndUpdatePropertyForTesting(
46 const InputMethodProperty& new_prop, 56 const InputMethodProperty& new_prop,
47 InputMethodPropertyList* prop_list); 57 InputMethodPropertyList* prop_list);
48 58
49 static void IBusDaemonInitializationDone(IBusControllerImpl* controller,
50 const std::string& ibus_address);
51
52 private: 59 private:
53 enum IBusDaemonStatus{ 60 enum IBusDaemonStatus{
54 IBUS_DAEMON_INITIALIZING, 61 IBUS_DAEMON_INITIALIZING,
55 IBUS_DAEMON_RUNNING, 62 IBUS_DAEMON_RUNNING,
56 IBUS_DAEMON_SHUTTING_DOWN, 63 IBUS_DAEMON_SHUTTING_DOWN,
57 IBUS_DAEMON_STOP, 64 IBUS_DAEMON_STOP,
58 }; 65 };
59 66
60 // IBusControllerBase overrides: 67 // IBusControllerBase overrides:
61 virtual bool SetInputMethodConfigInternal( 68 virtual bool SetInputMethodConfigInternal(
(...skipping 26 matching lines...) Expand all
88 base::ProcessHandle* process_handle, 95 base::ProcessHandle* process_handle,
89 GChildWatchFunc watch_func); 96 GChildWatchFunc watch_func);
90 97
91 // Returns pointer to InputMethod object. 98 // Returns pointer to InputMethod object.
92 ui::InputMethodIBus* GetInputMethod(); 99 ui::InputMethodIBus* GetInputMethod();
93 100
94 // Injects an alternative ui::InputMethod for testing. 101 // Injects an alternative ui::InputMethod for testing.
95 // The injected object must be released by caller. 102 // The injected object must be released by caller.
96 void set_input_method_for_testing(ui::InputMethodIBus* input_method); 103 void set_input_method_for_testing(ui::InputMethodIBus* input_method);
97 104
105 // Receives a notification on a worker thread and posts a call to
106 // IBusDaemonInitializationDone on the default task runner.
107 void IBusDaemonInitializationDoneWorkerCallback(
108 const std::string& ibus_address);
109
110 void IBusDaemonInitializationDone(const std::string& ibus_address);
111
98 // Called when the IBusConfigClient is initialized. 112 // Called when the IBusConfigClient is initialized.
99 void OnIBusConfigClientInitialized(); 113 void OnIBusConfigClientInitialized();
100 114
101 // Called when the input method process is shut down. 115 // Called when the input method process is shut down.
102 static void OnIBusDaemonExit(GPid pid, 116 static void OnIBusDaemonExit(GPid pid,
103 gint status, 117 gint status,
104 IBusControllerImpl* controller); 118 IBusControllerImpl* controller);
105 119
106 // The current ibus_daemon address. This value is assigned at the launching 120 // The current ibus_daemon address. This value is assigned at the launching
107 // ibus-daemon and used in bus connection initialization. 121 // ibus-daemon and used in bus connection initialization.
(...skipping 12 matching lines...) Expand all
120 134
121 // An object which knows all valid input methods and layout IDs. 135 // An object which knows all valid input methods and layout IDs.
122 InputMethodWhitelist whitelist_; 136 InputMethodWhitelist whitelist_;
123 137
124 // Represents ibus-daemon's status. 138 // Represents ibus-daemon's status.
125 IBusDaemonStatus ibus_daemon_status_; 139 IBusDaemonStatus ibus_daemon_status_;
126 140
127 // The pointer to global input method. We can inject this value for testing. 141 // The pointer to global input method. We can inject this value for testing.
128 ui::InputMethodIBus* input_method_; 142 ui::InputMethodIBus* input_method_;
129 143
144 scoped_refptr<base::SequencedTaskRunner> default_task_runner_;
145 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
146
130 // Used for making callbacks for PostTask. 147 // Used for making callbacks for PostTask.
131 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_; 148 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_;
132 149
133 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); 150 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl);
134 }; 151 };
135 152
136 } // namespace input_method 153 } // namespace input_method
137 } // namespace chromeos 154 } // namespace chromeos
138 155
139 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ 156 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller.cc ('k') | chrome/browser/chromeos/input_method/ibus_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698