[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 1 | // Copyright (c) 2011 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. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | ||||
6 | #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | ||||
7 | #pragma once | ||||
8 | |||||
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame^] | 9 | #include "base/memory/scoped_ptr.h" |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 10 | #include "chrome/browser/prefs/pref_change_registrar.h" |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame^] | 11 | #include "content/public/browser/notification_observer.h" |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 12 | #include "content/public/browser/notification_registrar.h" |
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 13 | #include "content/public/browser/web_contents_observer.h" |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 14 | |
15 | class PrefService; | ||||
[email protected] | ea6ad01a | 2011-12-21 21:53:49 | [diff] [blame] | 16 | class Profile; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 17 | struct WebPreferences; |
18 | |||||
19 | // Per-tab class to handle user preferences. | ||||
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 20 | class PrefsTabHelper : public content::WebContentsObserver, |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 21 | public content::NotificationObserver { |
22 | public: | ||||
[email protected] | 768c547 | 2011-12-26 19:06:17 | [diff] [blame] | 23 | explicit PrefsTabHelper(content::WebContents* contents); |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 24 | virtual ~PrefsTabHelper(); |
25 | |||||
26 | static void RegisterUserPrefs(PrefService* prefs); | ||||
27 | |||||
28 | PrefService* per_tab_prefs() { return per_tab_prefs_.get(); } | ||||
29 | |||||
30 | protected: | ||||
31 | // Update the RenderView's WebPreferences. Exposed as protected for testing. | ||||
32 | virtual void UpdateWebPreferences(); | ||||
33 | |||||
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 34 | // content::WebContentsObserver overrides, exposed as protected for testing. |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 35 | virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
36 | |||||
37 | private: | ||||
[email protected] | d8c66043 | 2011-12-22 20:51:25 | [diff] [blame] | 38 | // content::WebContentsObserver overrides: |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 39 | virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 40 | |
41 | // content::NotificationObserver overrides: | ||||
42 | virtual void Observe(int type, | ||||
43 | const content::NotificationSource& source, | ||||
44 | const content::NotificationDetails& details) OVERRIDE; | ||||
45 | |||||
46 | // Update the TabContents's RendererPreferences. | ||||
47 | void UpdateRendererPreferences(); | ||||
48 | |||||
[email protected] | ea6ad01a | 2011-12-21 21:53:49 | [diff] [blame] | 49 | Profile* GetProfile(); |
50 | |||||
[email protected] | 9ce7cb4 | 2011-12-07 18:53:07 | [diff] [blame] | 51 | content::NotificationRegistrar registrar_; |
52 | |||||
53 | scoped_ptr<PrefService> per_tab_prefs_; | ||||
54 | PrefChangeRegistrar pref_change_registrar_; | ||||
55 | PrefChangeRegistrar per_tab_pref_change_registrar_; | ||||
56 | |||||
57 | DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | ||||
58 | }; | ||||
59 | |||||
60 | #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |