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

Side by Side Diff: chrome/browser/chromeos/extensions/input_method_api.cc

Issue 1523593002: Add an option in language settings for activating the IME menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 #include "chrome/browser/chromeos/extensions/input_method_api.h" 5 #include "chrome/browser/chromeos/extensions/input_method_api.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chromeos/extensions/dictionary_event_router.h" 13 #include "chrome/browser/chromeos/extensions/dictionary_event_router.h"
14 #include "chrome/browser/chromeos/extensions/ime_menu_event_router.h"
14 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 15 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
15 #include "chrome/browser/chromeos/input_method/input_method_util.h" 16 #include "chrome/browser/chromeos/input_method/input_method_util.h"
16 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" 17 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
17 #include "chrome/browser/spellchecker/spellcheck_factory.h" 18 #include "chrome/browser/spellchecker/spellcheck_factory.h"
18 #include "chrome/browser/spellchecker/spellcheck_service.h" 19 #include "chrome/browser/spellchecker/spellcheck_service.h"
19 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
20 #include "chromeos/chromeos_switches.h" 21 #include "chromeos/chromeos_switches.h"
21 #include "components/browser_sync/browser/profile_sync_service.h" 22 #include "components/browser_sync/browser/profile_sync_service.h"
22 #include "extensions/browser/extension_function_registry.h" 23 #include "extensions/browser/extension_function_registry.h"
23 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 "inputMethodPrivate.onDictionaryChanged"; 177 "inputMethodPrivate.onDictionaryChanged";
177 178
178 // static 179 // static
179 const char InputMethodAPI::kOnDictionaryLoaded[] = 180 const char InputMethodAPI::kOnDictionaryLoaded[] =
180 "inputMethodPrivate.onDictionaryLoaded"; 181 "inputMethodPrivate.onDictionaryLoaded";
181 182
182 // static 183 // static
183 const char InputMethodAPI::kOnInputMethodChanged[] = 184 const char InputMethodAPI::kOnInputMethodChanged[] =
184 "inputMethodPrivate.onChanged"; 185 "inputMethodPrivate.onChanged";
185 186
187 // static
188 const char InputMethodAPI::kOnImeMenuActivated[] =
189 "inputMethodPrivate.onImeMenuActivated";
190
191 // static
192 const char InputMethodAPI::kOnImeMenuDeactivated[] =
193 "inputMethodPrivate.onImeMenuDeactivated";
194
186 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) 195 InputMethodAPI::InputMethodAPI(content::BrowserContext* context)
187 : context_(context) { 196 : context_(context) {
188 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); 197 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged);
189 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryChanged); 198 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryChanged);
190 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryLoaded); 199 EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryLoaded);
200 EventRouter::Get(context_)->RegisterObserver(this, kOnImeMenuActivated);
201 EventRouter::Get(context_)->RegisterObserver(this, kOnImeMenuDeactivated);
191 ExtensionFunctionRegistry* registry = 202 ExtensionFunctionRegistry* registry =
192 ExtensionFunctionRegistry::GetInstance(); 203 ExtensionFunctionRegistry::GetInstance();
193 registry->RegisterFunction<GetInputMethodConfigFunction>(); 204 registry->RegisterFunction<GetInputMethodConfigFunction>();
194 registry->RegisterFunction<GetCurrentInputMethodFunction>(); 205 registry->RegisterFunction<GetCurrentInputMethodFunction>();
195 registry->RegisterFunction<SetCurrentInputMethodFunction>(); 206 registry->RegisterFunction<SetCurrentInputMethodFunction>();
196 registry->RegisterFunction<GetInputMethodsFunction>(); 207 registry->RegisterFunction<GetInputMethodsFunction>();
197 registry->RegisterFunction<FetchAllDictionaryWordsFunction>(); 208 registry->RegisterFunction<FetchAllDictionaryWordsFunction>();
198 registry->RegisterFunction<AddWordToDictionaryFunction>(); 209 registry->RegisterFunction<AddWordToDictionaryFunction>();
199 registry->RegisterFunction<GetEncryptSyncEnabledFunction>(); 210 registry->RegisterFunction<GetEncryptSyncEnabledFunction>();
200 } 211 }
(...skipping 23 matching lines...) Expand all
224 } 235 }
225 } else if (details.event_name == kOnDictionaryChanged || 236 } else if (details.event_name == kOnDictionaryChanged ||
226 details.event_name == kOnDictionaryLoaded) { 237 details.event_name == kOnDictionaryLoaded) {
227 if (!dictionary_event_router_.get()) { 238 if (!dictionary_event_router_.get()) {
228 dictionary_event_router_.reset( 239 dictionary_event_router_.reset(
229 new chromeos::ExtensionDictionaryEventRouter(context_)); 240 new chromeos::ExtensionDictionaryEventRouter(context_));
230 } 241 }
231 if (details.event_name == kOnDictionaryLoaded) { 242 if (details.event_name == kOnDictionaryLoaded) {
232 dictionary_event_router_->DispatchLoadedEventIfLoaded(); 243 dictionary_event_router_->DispatchLoadedEventIfLoaded();
233 } 244 }
245 } else if (details.event_name == kOnImeMenuActivated ||
246 details.event_name == kOnImeMenuDeactivated) {
247 if (!ime_menu_event_router_.get()) {
248 ime_menu_event_router_.reset(
249 new chromeos::ExtensionImeMenuEventRouter(context_));
250 }
234 } 251 }
235 } 252 }
236 253
237 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > 254 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> >
238 g_factory = LAZY_INSTANCE_INITIALIZER; 255 g_factory = LAZY_INSTANCE_INITIALIZER;
239 256
240 // static 257 // static
241 BrowserContextKeyedAPIFactory<InputMethodAPI>* 258 BrowserContextKeyedAPIFactory<InputMethodAPI>*
242 InputMethodAPI::GetFactoryInstance() { 259 InputMethodAPI::GetFactoryInstance() {
243 return g_factory.Pointer(); 260 return g_factory.Pointer();
244 } 261 }
245 262
246 } // namespace extensions 263 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698