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

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: Created 8 years 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 IBusControllerImpl(
Seigo Nonaka 2012/12/13 05:40:11 nit: please add comment for |default_task_runner|
39 const scoped_refptr<base::SequencedTaskRunner>& default_task_runner,
40 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner);
34 virtual ~IBusControllerImpl(); 41 virtual ~IBusControllerImpl();
35 42
36 // IBusController overrides: 43 // IBusController overrides:
37 virtual bool Start() OVERRIDE; 44 virtual bool Start() OVERRIDE;
38 virtual void Reset() OVERRIDE; 45 virtual void Reset() OVERRIDE;
39 virtual bool Stop() OVERRIDE; 46 virtual bool Stop() OVERRIDE;
40 virtual bool ChangeInputMethod(const std::string& id) OVERRIDE; 47 virtual bool ChangeInputMethod(const std::string& id) OVERRIDE;
41 virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE; 48 virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE;
42 49
43 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for 50 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for
44 // unit testing. 51 // unit testing.
45 static bool FindAndUpdatePropertyForTesting( 52 static bool FindAndUpdatePropertyForTesting(
46 const InputMethodProperty& new_prop, 53 const InputMethodProperty& new_prop,
47 InputMethodPropertyList* prop_list); 54 InputMethodPropertyList* prop_list);
48 55
49 static void IBusDaemonInitializationDone(IBusControllerImpl* controller,
50 const std::string& ibus_address);
51
52 private: 56 private:
53 enum IBusDaemonStatus{ 57 enum IBusDaemonStatus{
54 IBUS_DAEMON_INITIALIZING, 58 IBUS_DAEMON_INITIALIZING,
55 IBUS_DAEMON_RUNNING, 59 IBUS_DAEMON_RUNNING,
56 IBUS_DAEMON_SHUTTING_DOWN, 60 IBUS_DAEMON_SHUTTING_DOWN,
57 IBUS_DAEMON_STOP, 61 IBUS_DAEMON_STOP,
58 }; 62 };
59 63
60 // IBusControllerBase overrides: 64 // IBusControllerBase overrides:
61 virtual bool SetInputMethodConfigInternal( 65 virtual bool SetInputMethodConfigInternal(
(...skipping 26 matching lines...) Expand all
88 base::ProcessHandle* process_handle, 92 base::ProcessHandle* process_handle,
89 GChildWatchFunc watch_func); 93 GChildWatchFunc watch_func);
90 94
91 // Returns pointer to InputMethod object. 95 // Returns pointer to InputMethod object.
92 ui::InputMethodIBus* GetInputMethod(); 96 ui::InputMethodIBus* GetInputMethod();
93 97
94 // Injects an alternative ui::InputMethod for testing. 98 // Injects an alternative ui::InputMethod for testing.
95 // The injected object must be released by caller. 99 // The injected object must be released by caller.
96 void set_input_method_for_testing(ui::InputMethodIBus* input_method); 100 void set_input_method_for_testing(ui::InputMethodIBus* input_method);
97 101
102 // Receives a notification on a worker thread and posts a call to
103 // IBusDaemonInitializationDone on the default task runner.
104 void IBusDaemonInitializationDoneWorkerCallback(
105 const std::string& ibus_address);
106
107 void IBusDaemonInitializationDone(const std::string& ibus_address);
108
98 // Called when the IBusConfigClient is initialized. 109 // Called when the IBusConfigClient is initialized.
99 void OnIBusConfigClientInitialized(); 110 void OnIBusConfigClientInitialized();
100 111
101 // Called when the input method process is shut down. 112 // Called when the input method process is shut down.
102 static void OnIBusDaemonExit(GPid pid, 113 static void OnIBusDaemonExit(GPid pid,
103 gint status, 114 gint status,
104 IBusControllerImpl* controller); 115 IBusControllerImpl* controller);
105 116
106 // The current ibus_daemon address. This value is assigned at the launching 117 // The current ibus_daemon address. This value is assigned at the launching
107 // ibus-daemon and used in bus connection initialization. 118 // ibus-daemon and used in bus connection initialization.
(...skipping 12 matching lines...) Expand all
120 131
121 // An object which knows all valid input methods and layout IDs. 132 // An object which knows all valid input methods and layout IDs.
122 InputMethodWhitelist whitelist_; 133 InputMethodWhitelist whitelist_;
123 134
124 // Represents ibus-daemon's status. 135 // Represents ibus-daemon's status.
125 IBusDaemonStatus ibus_daemon_status_; 136 IBusDaemonStatus ibus_daemon_status_;
126 137
127 // The pointer to global input method. We can inject this value for testing. 138 // The pointer to global input method. We can inject this value for testing.
128 ui::InputMethodIBus* input_method_; 139 ui::InputMethodIBus* input_method_;
129 140
141 scoped_refptr<base::SequencedTaskRunner> default_task_runner_;
142 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
143
130 // Used for making callbacks for PostTask. 144 // Used for making callbacks for PostTask.
131 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_; 145 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_;
132 146
133 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); 147 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl);
134 }; 148 };
135 149
136 } // namespace input_method 150 } // namespace input_method
137 } // namespace chromeos 151 } // namespace chromeos
138 152
139 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ 153 #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