blob: d970efb73554f5ea6a85a81da4fbabcaaedc6289 [file] [log] [blame]
[email protected]9ce7cb42011-12-07 18:53:071// 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]71fde352011-12-29 03:29:569#include "base/memory/scoped_ptr.h"
[email protected]9ce7cb42011-12-07 18:53:0710#include "chrome/browser/prefs/pref_change_registrar.h"
[email protected]71fde352011-12-29 03:29:5611#include "content/public/browser/notification_observer.h"
[email protected]9ce7cb42011-12-07 18:53:0712#include "content/public/browser/notification_registrar.h"
[email protected]d8c660432011-12-22 20:51:2513#include "content/public/browser/web_contents_observer.h"
[email protected]9ce7cb42011-12-07 18:53:0714
15class PrefService;
[email protected]ea6ad01a2011-12-21 21:53:4916class Profile;
[email protected]9ce7cb42011-12-07 18:53:0717struct WebPreferences;
18
19// Per-tab class to handle user preferences.
[email protected]d8c660432011-12-22 20:51:2520class PrefsTabHelper : public content::WebContentsObserver,
[email protected]9ce7cb42011-12-07 18:53:0721 public content::NotificationObserver {
22 public:
[email protected]768c5472011-12-26 19:06:1723 explicit PrefsTabHelper(content::WebContents* contents);
[email protected]9ce7cb42011-12-07 18:53:0724 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]d8c660432011-12-22 20:51:2534 // content::WebContentsObserver overrides, exposed as protected for testing.
[email protected]9ce7cb42011-12-07 18:53:0735 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
36
37 private:
[email protected]d8c660432011-12-22 20:51:2538 // content::WebContentsObserver overrides:
[email protected]26b5e322011-12-23 01:36:4739 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
[email protected]9ce7cb42011-12-07 18:53:0740
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]ea6ad01a2011-12-21 21:53:4949 Profile* GetProfile();
50
[email protected]9ce7cb42011-12-07 18:53:0751 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_