| 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 #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/prefs/public/pref_change_registrar.h" | 9 #include "base/prefs/public/pref_change_registrar.h" |
| 10 #include "base/prefs/public/pref_observer.h" | |
| 11 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
| 14 | 13 |
| 15 class OverlayUserPrefStore; | 14 class OverlayUserPrefStore; |
| 16 class PrefService; | 15 class PrefService; |
| 17 class Profile; | 16 class Profile; |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 class WebContents; | 19 class WebContents; |
| 21 } | 20 } |
| 22 | 21 |
| 23 // Per-tab class to handle user preferences. | 22 // Per-tab class to handle user preferences. |
| 24 class PrefsTabHelper : public content::NotificationObserver, | 23 class PrefsTabHelper : public content::NotificationObserver, |
| 25 public PrefObserver, | |
| 26 public content::WebContentsUserData<PrefsTabHelper> { | 24 public content::WebContentsUserData<PrefsTabHelper> { |
| 27 public: | 25 public: |
| 28 virtual ~PrefsTabHelper(); | 26 virtual ~PrefsTabHelper(); |
| 29 | 27 |
| 30 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); | 28 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); |
| 31 static void RegisterUserPrefs(PrefService* prefs); | 29 static void RegisterUserPrefs(PrefService* prefs); |
| 32 | 30 |
| 33 protected: | 31 protected: |
| 34 // Update the RenderView's WebPreferences. Exposed as protected for testing. | 32 // Update the RenderView's WebPreferences. Exposed as protected for testing. |
| 35 virtual void UpdateWebPreferences(); | 33 virtual void UpdateWebPreferences(); |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 explicit PrefsTabHelper(content::WebContents* contents); | 36 explicit PrefsTabHelper(content::WebContents* contents); |
| 39 friend class content::WebContentsUserData<PrefsTabHelper>; | 37 friend class content::WebContentsUserData<PrefsTabHelper>; |
| 40 | 38 |
| 41 // content::NotificationObserver overrides: | 39 // content::NotificationObserver overrides: |
| 42 virtual void Observe(int type, | 40 virtual void Observe(int type, |
| 43 const content::NotificationSource& source, | 41 const content::NotificationSource& source, |
| 44 const content::NotificationDetails& details) OVERRIDE; | 42 const content::NotificationDetails& details) OVERRIDE; |
| 45 | 43 |
| 46 // PrefObserver overrides: | 44 void OnPreferenceChanged(const std::string& pref_name); |
| 47 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
| 48 const std::string& pref_name) OVERRIDE; | |
| 49 | 45 |
| 50 // Update the WebContents's RendererPreferences. | 46 // Update the WebContents's RendererPreferences. |
| 51 void UpdateRendererPreferences(); | 47 void UpdateRendererPreferences(); |
| 52 | 48 |
| 53 Profile* GetProfile(); | 49 Profile* GetProfile(); |
| 54 void OnWebPrefChanged(const std::string& pref_name); | 50 void OnWebPrefChanged(const std::string& pref_name); |
| 55 | 51 |
| 56 content::WebContents* web_contents_; | 52 content::WebContents* web_contents_; |
| 57 content::NotificationRegistrar registrar_; | 53 content::NotificationRegistrar registrar_; |
| 58 PrefChangeRegistrar pref_change_registrar_; | 54 PrefChangeRegistrar pref_change_registrar_; |
| 59 | 55 |
| 60 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | 56 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); |
| 61 }; | 57 }; |
| 62 | 58 |
| 63 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 59 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
| OLD | NEW |