OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/prefs/pref_change_registrar.h" | 10 #include "chrome/browser/prefs/pref_change_registrar.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/web_contents_observer.h" | |
14 | 13 |
15 class OverlayUserPrefStore; | 14 class OverlayUserPrefStore; |
16 class PrefService; | 15 class PrefService; |
17 class Profile; | 16 class Profile; |
18 struct WebPreferences; | 17 struct WebPreferences; |
19 | 18 |
| 19 namespace content { |
| 20 class WebContents; |
| 21 } |
| 22 |
20 // Per-tab class to handle user preferences. | 23 // Per-tab class to handle user preferences. |
21 class PrefsTabHelper : public content::WebContentsObserver, | 24 class PrefsTabHelper : public content::NotificationObserver { |
22 public content::NotificationObserver { | |
23 public: | 25 public: |
24 explicit PrefsTabHelper(content::WebContents* contents); | 26 explicit PrefsTabHelper(content::WebContents* contents); |
25 virtual ~PrefsTabHelper(); | 27 virtual ~PrefsTabHelper(); |
26 | 28 |
27 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); | 29 static void InitIncognitoUserPrefStore(OverlayUserPrefStore* pref_store); |
28 static void InitPerTabUserPrefStore(OverlayUserPrefStore* pref_store); | |
29 static void RegisterUserPrefs(PrefService* prefs); | 30 static void RegisterUserPrefs(PrefService* prefs); |
30 | 31 |
31 PrefService* per_tab_prefs() { return per_tab_prefs_.get(); } | |
32 | |
33 protected: | 32 protected: |
34 // Update the RenderView's WebPreferences. Exposed as protected for testing. | 33 // Update the RenderView's WebPreferences. Exposed as protected for testing. |
35 virtual void UpdateWebPreferences(); | 34 virtual void UpdateWebPreferences(); |
36 | 35 |
37 // content::WebContentsObserver overrides, exposed as protected for testing. | |
38 virtual void RenderViewCreated( | |
39 content::RenderViewHost* render_view_host) OVERRIDE; | |
40 | |
41 private: | 36 private: |
42 // content::WebContentsObserver overrides: | |
43 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | |
44 | |
45 // content::NotificationObserver overrides: | 37 // content::NotificationObserver overrides: |
46 virtual void Observe(int type, | 38 virtual void Observe(int type, |
47 const content::NotificationSource& source, | 39 const content::NotificationSource& source, |
48 const content::NotificationDetails& details) OVERRIDE; | 40 const content::NotificationDetails& details) OVERRIDE; |
49 | 41 |
50 // Update the TabContents's RendererPreferences. | 42 // Update the TabContents's RendererPreferences. |
51 void UpdateRendererPreferences(); | 43 void UpdateRendererPreferences(); |
52 | 44 |
53 Profile* GetProfile(); | 45 Profile* GetProfile(); |
54 | 46 |
| 47 content::WebContents* web_contents_; |
55 content::NotificationRegistrar registrar_; | 48 content::NotificationRegistrar registrar_; |
56 | |
57 scoped_ptr<PrefService> per_tab_prefs_; | |
58 PrefChangeRegistrar pref_change_registrar_; | 49 PrefChangeRegistrar pref_change_registrar_; |
59 PrefChangeRegistrar per_tab_pref_change_registrar_; | |
60 | 50 |
61 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | 51 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); |
62 }; | 52 }; |
63 | 53 |
64 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 54 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
OLD | NEW |