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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ 6 #define CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/basictypes.h" 12 #include "chrome/browser/prefs/pref_member.h" 13 #include "content/common/notification_observer.h" 14 15 class Profile; 16 17 namespace prerender { 18 class PrerenderManager; 19 } 20 21 // Monitors network-related preferences for changes and applies them. 22 // The supplied PrefService must outlive this NetPrefObserver. 23 // Must be used only on the UI thread. 24 class NetPrefObserver : public NotificationObserver { 25 public: 26 // |prefs| must outlive this NetPrefObserver. A reference is 27 // held to |prerender_manager| if it is non-NULL. 28 NetPrefObserver(PrefService* prefs, 29 prerender::PrerenderManager* prerender_manager); 30 ~NetPrefObserver(); 31 32 // NotificationObserver 33 virtual void Observe(NotificationType type, 34 const NotificationSource& source, 35 const NotificationDetails& details); 36 37 static void RegisterPrefs(PrefService* prefs); 38 39 private: 40 // If |pref_name| is NULL, all monitored preferences will be applied. 41 void ApplySettings(const std::string* pref_name); 42 43 BooleanPrefMember network_prediction_enabled_; 44 BooleanPrefMember spdy_disabled_; 45 BooleanPrefMember http_throttling_enabled_; 46 scoped_refptr<prerender::PrerenderManager> prerender_manager_; 47 48 DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); 49 }; 50 51 #endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ 52 53