| 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/login/lock/screen_locker.h" | 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 10 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 11 #include "chrome/browser/chromeos/login/users/user_manager.h" | 12 #include "chrome/browser/chromeos/login/users/user_manager.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" |
| 21 #include "extensions/browser/extension_function_registry.h" | 22 #include "extensions/browser/extension_function_registry.h" |
| 22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 23 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 24 #include "extensions/common/manifest_handlers/background_info.h" | 25 #include "extensions/common/manifest_handlers/background_info.h" |
| 25 | 26 |
| 26 #if defined(USE_X11) | |
| 27 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | |
| 28 #endif | |
| 29 | |
| 30 namespace input_ime = extensions::api::input_ime; | 27 namespace input_ime = extensions::api::input_ime; |
| 31 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; | 28 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; |
| 32 namespace DeleteSurroundingText = | 29 namespace DeleteSurroundingText = |
| 33 extensions::api::input_ime::DeleteSurroundingText; | 30 extensions::api::input_ime::DeleteSurroundingText; |
| 34 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; | 31 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; |
| 35 namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents; | 32 namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents; |
| 36 namespace HideInputView = extensions::api::input_ime::HideInputView; | 33 namespace HideInputView = extensions::api::input_ime::HideInputView; |
| 37 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems; | 34 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems; |
| 38 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition; | 35 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition; |
| 39 namespace SetCandidates = extensions::api::input_ime::SetCandidates; | 36 namespace SetCandidates = extensions::api::input_ime::SetCandidates; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 namespace extensions { | 335 namespace extensions { |
| 339 | 336 |
| 340 InputImeEventRouter* | 337 InputImeEventRouter* |
| 341 InputImeEventRouter::GetInstance() { | 338 InputImeEventRouter::GetInstance() { |
| 342 return Singleton<InputImeEventRouter>::get(); | 339 return Singleton<InputImeEventRouter>::get(); |
| 343 } | 340 } |
| 344 | 341 |
| 345 bool InputImeEventRouter::RegisterImeExtension( | 342 bool InputImeEventRouter::RegisterImeExtension( |
| 346 const std::string& extension_id, | 343 const std::string& extension_id, |
| 347 const std::vector<extensions::InputComponentInfo>& input_components) { | 344 const std::vector<extensions::InputComponentInfo>& input_components) { |
| 348 #if defined(USE_X11) | |
| 349 VLOG(1) << "RegisterImeExtension: " << extension_id; | 345 VLOG(1) << "RegisterImeExtension: " << extension_id; |
| 350 | 346 |
| 351 if (engine_map_[extension_id]) | 347 if (engine_map_[extension_id]) |
| 352 return false; | 348 return false; |
| 353 | 349 |
| 354 chromeos::input_method::InputMethodManager* manager = | 350 chromeos::input_method::InputMethodManager* manager = |
| 355 chromeos::input_method::InputMethodManager::Get(); | 351 chromeos::input_method::InputMethodManager::Get(); |
| 356 chromeos::ComponentExtensionIMEManager* comp_ext_ime_manager = | 352 chromeos::ComponentExtensionIMEManager* comp_ext_ime_manager = |
| 357 manager->GetComponentExtensionIMEManager(); | 353 manager->GetComponentExtensionIMEManager(); |
| 358 | 354 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 388 } | 384 } |
| 389 | 385 |
| 390 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer( | 386 scoped_ptr<chromeos::InputMethodEngineInterface::Observer> observer( |
| 391 new chromeos::ImeObserver(extension_id)); | 387 new chromeos::ImeObserver(extension_id)); |
| 392 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); | 388 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); |
| 393 engine->Initialize(observer.Pass(), extension_id.c_str()); | 389 engine->Initialize(observer.Pass(), extension_id.c_str()); |
| 394 engine_map_[extension_id] = engine; | 390 engine_map_[extension_id] = engine; |
| 395 manager->AddInputMethodExtension(extension_id, descriptors, engine); | 391 manager->AddInputMethodExtension(extension_id, descriptors, engine); |
| 396 | 392 |
| 397 return true; | 393 return true; |
| 398 #else | |
| 399 // TODO(spang): IME support under ozone. | |
| 400 NOTIMPLEMENTED(); | |
| 401 return false; | |
| 402 #endif | |
| 403 } | 394 } |
| 404 | 395 |
| 405 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) { | 396 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) { |
| 406 std::map<std::string, InputMethodEngineInterface*>::iterator it = | 397 std::map<std::string, InputMethodEngineInterface*>::iterator it = |
| 407 engine_map_.find(extension_id); | 398 engine_map_.find(extension_id); |
| 408 if (it != engine_map_.end()) { | 399 if (it != engine_map_.end()) { |
| 409 chromeos::input_method::InputMethodManager::Get() | 400 chromeos::input_method::InputMethodManager::Get() |
| 410 ->RemoveInputMethodExtension(extension_id); | 401 ->RemoveInputMethodExtension(extension_id); |
| 411 delete it->second; | 402 delete it->second; |
| 412 engine_map_.erase(it); | 403 engine_map_.erase(it); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 // Notifies the IME extension for IME ready with onActivate/onFocus events. | 844 // Notifies the IME extension for IME ready with onActivate/onFocus events. |
| 854 if (engine) | 845 if (engine) |
| 855 engine->Enable(engine->GetActiveComponentId()); | 846 engine->Enable(engine->GetActiveComponentId()); |
| 856 } | 847 } |
| 857 | 848 |
| 858 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 849 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
| 859 return InputImeEventRouter::GetInstance(); | 850 return InputImeEventRouter::GetInstance(); |
| 860 } | 851 } |
| 861 | 852 |
| 862 } // namespace extensions | 853 } // namespace extensions |
| OLD | NEW |