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

Side by Side Diff: chrome/browser/extensions/api/settings_private/settings_private_event_router.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings_private/settings_private_event_ router.h" 5 #include "chrome/browser/extensions/api/settings_private/settings_private_event_ router.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 EventRouter* event_router = EventRouter::Get(context_); 87 EventRouter* event_router = EventRouter::Get(context_);
88 bool should_listen = event_router->HasEventListener( 88 bool should_listen = event_router->HasEventListener(
89 api::settings_private::OnPrefsChanged::kEventName); 89 api::settings_private::OnPrefsChanged::kEventName);
90 90
91 if (should_listen && !listening_) { 91 if (should_listen && !listening_) {
92 const PrefsUtil::TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys(); 92 const PrefsUtil::TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys();
93 for (const auto& it : keys) { 93 for (const auto& it : keys) {
94 std::string pref_name = it.first; 94 std::string pref_name = it.first;
95 if (prefs_util_->IsCrosSetting(pref_name)) { 95 if (prefs_util_->IsCrosSetting(pref_name)) {
96 #if defined(OS_CHROMEOS) 96 #if defined(OS_CHROMEOS)
97 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> observer = 97 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> observer =
98 chromeos::CrosSettings::Get()->AddSettingsObserver( 98 chromeos::CrosSettings::Get()->AddSettingsObserver(
99 pref_name.c_str(), 99 pref_name.c_str(),
100 base::Bind(&SettingsPrivateEventRouter::OnPreferenceChanged, 100 base::Bind(&SettingsPrivateEventRouter::OnPreferenceChanged,
101 base::Unretained(this), pref_name)); 101 base::Unretained(this), pref_name));
102 linked_ptr<chromeos::CrosSettings::ObserverSubscription> subscription( 102 linked_ptr<chromeos::CrosSettings::ObserverSubscription> subscription(
103 observer.release()); 103 observer.release());
104 cros_settings_subscription_map_.insert( 104 cros_settings_subscription_map_.insert(
105 make_pair(pref_name, subscription)); 105 make_pair(pref_name, subscription));
106 #endif 106 #endif
107 } else { 107 } else {
(...skipping 16 matching lines...) Expand all
124 } 124 }
125 125
126 void SettingsPrivateEventRouter::OnPreferenceChanged( 126 void SettingsPrivateEventRouter::OnPreferenceChanged(
127 const std::string& pref_name) { 127 const std::string& pref_name) {
128 EventRouter* event_router = EventRouter::Get(context_); 128 EventRouter* event_router = EventRouter::Get(context_);
129 if (!event_router->HasEventListener( 129 if (!event_router->HasEventListener(
130 api::settings_private::OnPrefsChanged::kEventName)) { 130 api::settings_private::OnPrefsChanged::kEventName)) {
131 return; 131 return;
132 } 132 }
133 133
134 scoped_ptr<api::settings_private::PrefObject> pref_object = 134 std::unique_ptr<api::settings_private::PrefObject> pref_object =
135 prefs_util_->GetPref(pref_name); 135 prefs_util_->GetPref(pref_name);
136 136
137 std::vector<api::settings_private::PrefObject> prefs; 137 std::vector<api::settings_private::PrefObject> prefs;
138 if (pref_object) 138 if (pref_object)
139 prefs.push_back(std::move(*pref_object)); 139 prefs.push_back(std::move(*pref_object));
140 140
141 scoped_ptr<base::ListValue> args( 141 std::unique_ptr<base::ListValue> args(
142 api::settings_private::OnPrefsChanged::Create(prefs)); 142 api::settings_private::OnPrefsChanged::Create(prefs));
143 143
144 scoped_ptr<Event> extension_event(new Event( 144 std::unique_ptr<Event> extension_event(new Event(
145 events::SETTINGS_PRIVATE_ON_PREFS_CHANGED, 145 events::SETTINGS_PRIVATE_ON_PREFS_CHANGED,
146 api::settings_private::OnPrefsChanged::kEventName, std::move(args))); 146 api::settings_private::OnPrefsChanged::kEventName, std::move(args)));
147 event_router->BroadcastEvent(std::move(extension_event)); 147 event_router->BroadcastEvent(std::move(extension_event));
148 } 148 }
149 149
150 SettingsPrivateEventRouter* SettingsPrivateEventRouter::Create( 150 SettingsPrivateEventRouter* SettingsPrivateEventRouter::Create(
151 content::BrowserContext* context) { 151 content::BrowserContext* context) {
152 return new SettingsPrivateEventRouter(context); 152 return new SettingsPrivateEventRouter(context);
153 } 153 }
154 154
155 } // namespace extensions 155 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698