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/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 registry->RegisterFunction<SetCandidatesFunction>(); | 857 registry->RegisterFunction<SetCandidatesFunction>(); |
858 registry->RegisterFunction<SetCursorPositionFunction>(); | 858 registry->RegisterFunction<SetCursorPositionFunction>(); |
859 registry->RegisterFunction<SetMenuItemsFunction>(); | 859 registry->RegisterFunction<SetMenuItemsFunction>(); |
860 registry->RegisterFunction<UpdateMenuItemsFunction>(); | 860 registry->RegisterFunction<UpdateMenuItemsFunction>(); |
861 registry->RegisterFunction<KeyEventHandled>(); | 861 registry->RegisterFunction<KeyEventHandled>(); |
862 } | 862 } |
863 | 863 |
864 InputImeAPI::~InputImeAPI() { | 864 InputImeAPI::~InputImeAPI() { |
865 } | 865 } |
866 | 866 |
| 867 static base::LazyInstance<ProfileKeyedAPIFactory<InputImeAPI> > |
| 868 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 869 |
| 870 // static |
| 871 ProfileKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { |
| 872 return &g_factory.Get(); |
| 873 } |
| 874 |
867 void InputImeAPI::Observe(int type, | 875 void InputImeAPI::Observe(int type, |
868 const content::NotificationSource& source, | 876 const content::NotificationSource& source, |
869 const content::NotificationDetails& details) { | 877 const content::NotificationDetails& details) { |
870 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | 878 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { |
871 const Extension* extension = | 879 const Extension* extension = |
872 content::Details<const Extension>(details).ptr(); | 880 content::Details<const Extension>(details).ptr(); |
873 const std::vector<InputComponentInfo>* input_components = | 881 const std::vector<InputComponentInfo>* input_components = |
874 extensions::InputComponents::GetInputComponents(extension); | 882 extensions::InputComponents::GetInputComponents(extension); |
875 if (!input_components) | 883 if (!input_components) |
876 return; | 884 return; |
(...skipping 15 matching lines...) Expand all Loading... |
892 if (input_components->size() > 0) { | 900 if (input_components->size() > 0) { |
893 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); | 901 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); |
894 } | 902 } |
895 } | 903 } |
896 } | 904 } |
897 | 905 |
898 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 906 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
899 return InputImeEventRouter::GetInstance(); | 907 return InputImeEventRouter::GetInstance(); |
900 } | 908 } |
901 | 909 |
902 static base::LazyInstance<ProfileKeyedAPIFactory<InputImeAPI> > | |
903 g_factory = LAZY_INSTANCE_INITIALIZER; | |
904 | |
905 template <> | |
906 ProfileKeyedAPIFactory<InputImeAPI>* | |
907 ProfileKeyedAPIFactory<InputImeAPI>::GetInstance() { | |
908 return &g_factory.Get(); | |
909 } | |
910 | |
911 } // namespace extensions | 910 } // namespace extensions |
OLD | NEW |