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 "base/prefs/pref_change_registrar.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 virtual ~PrefsTabHelper();
34 static void InitIncognitoUserPrefStore(OverlayUserPrefStore
* pref_store
);
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
38 // Update the RenderView's WebPreferences. Exposed as protected for testing.
39 virtual void UpdateWebPreferences();
42 explicit PrefsTabHelper(content::WebContents
* contents
);
43 friend class content::WebContentsUserData
<PrefsTabHelper
>;
45 // content::NotificationObserver overrides:
46 virtual void Observe(int type
,
47 const content::NotificationSource
& source
,
48 const content::NotificationDetails
& details
) OVERRIDE
;
50 // Update the WebContents's RendererPreferences.
51 void UpdateRendererPreferences();
53 Profile
* GetProfile();
54 void OnWebPrefChanged(const std::string
& pref_name
);
56 content::WebContents
* web_contents_
;
57 content::NotificationRegistrar registrar_
;
58 PrefChangeRegistrar pref_change_registrar_
;
59 scoped_ptr
<base::CallbackList
<void(void)>::Subscription
>
60 style_sheet_subscription_
;
61 base::WeakPtrFactory
<PrefsTabHelper
> weak_ptr_factory_
;
63 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper
);
66 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_