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

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api.cc

Issue 531613002: InputImeEventRouter::RegisterImeExtension should register extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/extensions/api/input_ime/input_ime_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/input_ime/input_ime_api.h" 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 9 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
11 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
12 #include "chrome/browser/chromeos/profiles/profile_helper.h" 13 #include "chrome/browser/chromeos/profiles/profile_helper.h"
13 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/extensions/api/input_ime.h" 16 #include "chrome/common/extensions/api/input_ime.h"
16 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" 17 #include "chrome/common/extensions/api/input_ime/input_components_handler.h"
17 #include "chromeos/ime/component_extension_ime_manager.h" 18 #include "chromeos/ime/component_extension_ime_manager.h"
18 #include "chromeos/ime/extension_ime_util.h" 19 #include "chromeos/ime/extension_ime_util.h"
19 #include "chromeos/ime/input_method_manager.h" 20 #include "chromeos/ime/input_method_manager.h"
20 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } // namespace chromeos 334 } // namespace chromeos
334 335
335 namespace extensions { 336 namespace extensions {
336 337
337 InputImeEventRouter* 338 InputImeEventRouter*
338 InputImeEventRouter::GetInstance() { 339 InputImeEventRouter::GetInstance() {
339 return Singleton<InputImeEventRouter>::get(); 340 return Singleton<InputImeEventRouter>::get();
340 } 341 }
341 342
342 bool InputImeEventRouter::RegisterImeExtension( 343 bool InputImeEventRouter::RegisterImeExtension(
344 Profile* profile,
343 const std::string& extension_id, 345 const std::string& extension_id,
344 const std::vector<extensions::InputComponentInfo>& input_components) { 346 const std::vector<extensions::InputComponentInfo>& input_components) {
345 VLOG(1) << "RegisterImeExtension: " << extension_id; 347 VLOG(1) << "RegisterImeExtension: " << extension_id;
346 348
347 if (engine_map_[extension_id]) 349 if (engine_map_[extension_id])
348 return false; 350 return false;
349 351
350 chromeos::input_method::InputMethodManager* manager = 352 chromeos::input_method::InputMethodManager* manager =
351 chromeos::input_method::InputMethodManager::Get(); 353 chromeos::input_method::InputMethodManager::Get();
352 chromeos::ComponentExtensionIMEManager* comp_ext_ime_manager = 354 chromeos::ComponentExtensionIMEManager* comp_ext_ime_manager =
(...skipping 28 matching lines...) Expand all
381 component.options_page_url, 383 component.options_page_url,
382 component.input_view_url)); 384 component.input_view_url));
383 } 385 }
384 } 386 }
385 387
386 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer( 388 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer(
387 new chromeos::ImeObserver(extension_id)); 389 new chromeos::ImeObserver(extension_id));
388 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); 390 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine();
389 engine->Initialize(observer.Pass(), extension_id.c_str()); 391 engine->Initialize(observer.Pass(), extension_id.c_str());
390 engine_map_[extension_id] = engine; 392 engine_map_[extension_id] = engine;
391 manager->GetActiveIMEState()->AddInputMethodExtension( 393 chromeos::UserSessionManager::GetInstance()
392 extension_id, descriptors, engine); 394 ->GetDefaultIMEState(profile)
395 ->AddInputMethodExtension(extension_id, descriptors, engine);
393 396
394 return true; 397 return true;
395 } 398 }
396 399
397 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) { 400 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) {
398 std::map<std::string, InputMethodEngineInterface*>::iterator it = 401 std::map<std::string, InputMethodEngineInterface*>::iterator it =
399 engine_map_.find(extension_id); 402 engine_map_.find(extension_id);
400 if (it != engine_map_.end()) { 403 if (it != engine_map_.end()) {
401 chromeos::input_method::InputMethodManager::Get() 404 chromeos::input_method::InputMethodManager::Get()
402 ->GetActiveIMEState() 405 ->GetActiveIMEState()
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 // static 821 // static
819 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { 822 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() {
820 return g_factory.Pointer(); 823 return g_factory.Pointer();
821 } 824 }
822 825
823 void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context, 826 void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
824 const Extension* extension) { 827 const Extension* extension) {
825 const std::vector<InputComponentInfo>* input_components = 828 const std::vector<InputComponentInfo>* input_components =
826 extensions::InputComponents::GetInputComponents(extension); 829 extensions::InputComponents::GetInputComponents(extension);
827 if (input_components) 830 if (input_components)
828 input_ime_event_router()->RegisterImeExtension(extension->id(), 831 input_ime_event_router()->RegisterImeExtension(
829 *input_components); 832 Profile::FromBrowserContext(browser_context),
833 extension->id(),
834 *input_components);
830 } 835 }
831 836
832 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, 837 void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context,
833 const Extension* extension, 838 const Extension* extension,
834 UnloadedExtensionInfo::Reason reason) { 839 UnloadedExtensionInfo::Reason reason) {
835 const std::vector<InputComponentInfo>* input_components = 840 const std::vector<InputComponentInfo>* input_components =
836 extensions::InputComponents::GetInputComponents(extension); 841 extensions::InputComponents::GetInputComponents(extension);
837 if (!input_components) 842 if (!input_components)
838 return; 843 return;
839 if (input_components->size() > 0) 844 if (input_components->size() > 0)
840 input_ime_event_router()->UnregisterAllImes(extension->id()); 845 input_ime_event_router()->UnregisterAllImes(extension->id());
841 } 846 }
842 847
843 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) { 848 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) {
844 InputMethodEngineInterface* engine = 849 InputMethodEngineInterface* engine =
845 input_ime_event_router()->GetActiveEngine(details.extension_id); 850 input_ime_event_router()->GetActiveEngine(details.extension_id);
846 // Notifies the IME extension for IME ready with onActivate/onFocus events. 851 // Notifies the IME extension for IME ready with onActivate/onFocus events.
847 if (engine) 852 if (engine)
848 engine->Enable(engine->GetActiveComponentId()); 853 engine->Enable(engine->GetActiveComponentId());
849 } 854 }
850 855
851 InputImeEventRouter* InputImeAPI::input_ime_event_router() { 856 InputImeEventRouter* InputImeAPI::input_ime_event_router() {
852 return InputImeEventRouter::GetInstance(); 857 return InputImeEventRouter::GetInstance();
853 } 858 }
854 859
855 } // namespace extensions 860 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/input_ime/input_ime_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698