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

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

Issue 11618005: Pull InputIme stuff out of ExtensionService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fixed 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
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/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 } // namespace chromeos 309 } // namespace chromeos
310 310
311 namespace extensions { 311 namespace extensions {
312 312
313 InputImeEventRouter* 313 InputImeEventRouter*
314 InputImeEventRouter::GetInstance() { 314 InputImeEventRouter::GetInstance() {
315 return Singleton<InputImeEventRouter>::get(); 315 return Singleton<InputImeEventRouter>::get();
316 } 316 }
317 317
318 void InputImeEventRouter::Init() {}
319
320 #if defined(OS_CHROMEOS) 318 #if defined(OS_CHROMEOS)
321 bool InputImeEventRouter::RegisterIme( 319 bool InputImeEventRouter::RegisterIme(
322 Profile* profile, 320 Profile* profile,
323 const std::string& extension_id, 321 const std::string& extension_id,
324 const extensions::Extension::InputComponentInfo& component) { 322 const extensions::Extension::InputComponentInfo& component) {
325 VLOG(1) << "RegisterIme: " << extension_id << " id: " << component.id; 323 VLOG(1) << "RegisterIme: " << extension_id << " id: " << component.id;
326 324
327 std::map<std::string, chromeos::InputMethodEngine*>& engine_map = 325 std::map<std::string, chromeos::InputMethodEngine*>& engine_map =
328 engines_[extension_id]; 326 engines_[extension_id];
329 327
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 bool handled = false; 828 bool handled = false;
831 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); 829 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled));
832 830
833 InputImeEventRouter::GetInstance()->OnKeyEventHandled( 831 InputImeEventRouter::GetInstance()->OnKeyEventHandled(
834 extension_id(), request_id_str, handled); 832 extension_id(), request_id_str, handled);
835 833
836 return true; 834 return true;
837 } 835 }
838 #endif 836 #endif
839 837
838 InputImeAPI::InputImeAPI(Profile* profile)
839 : profile_(profile) {
840 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
841 content::Source<Profile>(profile));
842 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
843 content::Source<Profile>(profile));
844 }
845
846 InputImeAPI::~InputImeAPI() {
847 }
848
849 void InputImeAPI::Observe(int type,
850 const content::NotificationSource& source,
851 const content::NotificationDetails& details) {
852 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
853 const Extension* extension =
854 content::Details<const Extension>(details).ptr();
855 for (std::vector<Extension::InputComponentInfo>::const_iterator component =
856 extension->input_components().begin();
857 component != extension->input_components().end();
858 ++component) {
859 if (component->type == Extension::INPUT_COMPONENT_TYPE_IME) {
860 input_ime_event_router()->RegisterIme(
861 profile_, extension->id(), *component);
862 }
863 }
864 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
865 const Extension* extension =
866 content::Details<const UnloadedExtensionInfo>(details)->extension;
867 if (extension->input_components().size() > 0) {
868 input_ime_event_router()->UnregisterAllImes(profile_, extension->id());
869 }
870 }
871 }
872
873 InputImeEventRouter* InputImeAPI::input_ime_event_router() {
874 return InputImeEventRouter::GetInstance();
875 }
876
840 } // namespace extensions 877 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698