[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / net / net_pref_observer.cc
blobd731020c6dc1e690d9f0c6380a16ec926cdf86e6
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
3 // found in the LICENSE file.
5 #include "chrome/browser/net/net_pref_observer.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/net/predictor.h"
10 #include "chrome/browser/prerender/prerender_manager.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/user_prefs/pref_registry_syncable.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "net/http/http_stream_factory.h"
16 using content::BrowserThread;
18 NetPrefObserver::NetPrefObserver(PrefService* prefs,
19 prerender::PrerenderManager* prerender_manager,
20 chrome_browser_net::Predictor* predictor)
21 : prerender_manager_(prerender_manager),
22 predictor_(predictor) {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
24 DCHECK(prefs);
25 DCHECK(predictor);
27 base::Closure prefs_callback = base::Bind(&NetPrefObserver::ApplySettings,
28 base::Unretained(this));
29 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, prefs,
30 prefs_callback);
31 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, prefs_callback);
33 ApplySettings();
36 NetPrefObserver::~NetPrefObserver() {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 void NetPrefObserver::ApplySettings() {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
43 predictor_->EnablePredictor(*network_prediction_enabled_);
44 if (prerender_manager_)
45 prerender_manager_->set_enabled(*network_prediction_enabled_);
46 if (spdy_disabled_.IsManaged())
47 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_);
50 // static
51 void NetPrefObserver::RegisterProfilePrefs(
52 user_prefs::PrefRegistrySyncable* registry) {
53 registry->RegisterBooleanPref(
54 prefs::kNetworkPredictionEnabled,
55 true,
56 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
57 registry->RegisterBooleanPref(
58 prefs::kDisableSpdy,
59 false,
60 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);