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

Side by Side Diff: chrome/browser/extensions/api/preference/preference_helpers.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: fix compile error for chromeos build. 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/preference/preference_helpers.h" 5 #include "chrome/browser/extensions/api/preference/preference_helpers.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/api/preference/preference_api.h" 10 #include "chrome/browser/extensions/api/preference/preference_api.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return kControlledByOtherExtensions; 82 return kControlledByOtherExtensions;
83 } 83 }
84 84
85 void DispatchEventToExtensions( 85 void DispatchEventToExtensions(
86 Profile* profile, 86 Profile* profile,
87 const std::string& event_name, 87 const std::string& event_name,
88 base::ListValue* args, 88 base::ListValue* args,
89 APIPermission::ID permission, 89 APIPermission::ID permission,
90 bool incognito, 90 bool incognito,
91 const std::string& browser_pref) { 91 const std::string& browser_pref) {
92 EventRouter* router = 92 EventRouter* router = EventRouter::Get(profile);
93 ExtensionSystem::Get(profile)->event_router();
94 if (!router || !router->HasEventListener(event_name)) 93 if (!router || !router->HasEventListener(event_name))
95 return; 94 return;
96 ExtensionService* extension_service = 95 ExtensionService* extension_service =
97 ExtensionSystem::Get(profile)->extension_service(); 96 ExtensionSystem::Get(profile)->extension_service();
98 const ExtensionSet* extensions = extension_service->extensions(); 97 const ExtensionSet* extensions = extension_service->extensions();
99 for (ExtensionSet::const_iterator it = extensions->begin(); 98 for (ExtensionSet::const_iterator it = extensions->begin();
100 it != extensions->end(); ++it) { 99 it != extensions->end(); ++it) {
101 std::string extension_id = (*it)->id(); 100 std::string extension_id = (*it)->id();
102 // TODO(bauerb): Only iterate over registered event listeners. 101 // TODO(bauerb): Only iterate over registered event listeners.
103 if (router->ExtensionHasEventListener(extension_id, event_name) && 102 if (router->ExtensionHasEventListener(extension_id, event_name) &&
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 scoped_ptr<base::ListValue> args_copy(args->DeepCopy()); 134 scoped_ptr<base::ListValue> args_copy(args->DeepCopy());
136 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass())); 135 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass()));
137 event->restrict_to_browser_context = restrict_to_profile; 136 event->restrict_to_browser_context = restrict_to_profile;
138 router->DispatchEventToExtension(extension_id, event.Pass()); 137 router->DispatchEventToExtension(extension_id, event.Pass());
139 } 138 }
140 } 139 }
141 } 140 }
142 141
143 } // namespace preference_helpers 142 } // namespace preference_helpers
144 } // namespace extensions 143 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/preference/preference_api.cc ('k') | chrome/browser/extensions/api/processes/processes_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698