Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/net/net_pref_observer.h" | 5 #include "chrome/browser/net/net_pref_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "components/pref_registry/pref_registry_syncable.h" | 10 #include "components/pref_registry/pref_registry_syncable.h" |
| 11 #include "components/prefs/pref_service.h" | 11 #include "components/prefs/pref_service.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "net/http/http_stream_factory.h" | 13 #include "net/http/http_stream_factory.h" |
| 14 | 14 |
| 15 using content::BrowserThread; | 15 using content::BrowserThread; |
| 16 | 16 |
| 17 NetPrefObserver::NetPrefObserver(PrefService* prefs) { | 17 NetPrefObserver::NetPrefObserver(PrefService* prefs) { |
| 18 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 18 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 19 DCHECK(prefs); | 19 DCHECK(prefs); |
| 20 | |
| 21 base::Closure prefs_callback = base::Bind(&NetPrefObserver::ApplySettings, | |
| 22 base::Unretained(this)); | |
| 23 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, prefs_callback); | |
| 24 | |
| 25 ApplySettings(); | |
| 26 } | 20 } |
| 27 | 21 |
| 28 NetPrefObserver::~NetPrefObserver() { | 22 NetPrefObserver::~NetPrefObserver() { |
| 29 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 23 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 30 } | 24 } |
| 31 | 25 |
| 32 void NetPrefObserver::ApplySettings() { | |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 34 | |
| 35 if (spdy_disabled_.IsManaged()) | |
| 36 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_); | |
| 37 } | |
| 38 | |
| 39 // static | 26 // static |
| 40 void NetPrefObserver::RegisterProfilePrefs( | 27 void NetPrefObserver::RegisterProfilePrefs( |
| 41 user_prefs::PrefRegistrySyncable* registry) { | 28 user_prefs::PrefRegistrySyncable* registry) { |
| 42 registry->RegisterBooleanPref( | 29 registry->RegisterBooleanPref( |
| 43 prefs::kNetworkPredictionEnabled, | 30 prefs::kNetworkPredictionEnabled, |
| 44 true, | 31 true, |
| 45 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 32 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 46 registry->RegisterBooleanPref(prefs::kDisableSpdy, false); | 33 registry->RegisterBooleanPref(prefs::kDisableSpdy, false); |
|
mef
2016/07/13 18:26:32
is this still needed?
Bence
2016/07/15 20:35:33
I would love to remove this, but then some policy
| |
| 47 } | 34 } |
| OLD | NEW |