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 #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_
8 #include "base/callback_list.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/web_contents_user_data.h"
16 class OverlayUserPrefStore
;
24 namespace user_prefs
{
25 class PrefRegistrySyncable
;
28 // Per-tab class to handle user preferences.
29 class PrefsTabHelper
: public content::NotificationObserver
,
30 public content::WebContentsUserData
<PrefsTabHelper
> {
32 ~PrefsTabHelper() override
;
34 static void InitIncognitoUserPrefStore(OverlayUserPrefStore
* pref_store
);
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
36 static void GetServiceInstance();
39 // Update the RenderView's WebPreferences. Exposed as protected for testing.
40 virtual void UpdateWebPreferences();
43 explicit PrefsTabHelper(content::WebContents
* contents
);
44 friend class content::WebContentsUserData
<PrefsTabHelper
>;
45 friend class PrefWatcher
;
47 // content::NotificationObserver overrides:
48 void Observe(int type
,
49 const content::NotificationSource
& source
,
50 const content::NotificationDetails
& details
) override
;
52 // Update the WebContents's RendererPreferences.
53 void UpdateRendererPreferences();
55 void OnFontFamilyPrefChanged(const std::string
& pref_name
);
56 void OnWebPrefChanged(const std::string
& pref_name
);
58 content::WebContents
* web_contents_
;
60 content::NotificationRegistrar registrar_
;
61 scoped_ptr
<base::CallbackList
<void(void)>::Subscription
>
62 style_sheet_subscription_
;
63 scoped_ptr
<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription
>
64 default_zoom_level_subscription_
;
65 base::WeakPtrFactory
<PrefsTabHelper
> weak_ptr_factory_
;
67 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper
);
70 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_