Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api.cc

Issue 238633009: cleanup: Use EventRouter instead of ExtensionSystem::Get->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/extensions/api/input_ime.h" 12 #include "chrome/common/extensions/api/input_ime.h"
13 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" 13 #include "chrome/common/extensions/api/input_ime/input_components_handler.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "extensions/browser/event_router.h" 16 #include "extensions/browser/event_router.h"
17 #include "extensions/browser/extension_function_registry.h" 17 #include "extensions/browser/extension_function_registry.h"
18 #include "extensions/browser/extension_system.h"
19 18
20 #if defined(USE_X11) 19 #if defined(USE_X11)
21 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 20 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
22 #endif 21 #endif
23 22
24 namespace input_ime = extensions::api::input_ime; 23 namespace input_ime = extensions::api::input_ime;
25 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; 24 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled;
26 namespace DeleteSurroundingText = 25 namespace DeleteSurroundingText =
27 extensions::api::input_ime::DeleteSurroundingText; 26 extensions::api::input_ime::DeleteSurroundingText;
28 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; 27 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 out->enabled = input.enabled ? *input.enabled : true; 71 out->enabled = input.enabled ? *input.enabled : true;
73 } 72 }
74 73
75 static void DispatchEventToExtension(Profile* profile, 74 static void DispatchEventToExtension(Profile* profile,
76 const std::string& extension_id, 75 const std::string& extension_id,
77 const std::string& event_name, 76 const std::string& event_name,
78 scoped_ptr<base::ListValue> args) { 77 scoped_ptr<base::ListValue> args) {
79 scoped_ptr<extensions::Event> event(new extensions::Event( 78 scoped_ptr<extensions::Event> event(new extensions::Event(
80 event_name, args.Pass())); 79 event_name, args.Pass()));
81 event->restrict_to_browser_context = profile; 80 event->restrict_to_browser_context = profile;
82 extensions::ExtensionSystem::Get(profile)->event_router()-> 81 extensions::EventRouter::Get(profile)
83 DispatchEventToExtension(extension_id, event.Pass()); 82 ->DispatchEventToExtension(extension_id, event.Pass());
84 } 83 }
85 84
86 } // namespace 85 } // namespace
87 86
88 namespace chromeos { 87 namespace chromeos {
89 class ImeObserver : public InputMethodEngineInterface::Observer { 88 class ImeObserver : public InputMethodEngineInterface::Observer {
90 public: 89 public:
91 ImeObserver(Profile* profile, const std::string& extension_id) 90 ImeObserver(Profile* profile, const std::string& extension_id)
92 : profile_(profile), extension_id_(extension_id) {} 91 : profile_(profile), extension_id_(extension_id) {}
93 92
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 778
780 InputImeAPI::InputImeAPI(content::BrowserContext* context) 779 InputImeAPI::InputImeAPI(content::BrowserContext* context)
781 : profile_(Profile::FromBrowserContext(context)) { 780 : profile_(Profile::FromBrowserContext(context)) {
782 registrar_.Add(this, 781 registrar_.Add(this,
783 chrome::NOTIFICATION_EXTENSION_LOADED, 782 chrome::NOTIFICATION_EXTENSION_LOADED,
784 content::Source<Profile>(profile_)); 783 content::Source<Profile>(profile_));
785 registrar_.Add(this, 784 registrar_.Add(this,
786 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 785 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
787 content::Source<Profile>(profile_)); 786 content::Source<Profile>(profile_));
788 787
789 EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router(); 788 EventRouter* event_router = EventRouter::Get(profile_);
790 event_router->RegisterObserver(this, input_ime::OnActivate::kEventName); 789 event_router->RegisterObserver(this, input_ime::OnActivate::kEventName);
791 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName); 790 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName);
792 } 791 }
793 792
794 InputImeAPI::~InputImeAPI() { 793 InputImeAPI::~InputImeAPI() {
795 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 794 EventRouter::Get(profile_)->UnregisterObserver(this);
796 } 795 }
797 796
798 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> > 797 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> >
799 g_factory = LAZY_INSTANCE_INITIALIZER; 798 g_factory = LAZY_INSTANCE_INITIALIZER;
800 799
801 // static 800 // static
802 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { 801 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() {
803 return g_factory.Pointer(); 802 return g_factory.Pointer();
804 } 803 }
805 804
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 input_ime_event_router()->GetActiveEngine(details.extension_id); 843 input_ime_event_router()->GetActiveEngine(details.extension_id);
845 if (engine) 844 if (engine)
846 engine->NotifyImeReady(); 845 engine->NotifyImeReady();
847 } 846 }
848 847
849 InputImeEventRouter* InputImeAPI::input_ime_event_router() { 848 InputImeEventRouter* InputImeAPI::input_ime_event_router() {
850 return InputImeEventRouter::GetInstance(); 849 return InputImeEventRouter::GetInstance();
851 } 850 }
852 851
853 } // namespace extensions 852 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698