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

Side by Side Diff: chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc

Issue 709813004: Remove the deprecated function ExtensionService::extensions(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed thestig@'s comments. Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chrome_direct_setting_api.h" 5 #include "chrome/browser/extensions/api/preference/chrome_direct_setting_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" 13 #include "chrome/browser/extensions/api/preference/preference_api_constants.h"
14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "extensions/browser/extension_system.h" 15 #include "extensions/browser/extension_registry.h"
17 16
18 namespace extensions { 17 namespace extensions {
19 namespace chromedirectsetting { 18 namespace chromedirectsetting {
20 19
21 const char kOnPrefChangeFormat[] = 20 const char kOnPrefChangeFormat[] =
22 "types.private.ChromeDirectSetting.%s.onChange"; 21 "types.private.ChromeDirectSetting.%s.onChange";
23 22
24 class PreferenceWhitelist { 23 class PreferenceWhitelist {
25 public: 24 public:
26 PreferenceWhitelist() { 25 PreferenceWhitelist() {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (router && router->HasEventListener(event_name)) { 129 if (router && router->HasEventListener(event_name)) {
131 const PrefService::Preference* preference = 130 const PrefService::Preference* preference =
132 profile_->GetPrefs()->FindPreference(pref_key.c_str()); 131 profile_->GetPrefs()->FindPreference(pref_key.c_str());
133 const base::Value* value = preference->GetValue(); 132 const base::Value* value = preference->GetValue();
134 133
135 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); 134 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
136 result->Set(preference_api_constants::kValue, value->DeepCopy()); 135 result->Set(preference_api_constants::kValue, value->DeepCopy());
137 base::ListValue args; 136 base::ListValue args;
138 args.Append(result.release()); 137 args.Append(result.release());
139 138
140 ExtensionService* extension_service = 139 for (const scoped_refptr<const extensions::Extension>& extension :
141 ExtensionSystem::Get(profile_)->extension_service(); 140 ExtensionRegistry::Get(profile_)->enabled_extensions()) {
142 const ExtensionSet* extensions = extension_service->extensions(); 141 const std::string& extension_id = extension->id();
143 for (ExtensionSet::const_iterator it = extensions->begin();
144 it != extensions->end(); ++it) {
145 const std::string& extension_id = (*it)->id();
146 if (router->ExtensionHasEventListener(extension_id, event_name)) { 142 if (router->ExtensionHasEventListener(extension_id, event_name)) {
147 scoped_ptr<base::ListValue> args_copy(args.DeepCopy()); 143 scoped_ptr<base::ListValue> args_copy(args.DeepCopy());
148 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass())); 144 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass()));
149 router->DispatchEventToExtension(extension_id, event.Pass()); 145 router->DispatchEventToExtension(extension_id, event.Pass());
150 } 146 }
151 } 147 }
152 } 148 }
153 } 149 }
154 150
155 } // namespace chromedirectsetting 151 } // namespace chromedirectsetting
156 } // namespace extensions 152 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698