Chromium Code Reviews| 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/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/session/user_session_manager.h" |
| 12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/common/extensions/api/input_ime.h" | 16 #include "chrome/common/extensions/api/input_ime.h" |
| 17 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" | 17 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 #include "extensions/browser/extension_function_registry.h" | 19 #include "extensions/browser/extension_function_registry.h" |
| 20 #include "extensions/browser/extension_registry.h" | 20 #include "extensions/browser/extension_registry.h" |
| 21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/browser/process_manager.h" | |
| 22 #include "extensions/common/manifest_handlers/background_info.h" | 23 #include "extensions/common/manifest_handlers/background_info.h" |
| 23 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" | 24 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" |
| 24 #include "ui/base/ime/chromeos/extension_ime_util.h" | 25 #include "ui/base/ime/chromeos/extension_ime_util.h" |
| 25 #include "ui/base/ime/chromeos/input_method_manager.h" | 26 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 26 | 27 |
| 27 namespace input_ime = extensions::api::input_ime; | 28 namespace input_ime = extensions::api::input_ime; |
| 28 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; | 29 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; |
| 29 namespace DeleteSurroundingText = | 30 namespace DeleteSurroundingText = |
| 30 extensions::api::input_ime::DeleteSurroundingText; | 31 extensions::api::input_ime::DeleteSurroundingText; |
| 31 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; | 32 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 75 |
| 75 if (input.enabled) | 76 if (input.enabled) |
| 76 out->modified |= InputMethodEngineInterface::MENU_ITEM_MODIFIED_ENABLED; | 77 out->modified |= InputMethodEngineInterface::MENU_ITEM_MODIFIED_ENABLED; |
| 77 out->enabled = input.enabled ? *input.enabled : true; | 78 out->enabled = input.enabled ? *input.enabled : true; |
| 78 } | 79 } |
| 79 | 80 |
| 80 static void DispatchEventToExtension(const std::string& extension_id, | 81 static void DispatchEventToExtension(const std::string& extension_id, |
| 81 const std::string& event_name, | 82 const std::string& event_name, |
| 82 scoped_ptr<base::ListValue> args) { | 83 scoped_ptr<base::ListValue> args) { |
| 83 Profile* profile = ProfileManager::GetActiveUserProfile(); | 84 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 85 if (event_name != input_ime::OnActivate::kEventName) { | |
| 86 // For suspended IME extension (e.g. XKB extension), don't awake it by IME | |
|
Seigo Nonaka
2015/01/29 09:11:29
I'm sorry but "suspended IME" and its example is n
Shu Chen
2015/01/30 14:38:29
"suspend" means the extension background is killed
Seigo Nonaka
2015/02/02 00:56:38
Oh, I didn't know extension background page can be
| |
| 87 // events except onActivate. The IME extension should be awake by other | |
| 88 // events (e.g. runtime.onMessage) from its other pages. | |
| 89 // This is to save memory for steady state Chrome OS on which the users | |
| 90 // don't want any IME features. | |
| 91 extensions::ExtensionSystem* extension_system = | |
| 92 extensions::ExtensionSystem::Get(profile); | |
| 93 if (extension_system) { | |
| 94 const extensions::Extension* extension = | |
| 95 extension_system->extension_service()->GetExtensionById( | |
| 96 extension_id, false /* include_disabled */); | |
| 97 extensions::ProcessManager* process_manager = | |
| 98 extensions::ProcessManager::Get(profile); | |
| 99 if (extensions::BackgroundInfo::HasBackgroundPage(extension) && | |
| 100 !process_manager->GetBackgroundHostForExtension(extension_id)) { | |
| 101 return; | |
| 102 } | |
| 103 } | |
| 104 } | |
| 105 | |
| 84 scoped_ptr<extensions::Event> event(new extensions::Event( | 106 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 85 event_name, args.Pass())); | 107 event_name, args.Pass())); |
| 86 event->restrict_to_browser_context = profile; | 108 event->restrict_to_browser_context = profile; |
| 87 extensions::EventRouter::Get(profile) | 109 extensions::EventRouter::Get(profile) |
| 88 ->DispatchEventToExtension(extension_id, event.Pass()); | 110 ->DispatchEventToExtension(extension_id, event.Pass()); |
| 89 } | 111 } |
| 90 | 112 |
| 91 void CallbackKeyEventHandle(chromeos::input_method::KeyEventHandle* key_data, | 113 void CallbackKeyEventHandle(chromeos::input_method::KeyEventHandle* key_data, |
| 92 bool handled) { | 114 bool handled) { |
| 93 base::Callback<void(bool consumed)>* callback = | 115 base::Callback<void(bool consumed)>* callback = |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 926 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
| 905 if (engine) | 927 if (engine) |
| 906 engine->Enable(engine->GetActiveComponentId()); | 928 engine->Enable(engine->GetActiveComponentId()); |
| 907 } | 929 } |
| 908 | 930 |
| 909 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 931 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
| 910 return InputImeEventRouter::GetInstance(); | 932 return InputImeEventRouter::GetInstance(); |
| 911 } | 933 } |
| 912 | 934 |
| 913 } // namespace extensions | 935 } // namespace extensions |
| OLD | NEW |