[email protected] | 32c3c75 | 2012-01-05 17:33:47 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 2 | // 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] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 7 | |
[email protected] | 2a7cac0 | 2013-09-26 19:20:18 | [diff] [blame] | 8 | #include "base/callback_list.h" |
[email protected] | be36dcf | 2012-05-22 07:04:00 | [diff] [blame] | 9 | #include "base/compiler_specific.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 10 | #include "base/macros.h" |
[email protected] | 124593ce | 2013-08-20 01:42:23 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
Brett Wilson | 21cf626a | 2017-09-07 00:30:20 | [diff] [blame^] | 12 | #include "chrome/browser/font_pref_change_notifier.h" |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame] | 13 | #include "content/public/browser/notification_observer.h" |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 14 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 15 | #include "content/public/browser/web_contents_user_data.h" |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 16 | |
mcnee | 336ea2c | 2017-05-23 22:50:59 | [diff] [blame] | 17 | #if !defined(OS_ANDROID) |
18 | #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | ||||
19 | #endif | ||||
20 | |||||
[email protected] | ea6ad01a | 2011-12-21 21:53:49 | [diff] [blame] | 21 | class Profile; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 22 | |
[email protected] | d0aa78d | 2012-03-26 07:55:02 | [diff] [blame] | 23 | namespace content { |
24 | class WebContents; | ||||
25 | } | ||||
26 | |||||
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 27 | namespace user_prefs { |
28 | class PrefRegistrySyncable; | ||||
29 | } | ||||
30 | |||||
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 31 | // Per-tab class to handle user preferences. |
[email protected] | bbf1925a | 2012-10-03 16:39:22 | [diff] [blame] | 32 | class PrefsTabHelper : public content::NotificationObserver, |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 33 | public content::WebContentsUserData<PrefsTabHelper> { |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 34 | public: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 35 | ~PrefsTabHelper() override; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 36 | |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 37 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
jam | d9bb3b780 | 2015-01-28 20:32:16 | [diff] [blame] | 38 | static void GetServiceInstance(); |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 39 | |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 40 | protected: |
41 | // Update the RenderView's WebPreferences. Exposed as protected for testing. | ||||
42 | virtual void UpdateWebPreferences(); | ||||
43 | |||||
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 44 | private: |
[email protected] | bbf1925a | 2012-10-03 16:39:22 | [diff] [blame] | 45 | explicit PrefsTabHelper(content::WebContents* contents); |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 46 | friend class content::WebContentsUserData<PrefsTabHelper>; |
jam | d9bb3b780 | 2015-01-28 20:32:16 | [diff] [blame] | 47 | friend class PrefWatcher; |
[email protected] | bbf1925a | 2012-10-03 16:39:22 | [diff] [blame] | 48 | |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 49 | // content::NotificationObserver overrides: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 50 | void Observe(int type, |
51 | const content::NotificationSource& source, | ||||
52 | const content::NotificationDetails& details) override; | ||||
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 53 | |
[email protected] | 3dfa7f3c | 2012-04-18 18:01:32 | [diff] [blame] | 54 | // Update the WebContents's RendererPreferences. |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 55 | void UpdateRendererPreferences(); |
56 | |||||
[email protected] | 9e797d2 | 2014-08-08 21:31:30 | [diff] [blame] | 57 | void OnFontFamilyPrefChanged(const std::string& pref_name); |
[email protected] | be85e7d | 2012-10-31 08:34:20 | [diff] [blame] | 58 | void OnWebPrefChanged(const std::string& pref_name); |
[email protected] | ea6ad01a | 2011-12-21 21:53:49 | [diff] [blame] | 59 | |
kulshin | 2510d5d | 2016-10-10 21:04:32 | [diff] [blame] | 60 | void NotifyWebkitPreferencesChanged(const std::string& pref_name); |
61 | |||||
[email protected] | d0aa78d | 2012-03-26 07:55:02 | [diff] [blame] | 62 | content::WebContents* web_contents_; |
jam | d9bb3b780 | 2015-01-28 20:32:16 | [diff] [blame] | 63 | Profile* profile_; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 64 | content::NotificationRegistrar registrar_; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 65 | std::unique_ptr<base::CallbackList<void(void)>::Subscription> |
[email protected] | 64aaec55 | 2013-09-12 17:26:38 | [diff] [blame] | 66 | style_sheet_subscription_; |
mcnee | 336ea2c | 2017-05-23 22:50:59 | [diff] [blame] | 67 | #if !defined(OS_ANDROID) |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 68 | std::unique_ptr<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription> |
wjmaclean | e530aa74 | 2014-10-14 21:43:30 | [diff] [blame] | 69 | default_zoom_level_subscription_; |
Brett Wilson | 21cf626a | 2017-09-07 00:30:20 | [diff] [blame^] | 70 | FontPrefChangeNotifier::Registrar font_change_registrar_; |
mcnee | 336ea2c | 2017-05-23 22:50:59 | [diff] [blame] | 71 | #endif // !defined(OS_ANDROID) |
[email protected] | 07f0f2cf | 2013-10-09 03:43:18 | [diff] [blame] | 72 | base::WeakPtrFactory<PrefsTabHelper> weak_ptr_factory_; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 73 | |
74 | DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | ||||
75 | }; | ||||
76 | |||||
77 | #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |