| OLD | NEW |
| 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/pref_set_observer.h" | 10 #include "chrome/browser/prefs/pref_set_observer.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 pref_config_state_, pref_config_, | 63 pref_config_state_, pref_config_, |
| 64 system_availability, system_config, false, | 64 system_availability, system_config, false, |
| 65 &config_state, config); | 65 &config_state, config); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ChromeProxyConfigService::OnLazyPoll() { | 68 void ChromeProxyConfigService::OnLazyPoll() { |
| 69 if (base_service_.get()) | 69 if (base_service_.get()) |
| 70 base_service_->OnLazyPoll(); | 70 base_service_->OnLazyPoll(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ChromeProxyConfigService::StartTearDown() { |
| 74 if (base_service_.get()) |
| 75 base_service_->StartTearDown(); |
| 76 } |
| 77 |
| 73 void ChromeProxyConfigService::UpdateProxyConfig( | 78 void ChromeProxyConfigService::UpdateProxyConfig( |
| 74 ProxyPrefs::ConfigState config_state, | 79 ProxyPrefs::ConfigState config_state, |
| 75 const net::ProxyConfig& config) { | 80 const net::ProxyConfig& config) { |
| 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 77 | 82 |
| 78 pref_config_read_pending_ = false; | 83 pref_config_read_pending_ = false; |
| 79 pref_config_state_ = config_state; | 84 pref_config_state_ = config_state; |
| 80 pref_config_ = config; | 85 pref_config_ = config; |
| 81 | 86 |
| 82 if (!observers_.size()) | 87 if (!observers_.size()) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 102 const net::ProxyConfig& config, | 107 const net::ProxyConfig& config, |
| 103 ConfigAvailability availability) { | 108 ConfigAvailability availability) { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 105 | 110 |
| 106 // Check whether there is a proxy configuration defined by preferences. In | 111 // Check whether there is a proxy configuration defined by preferences. In |
| 107 // this case that proxy configuration takes precedence and the change event | 112 // this case that proxy configuration takes precedence and the change event |
| 108 // from the delegate proxy service can be disregarded. | 113 // from the delegate proxy service can be disregarded. |
| 109 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) { | 114 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) { |
| 110 net::ProxyConfig actual_config; | 115 net::ProxyConfig actual_config; |
| 111 availability = GetLatestProxyConfig(&actual_config); | 116 availability = GetLatestProxyConfig(&actual_config); |
| 112 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, | 117 // Don't send out notification if we don't really have a configuration yet. |
| 113 OnProxyConfigChanged(actual_config, availability)); | 118 if (availability != net::ProxyConfigService::CONFIG_PENDING) |
| 119 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, |
| 120 OnProxyConfigChanged(actual_config, availability)); |
| 114 } | 121 } |
| 115 } | 122 } |
| 116 | 123 |
| 117 void ChromeProxyConfigService::RegisterObserver() { | 124 void ChromeProxyConfigService::RegisterObserver() { |
| 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 119 if (!registered_observer_ && base_service_.get()) { | 126 if (!registered_observer_ && base_service_.get()) { |
| 120 base_service_->AddObserver(this); | 127 base_service_->AddObserver(this); |
| 121 registered_observer_ = true; | 128 registered_observer_ = true; |
| 122 } | 129 } |
| 123 } | 130 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 config_state = ProxyPrefs::CONFIG_EXTENSION; | 343 config_state = ProxyPrefs::CONFIG_EXTENSION; |
| 337 else | 344 else |
| 338 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE; | 345 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE; |
| 339 } else { | 346 } else { |
| 340 config_state = ProxyPrefs::CONFIG_FALLBACK; | 347 config_state = ProxyPrefs::CONFIG_FALLBACK; |
| 341 } | 348 } |
| 342 } | 349 } |
| 343 | 350 |
| 344 return config_state; | 351 return config_state; |
| 345 } | 352 } |
| OLD | NEW |