| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/prefs/pref_change_registrar.h" | 9 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 | 12 |
| 13 class PrefService; | 13 class PrefService; |
| 14 class Profile; | 14 class Profile; |
| 15 struct WebPreferences; | 15 struct WebPreferences; |
| 16 | 16 |
| 17 // Per-tab class to handle user preferences. | 17 // Per-tab class to handle user preferences. |
| 18 class PrefsTabHelper : public content::WebContentsObserver, | 18 class PrefsTabHelper : public content::WebContentsObserver, |
| 19 public content::NotificationObserver { | 19 public content::NotificationObserver { |
| 20 public: | 20 public: |
| 21 explicit PrefsTabHelper(TabContents* contents); | 21 explicit PrefsTabHelper(content::WebContents* contents); |
| 22 virtual ~PrefsTabHelper(); | 22 virtual ~PrefsTabHelper(); |
| 23 | 23 |
| 24 static void RegisterUserPrefs(PrefService* prefs); | 24 static void RegisterUserPrefs(PrefService* prefs); |
| 25 | 25 |
| 26 PrefService* per_tab_prefs() { return per_tab_prefs_.get(); } | 26 PrefService* per_tab_prefs() { return per_tab_prefs_.get(); } |
| 27 | 27 |
| 28 protected: | 28 protected: |
| 29 // Update the RenderView's WebPreferences. Exposed as protected for testing. | 29 // Update the RenderView's WebPreferences. Exposed as protected for testing. |
| 30 virtual void UpdateWebPreferences(); | 30 virtual void UpdateWebPreferences(); |
| 31 | 31 |
| 32 // content::WebContentsObserver overrides, exposed as protected for testing. | 32 // content::WebContentsObserver overrides, exposed as protected for testing. |
| 33 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 33 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 // content::WebContentsObserver overrides: | 36 // content::WebContentsObserver overrides: |
| 37 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | 37 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
| 38 | 38 |
| 39 // content::NotificationObserver overrides: | 39 // content::NotificationObserver overrides: |
| 40 virtual void Observe(int type, | 40 virtual void Observe(int type, |
| 41 const content::NotificationSource& source, | 41 const content::NotificationSource& source, |
| 42 const content::NotificationDetails& details) OVERRIDE; | 42 const content::NotificationDetails& details) OVERRIDE; |
| 43 | 43 |
| 44 // Update the TabContents's RendererPreferences. | 44 // Update the TabContents's RendererPreferences. |
| 45 void UpdateRendererPreferences(); | 45 void UpdateRendererPreferences(); |
| 46 | 46 |
| 47 Profile* GetProfile(); | 47 Profile* GetProfile(); |
| 48 | 48 |
| 49 // Our owning TabContents. | |
| 50 TabContents* contents_; | |
| 51 | |
| 52 content::NotificationRegistrar registrar_; | 49 content::NotificationRegistrar registrar_; |
| 53 | 50 |
| 54 scoped_ptr<PrefService> per_tab_prefs_; | 51 scoped_ptr<PrefService> per_tab_prefs_; |
| 55 PrefChangeRegistrar pref_change_registrar_; | 52 PrefChangeRegistrar pref_change_registrar_; |
| 56 PrefChangeRegistrar per_tab_pref_change_registrar_; | 53 PrefChangeRegistrar per_tab_pref_change_registrar_; |
| 57 | 54 |
| 58 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); | 55 DISALLOW_COPY_AND_ASSIGN(PrefsTabHelper); |
| 59 }; | 56 }; |
| 60 | 57 |
| 61 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ | 58 #endif // CHROME_BROWSER_UI_PREFS_PREFS_TAB_HELPER_H_ |
| OLD | NEW |