OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_input_ime_api.h" | 5 #include "chrome/browser/extensions/extension_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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
11 #include "chrome/browser/extensions/extension_event_router.h" | 12 #include "chrome/browser/extensions/extension_event_router.h" |
12 #include "chrome/browser/extensions/extension_input_module_constants.h" | 13 #include "chrome/browser/extensions/extension_input_module_constants.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 | 15 |
15 namespace keys = extension_input_module_constants; | 16 namespace keys = extension_input_module_constants; |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 417 |
417 engine_map[component.id] = engine; | 418 engine_map[component.id] = engine; |
418 | 419 |
419 std::map<std::string, chromeos::ImeObserver*>& observer_list = | 420 std::map<std::string, chromeos::ImeObserver*>& observer_list = |
420 observers_[extension_id]; | 421 observers_[extension_id]; |
421 | 422 |
422 observer_list[component.id] = observer; | 423 observer_list[component.id] = observer; |
423 | 424 |
424 return true; | 425 return true; |
425 } | 426 } |
| 427 |
| 428 void ExtensionInputImeEventRouter::UnregisterAllImes( |
| 429 Profile* profile, const std::string& extension_id) { |
| 430 std::map<std::string, |
| 431 std::map<std::string, |
| 432 chromeos::InputMethodEngine*> >::iterator engine_map = |
| 433 engines_.find(extension_id); |
| 434 if (engine_map != engines_.end()) { |
| 435 STLDeleteContainerPairSecondPointers(engine_map->second.begin(), |
| 436 engine_map->second.end()); |
| 437 engines_.erase(engine_map); |
| 438 } |
| 439 |
| 440 std::map<std::string, |
| 441 std::map<std::string, |
| 442 chromeos::ImeObserver*> >::iterator observer_list = |
| 443 observers_.find(extension_id); |
| 444 if (observer_list != observers_.end()) { |
| 445 STLDeleteContainerPairSecondPointers(observer_list->second.begin(), |
| 446 observer_list->second.end()); |
| 447 observers_.erase(observer_list); |
| 448 } |
| 449 } |
426 #endif | 450 #endif |
427 | 451 |
428 chromeos::InputMethodEngine* ExtensionInputImeEventRouter::GetEngine( | 452 chromeos::InputMethodEngine* ExtensionInputImeEventRouter::GetEngine( |
429 const std::string& extension_id, const std::string& engine_id) { | 453 const std::string& extension_id, const std::string& engine_id) { |
430 std::map<std::string, | 454 std::map<std::string, |
431 std::map<std::string, chromeos::InputMethodEngine*> >::const_iterator | 455 std::map<std::string, chromeos::InputMethodEngine*> >::const_iterator |
432 engine_list = engines_.find(extension_id); | 456 engine_list = engines_.find(extension_id); |
433 if (engine_list != engines_.end()) { | 457 if (engine_list != engines_.end()) { |
434 std::map<std::string, chromeos::InputMethodEngine*>::const_iterator | 458 std::map<std::string, chromeos::InputMethodEngine*>::const_iterator |
435 engine_ix = engine_list->second.find(engine_id); | 459 engine_ix = engine_list->second.find(engine_id); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 876 |
853 bool handled = false; | 877 bool handled = false; |
854 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); | 878 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); |
855 | 879 |
856 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled( | 880 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled( |
857 extension_id(), request_id_str, handled); | 881 extension_id(), request_id_str, handled); |
858 | 882 |
859 return true; | 883 return true; |
860 } | 884 } |
861 #endif | 885 #endif |
OLD | NEW |