blob: 9bedc7cda1c9de0cbc560dc290ef60af39a6c3bb [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]be36dcf2012-05-22 07:04:008#include "base/compiler_specific.h"
avi655876a2015-12-25 07:18:159#include "base/macros.h"
[email protected]124593ce2013-08-20 01:42:2310#include "base/memory/weak_ptr.h"
Brett Wilson21cf626a2017-09-07 00:30:2011#include "chrome/browser/font_pref_change_notifier.h"
[email protected]71fde352011-12-29 03:29:5612#include "content/public/browser/notification_observer.h"
[email protected]9ce7cb42011-12-07 18:53:0713#include "content/public/browser/notification_registrar.h"
[email protected]46b3c982012-10-09 18:38:3014#include "content/public/browser/web_contents_user_data.h"
[email protected]9ce7cb42011-12-07 18:53:0715
mcnee336ea2c2017-05-23 22:50:5916#if !defined(OS_ANDROID)
17#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
18#endif
19
[email protected]ea6ad01a2011-12-21 21:53:4920class Profile;
[email protected]9ce7cb42011-12-07 18:53:0721
[email protected]d0aa78d2012-03-26 07:55:0222namespace content {
23class WebContents;
24}
25
[email protected]443e9312013-05-06 06:17:3426namespace user_prefs {
27class PrefRegistrySyncable;
28}
29
[email protected]9ce7cb42011-12-07 18:53:0730// Per-tab class to handle user preferences.
[email protected]bbf1925a2012-10-03 16:39:2231class PrefsTabHelper : public content::NotificationObserver,
[email protected]46b3c982012-10-09 18:38:3032 public content::WebContentsUserData<PrefsTabHelper> {
[email protected]9ce7cb42011-12-07 18:53:0733 public:
dcheng5dd5ff62014-10-21 12:42:3834 ~PrefsTabHelper() override;
[email protected]9ce7cb42011-12-07 18:53:0735
Xi Han25a7f032019-04-18 21:44:2136 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
37 const std::string& locale);
jamd9bb3b7802015-01-28 20:32:1638 static void GetServiceInstance();
[email protected]9ce7cb42011-12-07 18:53:0739
[email protected]9ce7cb42011-12-07 18:53:0740 protected:
41 // Update the RenderView's WebPreferences. Exposed as protected for testing.
42 virtual void UpdateWebPreferences();
43
[email protected]9ce7cb42011-12-07 18:53:0744 private:
[email protected]bbf1925a2012-10-03 16:39:2245 explicit PrefsTabHelper(content::WebContents* contents);
[email protected]46b3c982012-10-09 18:38:3046 friend class content::WebContentsUserData<PrefsTabHelper>;
jamd9bb3b7802015-01-28 20:32:1647 friend class PrefWatcher;
[email protected]bbf1925a2012-10-03 16:39:2248
[email protected]9ce7cb42011-12-07 18:53:0749 // content::NotificationObserver overrides:
dcheng5dd5ff62014-10-21 12:42:3850 void Observe(int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) override;
[email protected]9ce7cb42011-12-07 18:53:0753
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:2354 // Update the WebContents's blink::RendererPreferences.
[email protected]9ce7cb42011-12-07 18:53:0755 void UpdateRendererPreferences();
56
[email protected]9e797d22014-08-08 21:31:3057 void OnFontFamilyPrefChanged(const std::string& pref_name);
[email protected]be85e7d2012-10-31 08:34:2058 void OnWebPrefChanged(const std::string& pref_name);
[email protected]ea6ad01a2011-12-21 21:53:4959
kulshin2510d5d2016-10-10 21:04:3260 void NotifyWebkitPreferencesChanged(const std::string& pref_name);
61
[email protected]d0aa78d2012-03-26 07:55:0262 content::WebContents* web_contents_;
jamd9bb3b7802015-01-28 20:32:1663 Profile* profile_;
[email protected]9ce7cb42011-12-07 18:53:0764 content::NotificationRegistrar registrar_;
mcnee336ea2c2017-05-23 22:50:5965#if !defined(OS_ANDROID)
dcheng9603ab92016-04-08 04:17:3266 std::unique_ptr<ChromeZoomLevelPrefs::DefaultZoomLevelSubscription>
wjmacleane530aa742014-10-14 21:43:3067 default_zoom_level_subscription_;
Brett Wilson21cf626a2017-09-07 00:30:2068 FontPrefChangeNotifier::Registrar font_change_registrar_;
mcnee336ea2c2017-05-23 22:50:5969#endif // !defined(OS_ANDROID)
Jeremy Roman495db682019-07-12 16:03:2470 base::WeakPtrFactory<PrefsTabHelper> weak_ptr_factory_{this};
[email protected]9ce7cb42011-12-07 18:53:0771
François Doray4f51d5d2018-12-03 22:26:2472 WEB_CONTENTS_USER_DATA_KEY_DECL();
73
[email protected]9ce7cb42011-12-07 18:53:0774 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper);
75};
76
77#endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_