| 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/callback_list.h" | 8 #include "base/callback_list.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/prefs/pref_change_registrar.h" | |
| 12 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 11 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
| 13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 16 | 15 |
| 17 class OverlayUserPrefStore; | 16 class OverlayUserPrefStore; |
| 18 class PrefService; | 17 class PrefService; |
| 19 class Profile; | 18 class Profile; |
| 20 | 19 |
| 21 namespace content { | 20 namespace content { |
| 22 class WebContents; | 21 class WebContents; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace user_prefs { | 24 namespace user_prefs { |
| 26 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
| 27 } | 26 } |
| 28 | 27 |
| 29 // Per-tab class to handle user preferences. | 28 // Per-tab class to handle user preferences. |
| 30 class PrefsTabHelper : public content::NotificationObserver, | 29 class PrefsTabHelper : public content::NotificationObserver, |
| 31 public content::WebContentsUserData<PrefsTabHelper> { | 30 public content::WebContentsUserData<PrefsTabHelper> { |
| 32 public: | 31 public: |
| 33 ~PrefsTabHelper() override; | 32 ~PrefsTabHelper() override; |
| 34 | 33 |
| 35 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); | 34 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); |
| 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 36 static void GetServiceInstance(); |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 // Update the RenderView's WebPreferences. Exposed as protected for testing. | 39 // Update the RenderView's WebPreferences. Exposed as protected for testing. |
| 40 virtual void UpdateWebPreferences(); | 40 virtual void UpdateWebPreferences(); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 explicit PrefsTabHelper(content::WebContents* contents); | 43 explicit PrefsTabHelper(content::WebContents* contents); |
| 44 friend class content::WebContentsUserData<PrefsTabHelper>; | 44 friend class content::WebContentsUserData<PrefsTabHelper>; |
| 45 friend class PrefWatcher; |
| 45 | 46 |
| 46 // content::NotificationObserver overrides: | 47 // content::NotificationObserver overrides: |
| 47 void Observe(int type, | 48 void Observe(int type, |
| 48 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
| 49 const content::NotificationDetails& details) override; | 50 const content::NotificationDetails& details) override; |
| 50 | 51 |
| 51 // Update the WebContents's RendererPreferences. | 52 // Update the WebContents's RendererPreferences. |
| 52 void UpdateRendererPreferences(); | 53 void UpdateRendererPreferences(); |
| 53 | 54 |
| 54 Profile* GetProfile(); | |
| 55 | |
| 56 void OnFontFamilyPrefChanged(const std::string& pref_name); | 55 void OnFontFamilyPrefChanged(const std::string& pref_name); |
| 57 void OnWebPrefChanged(const std::string& pref_name); | 56 void OnWebPrefChanged(const std::string& pref_name); |
| 58 | 57 |
| 59 content::WebContents* web_contents_; | 58 content::WebContents* web_contents_; |
| 59 Profile* profile_; |
| 60 content::NotificationRegistrar registrar_; | 60 content::NotificationRegistrar registrar_; |
| 61 PrefChangeRegistrar pref_change_registrar_; | |
| 62 scoped_ptr<base::CallbackList<void(void)>::Subscription> | 61 scoped_ptr<base::CallbackList<void(void)>::Subscription> |
| 63 style_sheet_subscription_; | 62 style_sheet_subscription_; |
| 64 scoped_ptr<chrome::ChromeZoomLevelPrefs::DefaultZoomLevelSubscription> | 63 scoped_ptr<chrome::ChromeZoomLevelPrefs::DefaultZoomLevelSubscription> |
| 65 default_zoom_level_subscription_; | 64 default_zoom_level_subscription_; |
| 66 base::WeakPtrFactory<PrefsTabHelper> weak_ptr_factory_; | 65 base::WeakPtrFactory<PrefsTabHelper> weak_ptr_factory_; |
| 67 | 66 |
| 68 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | 67 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 70 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
| OLD | NEW |