| 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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h" |
| 11 #include "chrome/browser/extensions/extension_function_registry.h" | 11 #include "chrome/browser/extensions/extension_function_registry.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/extensions/api/input_ime.h" | 14 #include "chrome/common/extensions/api/input_ime.h" |
| 15 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" | 15 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" |
| 16 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 | 19 |
| 20 namespace input_ime = extensions::api::input_ime; | 20 namespace input_ime = extensions::api::input_ime; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 VLOG(1) << "RegisterIme: " << extension_id << " id: " << component.id; | 289 VLOG(1) << "RegisterIme: " << extension_id << " id: " << component.id; |
| 290 | 290 |
| 291 std::map<std::string, chromeos::InputMethodEngine*>& engine_map = | 291 std::map<std::string, chromeos::InputMethodEngine*>& engine_map = |
| 292 engines_[extension_id]; | 292 engines_[extension_id]; |
| 293 | 293 |
| 294 std::map<std::string, chromeos::InputMethodEngine*>::iterator engine_ix = | 294 std::map<std::string, chromeos::InputMethodEngine*>::iterator engine_ix = |
| 295 engine_map.find(component.id); | 295 engine_map.find(component.id); |
| 296 if (engine_ix != engine_map.end()) | 296 if (engine_ix != engine_map.end()) |
| 297 return false; | 297 return false; |
| 298 | 298 |
| 299 std::string error; | |
| 300 chromeos::ImeObserver* observer = new chromeos::ImeObserver(profile, | 299 chromeos::ImeObserver* observer = new chromeos::ImeObserver(profile, |
| 301 extension_id, | 300 extension_id, |
| 302 component.id); | 301 component.id); |
| 303 std::vector<std::string> layouts; | 302 std::vector<std::string> layouts; |
| 304 layouts.assign(component.layouts.begin(), component.layouts.end()); | 303 layouts.assign(component.layouts.begin(), component.layouts.end()); |
| 305 | 304 |
| 306 std::vector<std::string> languages; | 305 std::vector<std::string> languages; |
| 307 languages.assign(component.languages.begin(), component.languages.end()); | 306 languages.assign(component.languages.begin(), component.languages.end()); |
| 308 | 307 |
| 309 chromeos::InputMethodEngine* engine = | 308 chromeos::InputMethodEngineIBus* engine = |
| 310 chromeos::InputMethodEngine::CreateEngine( | 309 new chromeos::InputMethodEngineIBus(); |
| 311 observer, component.name.c_str(), extension_id.c_str(), | 310 engine->Initialize(observer, component.name.c_str(), extension_id.c_str(), |
| 312 component.id.c_str(), component.description.c_str(), | 311 component.id.c_str(), languages, layouts, |
| 313 languages, layouts, component.options_page_url, | 312 component.options_page_url, component.input_view_url); |
| 314 component.input_view_url, &error); | |
| 315 if (!engine) { | |
| 316 delete observer; | |
| 317 LOG(ERROR) << "RegisterIme: " << error; | |
| 318 return false; | |
| 319 } | |
| 320 | |
| 321 engine_map[component.id] = engine; | 313 engine_map[component.id] = engine; |
| 322 | 314 |
| 323 std::map<std::string, chromeos::ImeObserver*>& observer_list = | 315 std::map<std::string, chromeos::ImeObserver*>& observer_list = |
| 324 observers_[extension_id]; | 316 observers_[extension_id]; |
| 325 | 317 |
| 326 observer_list[component.id] = observer; | 318 observer_list[component.id] = observer; |
| 327 | 319 |
| 328 return true; | 320 return true; |
| 329 } | 321 } |
| 330 | 322 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (input_components->size() > 0) | 756 if (input_components->size() > 0) |
| 765 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); | 757 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); |
| 766 } | 758 } |
| 767 } | 759 } |
| 768 | 760 |
| 769 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 761 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
| 770 return InputImeEventRouter::GetInstance(); | 762 return InputImeEventRouter::GetInstance(); |
| 771 } | 763 } |
| 772 | 764 |
| 773 } // namespace extensions | 765 } // namespace extensions |
| OLD | NEW |