| 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/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 scoped_ptr<KeyEventHandled::Params> params( | 773 scoped_ptr<KeyEventHandled::Params> params( |
| 774 KeyEventHandled::Params::Create(*args_)); | 774 KeyEventHandled::Params::Create(*args_)); |
| 775 InputImeEventRouter::GetInstance()->OnKeyEventHandled( | 775 InputImeEventRouter::GetInstance()->OnKeyEventHandled( |
| 776 extension_id(), params->request_id, params->response); | 776 extension_id(), params->request_id, params->response); |
| 777 return true; | 777 return true; |
| 778 } | 778 } |
| 779 | 779 |
| 780 InputImeAPI::InputImeAPI(content::BrowserContext* context) | 780 InputImeAPI::InputImeAPI(content::BrowserContext* context) |
| 781 : profile_(Profile::FromBrowserContext(context)) { | 781 : profile_(Profile::FromBrowserContext(context)) { |
| 782 registrar_.Add(this, | 782 registrar_.Add(this, |
| 783 chrome::NOTIFICATION_EXTENSION_LOADED, | 783 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 784 content::Source<Profile>(profile_)); | 784 content::Source<Profile>(profile_)); |
| 785 registrar_.Add(this, | 785 registrar_.Add(this, |
| 786 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 786 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 787 content::Source<Profile>(profile_)); | 787 content::Source<Profile>(profile_)); |
| 788 | 788 |
| 789 EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router(); | 789 EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router(); |
| 790 event_router->RegisterObserver(this, input_ime::OnActivate::kEventName); | 790 event_router->RegisterObserver(this, input_ime::OnActivate::kEventName); |
| 791 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName); | 791 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName); |
| 792 } | 792 } |
| 793 | 793 |
| 794 InputImeAPI::~InputImeAPI() { | 794 InputImeAPI::~InputImeAPI() { |
| 795 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 795 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
| 796 } | 796 } |
| 797 | 797 |
| 798 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> > | 798 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> > |
| 799 g_factory = LAZY_INSTANCE_INITIALIZER; | 799 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 800 | 800 |
| 801 // static | 801 // static |
| 802 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { | 802 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { |
| 803 return g_factory.Pointer(); | 803 return g_factory.Pointer(); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void InputImeAPI::Observe(int type, | 806 void InputImeAPI::Observe(int type, |
| 807 const content::NotificationSource& source, | 807 const content::NotificationSource& source, |
| 808 const content::NotificationDetails& details) { | 808 const content::NotificationDetails& details) { |
| 809 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | 809 if (type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) { |
| 810 const Extension* extension = | 810 const Extension* extension = |
| 811 content::Details<const Extension>(details).ptr(); | 811 content::Details<const Extension>(details).ptr(); |
| 812 const std::vector<InputComponentInfo>* input_components = | 812 const std::vector<InputComponentInfo>* input_components = |
| 813 extensions::InputComponents::GetInputComponents(extension); | 813 extensions::InputComponents::GetInputComponents(extension); |
| 814 if (!input_components) | 814 if (!input_components) |
| 815 return; | 815 return; |
| 816 for (std::vector<extensions::InputComponentInfo>::const_iterator component = | 816 for (std::vector<extensions::InputComponentInfo>::const_iterator component = |
| 817 input_components->begin(); component != input_components->end(); | 817 input_components->begin(); component != input_components->end(); |
| 818 ++component) { | 818 ++component) { |
| 819 if (component->type == extensions::INPUT_COMPONENT_TYPE_IME) { | 819 if (component->type == extensions::INPUT_COMPONENT_TYPE_IME) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 844 input_ime_event_router()->GetActiveEngine(details.extension_id); | 844 input_ime_event_router()->GetActiveEngine(details.extension_id); |
| 845 if (engine) | 845 if (engine) |
| 846 engine->NotifyImeReady(); | 846 engine->NotifyImeReady(); |
| 847 } | 847 } |
| 848 | 848 |
| 849 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 849 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
| 850 return InputImeEventRouter::GetInstance(); | 850 return InputImeEventRouter::GetInstance(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 } // namespace extensions | 853 } // namespace extensions |
| OLD | NEW |