blob: f814ce12790a9ad5c7dce285d76be7de0e97698a [file] [log] [blame]
[email protected]32c3c752012-01-05 17:33:471// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]9ce7cb42011-12-07 18:53:072// 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_UI_PREFS_PREFS_TAB_HELPER_H_
6#define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_
[email protected]9ce7cb42011-12-07 18:53:077
[email protected]2a7cac02013-09-26 19:20:188#include "base/callback_list.h"
[email protected]be36dcf2012-05-22 07:04:009#include "base/compiler_specific.h"
avi655876a2015-12-25 07:18:1510#include "base/macros.h"
[email protected]124593ce2013-08-20 01:42:2311#include "base/memory/weak_ptr.h"
wjmacleane530aa742014-10-14 21:43:3012#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
[email protected]71fde352011-12-29 03:29:5613#include "content/public/browser/notification_observer.h"
[email protected]9ce7cb42011-12-07 18:53:0714#include "content/public/browser/notification_registrar.h"
[email protected]46b3c982012-10-09 18:38:3015#include "content/public/browser/web_contents_user_data.h"
[email protected]9ce7cb42011-12-07 18:53:0716
[email protected]32c3c752012-01-05 17:33:4717class OverlayUserPrefStore;
[email protected]c753f142013-02-10 13:14:0418class PrefService;
[email protected]ea6ad01a2011-12-21 21:53:4919class Profile;
[email protected]9ce7cb42011-12-07 18:53:0720
[email protected]d0aa78d2012-03-26 07:55:0221namespace content {
22class WebContents;
23}
24
[email protected]443e9312013-05-06 06:17:3425namespace user_prefs {
26class PrefRegistrySyncable;
27}
28
[email protected]9ce7cb42011-12-07 18:53:0729// Per-tab class to handle user preferences.
[email protected]bbf1925a2012-10-03 16:39:2230class PrefsTabHelper : public content::NotificationObserver,
[email protected]46b3c982012-10-09 18:38:3031 public content::WebContentsUserData<PrefsTabHelper> {
[email protected]9ce7cb42011-12-07 18:53:0732 public:
dcheng5dd5ff62014-10-21 12:42:3833 ~PrefsTabHelper() override;
[email protected]9ce7cb42011-12-07 18:53:0734
[email protected]37ca3fe02013-07-05 15:32:4435 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
jamd9bb3b7802015-01-28 20:32:1636 static void GetServiceInstance();
[email protected]9ce7cb42011-12-07 18:53:0737
[email protected]9ce7cb42011-12-07 18:53:0738 protected:
39 // Update the RenderView's WebPreferences. Exposed as protected for testing.
40 virtual void UpdateWebPreferences();
41
[email protected]9ce7cb42011-12-07 18:53:0742 private:
[email protected]bbf1925a2012-10-03 16:39:2243 explicit PrefsTabHelper(content::WebContents* contents);
[email protected]46b3c982012-10-09 18:38:3044 friend class content::WebContentsUserData<PrefsTabHelper>;
jamd9bb3b7802015-01-28 20:32:1645 friend class PrefWatcher;
[email protected]bbf1925a2012-10-03 16:39:2246
[email protected]9ce7cb42011-12-07 18:53:0747 // content::NotificationObserver overrides:
dcheng5dd5ff62014-10-21 12:42:3848 void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) override;
[email protected]9ce7cb42011-12-07 18:53:0751
[email protected]3dfa7f3c2012-04-18 18:01:3252 // Update the WebContents's RendererPreferences.
[email protected]9ce7cb42011-12-07 18:53:0753 void UpdateRendererPreferences();
54
[email protected]9e797d22014-08-08 21:31:3055 void OnFontFamilyPrefChanged(const std::string& pref_name);
[email protected]be85e7d2012-10-31 08:34:2056 void OnWebPrefChanged(const std::string& pref_name);
[email protected]ea6ad01a2011-12-21 21:53:4957
[email protected]d0aa78d2012-03-26 07:55:0258 content::WebContents* web_contents_;
jamd9bb3b7802015-01-28 20:32:1659 Profile* profile_;
[email protected]9ce7cb42011-12-07 18:53:0760 content::NotificationRegistrar registrar_;
[email protected]2a7cac02013-09-26 19:20:1861 scoped_ptr<base::CallbackList<void(void)>::Subscription>
[email protected]64aaec552013-09-12 17:26:3862 style_sheet_subscription_;
tfarina135e1a42015-09-02 22:35:4763 scoped_ptr<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription>
wjmacleane530aa742014-10-14 21:43:3064 default_zoom_level_subscription_;
[email protected]07f0f2cf2013-10-09 03:43:1865 base::WeakPtrFactory<PrefsTabHelper> weak_ptr_factory_;
[email protected]9ce7cb42011-12-07 18:53:0766
67 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper);
68};
69
70#endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_