OLD | NEW |
---|---|
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 #include "chrome/browser/chromeos/extensions/input_method_api.h" | 5 #include "chrome/browser/chromeos/extensions/input_method_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/chromeos/extensions/dictionary_event_router.h" | 16 #include "chrome/browser/chromeos/extensions/dictionary_event_router.h" |
17 #include "chrome/browser/chromeos/extensions/ime_menu_event_router.h" | |
17 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 18 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
18 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 19 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
19 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" | 20 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
20 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 21 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
21 #include "chrome/browser/spellchecker/spellcheck_service.h" | 22 #include "chrome/browser/spellchecker/spellcheck_service.h" |
22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
23 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
24 #include "components/browser_sync/browser/profile_sync_service.h" | 25 #include "components/browser_sync/browser/profile_sync_service.h" |
25 #include "extensions/browser/extension_function_registry.h" | 26 #include "extensions/browser/extension_function_registry.h" |
26 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 "inputMethodPrivate.onDictionaryChanged"; | 180 "inputMethodPrivate.onDictionaryChanged"; |
180 | 181 |
181 // static | 182 // static |
182 const char InputMethodAPI::kOnDictionaryLoaded[] = | 183 const char InputMethodAPI::kOnDictionaryLoaded[] = |
183 "inputMethodPrivate.onDictionaryLoaded"; | 184 "inputMethodPrivate.onDictionaryLoaded"; |
184 | 185 |
185 // static | 186 // static |
186 const char InputMethodAPI::kOnInputMethodChanged[] = | 187 const char InputMethodAPI::kOnInputMethodChanged[] = |
187 "inputMethodPrivate.onChanged"; | 188 "inputMethodPrivate.onChanged"; |
188 | 189 |
190 // static | |
191 const char InputMethodAPI::kOnImeMenuActivationChanged[] = | |
192 "inputMethodPrivate.onImeMenuActivationChanged"; | |
193 | |
189 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) | 194 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) |
190 : context_(context) { | 195 : context_(context) { |
191 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); | 196 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); |
192 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryChanged); | 197 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryChanged); |
193 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryLoaded); | 198 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryLoaded); |
199 EventRouter::Get(context_) | |
200 ->RegisterObserver(this, kOnImeMenuActivationChanged); | |
194 ExtensionFunctionRegistry* registry = | 201 ExtensionFunctionRegistry* registry = |
195 ExtensionFunctionRegistry::GetInstance(); | 202 ExtensionFunctionRegistry::GetInstance(); |
196 registry->RegisterFunction<GetInputMethodConfigFunction>(); | 203 registry->RegisterFunction<GetInputMethodConfigFunction>(); |
197 registry->RegisterFunction<GetCurrentInputMethodFunction>(); | 204 registry->RegisterFunction<GetCurrentInputMethodFunction>(); |
198 registry->RegisterFunction<SetCurrentInputMethodFunction>(); | 205 registry->RegisterFunction<SetCurrentInputMethodFunction>(); |
199 registry->RegisterFunction<GetInputMethodsFunction>(); | 206 registry->RegisterFunction<GetInputMethodsFunction>(); |
200 registry->RegisterFunction<FetchAllDictionaryWordsFunction>(); | 207 registry->RegisterFunction<FetchAllDictionaryWordsFunction>(); |
201 registry->RegisterFunction<AddWordToDictionaryFunction>(); | 208 registry->RegisterFunction<AddWordToDictionaryFunction>(); |
202 registry->RegisterFunction<GetEncryptSyncEnabledFunction>(); | 209 registry->RegisterFunction<GetEncryptSyncEnabledFunction>(); |
203 } | 210 } |
(...skipping 23 matching lines...) Expand all Loading... | |
227 } | 234 } |
228 } else if (details.event_name == kOnDictionaryChanged || | 235 } else if (details.event_name == kOnDictionaryChanged || |
229 details.event_name == kOnDictionaryLoaded) { | 236 details.event_name == kOnDictionaryLoaded) { |
230 if (!dictionary_event_router_.get()) { | 237 if (!dictionary_event_router_.get()) { |
231 dictionary_event_router_.reset( | 238 dictionary_event_router_.reset( |
232 new chromeos::ExtensionDictionaryEventRouter(context_)); | 239 new chromeos::ExtensionDictionaryEventRouter(context_)); |
233 } | 240 } |
234 if (details.event_name == kOnDictionaryLoaded) { | 241 if (details.event_name == kOnDictionaryLoaded) { |
235 dictionary_event_router_->DispatchLoadedEventIfLoaded(); | 242 dictionary_event_router_->DispatchLoadedEventIfLoaded(); |
236 } | 243 } |
244 } else if (details.event_name == kOnImeMenuActivationChanged) { | |
245 if (!ime_menu_event_router_.get()) { | |
Devlin
2016/01/13 18:11:27
Is this different than
else if (details.event_name
Azure Wei
2016/01/14 09:38:26
Done.
| |
246 ime_menu_event_router_.reset( | |
247 new chromeos::ExtensionImeMenuEventRouter(context_)); | |
248 } | |
237 } | 249 } |
238 } | 250 } |
239 | 251 |
240 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > | 252 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > |
241 g_factory = LAZY_INSTANCE_INITIALIZER; | 253 g_factory = LAZY_INSTANCE_INITIALIZER; |
242 | 254 |
243 // static | 255 // static |
244 BrowserContextKeyedAPIFactory<InputMethodAPI>* | 256 BrowserContextKeyedAPIFactory<InputMethodAPI>* |
245 InputMethodAPI::GetFactoryInstance() { | 257 InputMethodAPI::GetFactoryInstance() { |
246 return g_factory.Pointer(); | 258 return g_factory.Pointer(); |
247 } | 259 } |
248 | 260 |
249 } // namespace extensions | 261 } // namespace extensions |
OLD | NEW |