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

Side by Side Diff: chrome/browser/net/pref_proxy_config_tracker_impl.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/pref_proxy_config_tracker_impl.h" 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prefs/proxy_config_dictionary.h" 10 #include "chrome/browser/prefs/proxy_config_dictionary.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return true; 280 return true;
281 } 281 }
282 case ProxyPrefs::kModeCount: { 282 case ProxyPrefs::kModeCount: {
283 // Fall through to NOTREACHED(). 283 // Fall through to NOTREACHED().
284 } 284 }
285 } 285 }
286 NOTREACHED() << "Unknown proxy mode, falling back to system settings."; 286 NOTREACHED() << "Unknown proxy mode, falling back to system settings.";
287 return false; 287 return false;
288 } 288 }
289 289
290 void PrefProxyConfigTrackerImpl::Observe( 290 void PrefProxyConfigTrackerImpl::OnPreferenceChanged(
291 int type, 291 PrefServiceBase* service,
292 const content::NotificationSource& source, 292 const std::string& pref_name) {
293 const content::NotificationDetails& details) {
294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
295 if (type == chrome::NOTIFICATION_PREF_CHANGED && 294 if (service == pref_service_) {
296 content::Source<PrefService>(source).ptr() == pref_service_) {
297 net::ProxyConfig new_config; 295 net::ProxyConfig new_config;
298 ProxyPrefs::ConfigState config_state = ReadPrefConfig(&new_config); 296 ProxyPrefs::ConfigState config_state = ReadPrefConfig(&new_config);
299 if (config_state_ != config_state || 297 if (config_state_ != config_state ||
300 (config_state_ != ProxyPrefs::CONFIG_UNSET && 298 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
301 !pref_config_.Equals(new_config))) { 299 !pref_config_.Equals(new_config))) {
302 config_state_ = config_state; 300 config_state_ = config_state;
303 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 301 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
304 pref_config_ = new_config; 302 pref_config_ = new_config;
305 update_pending_ = true; 303 update_pending_ = true;
306 } 304 }
307 if (update_pending_) 305 if (update_pending_)
308 OnProxyConfigChanged(config_state, new_config); 306 OnProxyConfigChanged(config_state, new_config);
309 } else { 307 } else {
310 NOTREACHED() << "Unexpected notification of type " << type; 308 NOTREACHED() << "Unexpected PrefService.";
311 } 309 }
312 } 310 }
313 311
314 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig( 312 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
315 net::ProxyConfig* config) { 313 net::ProxyConfig* config) {
316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
317 315
318 // Clear the configuration and source. 316 // Clear the configuration and source.
319 *config = net::ProxyConfig(); 317 *config = net::ProxyConfig();
320 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET; 318 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET;
(...skipping 14 matching lines...) Expand all
335 config_state = ProxyPrefs::CONFIG_EXTENSION; 333 config_state = ProxyPrefs::CONFIG_EXTENSION;
336 else 334 else
337 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE; 335 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE;
338 } else { 336 } else {
339 config_state = ProxyPrefs::CONFIG_FALLBACK; 337 config_state = ProxyPrefs::CONFIG_FALLBACK;
340 } 338 }
341 } 339 }
342 340
343 return config_state; 341 return config_state;
344 } 342 }
OLDNEW
« no previous file with comments | « chrome/browser/net/pref_proxy_config_tracker_impl.h ('k') | chrome/browser/net/ssl_config_service_manager_pref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698