OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 10 #include "chrome/browser/browsing_data_database_helper.h" |
| 11 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 12 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 14 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 15 #include "chrome/common/content_settings.h" |
| 16 #include "chrome/common/content_settings_types.h" |
| 17 #include "net/base/cookie_monster.h" |
| 18 |
| 19 class Profile; |
| 20 |
| 21 class TabSpecificContentSettings |
| 22 : public RenderViewHostDelegate::ContentSettings { |
| 23 public: |
| 24 class Delegate { |
| 25 public: |
| 26 // Invoked when content settings managed by the TabSpecificContentSettings |
| 27 // object change. |
| 28 virtual void OnContentSettingsChange() = 0; |
| 29 |
| 30 virtual ~Delegate() {} |
| 31 }; |
| 32 |
| 33 TabSpecificContentSettings(Delegate* delegate, Profile* profile); |
| 34 |
| 35 virtual ~TabSpecificContentSettings() {} |
| 36 |
| 37 // Resets the |content_blocked_| array and stored cookies. |
| 38 void ClearBlockedContentSettings(); |
| 39 |
| 40 // Changes the |content_blocked_| entry for popups. |
| 41 void SetPopupsBlocked(bool blocked); |
| 42 |
| 43 // Updates Geolocation settings on navigation. |
| 44 void GeolocationDidNavigate( |
| 45 const NavigationController::LoadCommittedDetails& details); |
| 46 |
| 47 // Returns whether a particular kind of content has been blocked for this |
| 48 // page. |
| 49 bool IsContentBlocked(ContentSettingsType content_type) const; |
| 50 |
| 51 // Returns the GeolocationSettingsState that controls the |
| 52 // geolocation API usage on this page. |
| 53 const GeolocationSettingsState& geolocation_settings_state() const { |
| 54 return geolocation_settings_state_; |
| 55 } |
| 56 |
| 57 // RenderViewHostDelegate::ContentSettings implementation. |
| 58 virtual void OnContentBlocked(ContentSettingsType type); |
| 59 virtual void OnCookieAccessed(const GURL& url, |
| 60 const std::string& cookie_line, |
| 61 bool blocked_by_policy); |
| 62 virtual void OnLocalStorageAccessed(const GURL& url, bool blocked_by_policy); |
| 63 virtual void OnWebDatabaseAccessed(const GURL& url, |
| 64 const string16& name, |
| 65 const string16& display_name, |
| 66 unsigned long estimated_size, |
| 67 bool blocked_by_policy); |
| 68 virtual void OnGeolocationPermissionSet(const GURL& requesting_frame, |
| 69 bool allowed); |
| 70 |
| 71 private: |
| 72 class LocalSharedObjectsContainer { |
| 73 public: |
| 74 explicit LocalSharedObjectsContainer(Profile* profile); |
| 75 |
| 76 // Empties the container. |
| 77 void Reset(); |
| 78 |
| 79 net::CookieMonster* cookies() const { return cookies_; } |
| 80 CannedBrowsingDataAppCacheHelper* appcaches() const { |
| 81 return appcaches_; |
| 82 } |
| 83 CannedBrowsingDataDatabaseHelper* databases() const { |
| 84 return databases_; |
| 85 } |
| 86 CannedBrowsingDataLocalStorageHelper* local_storages() const { |
| 87 return local_storages_; |
| 88 } |
| 89 |
| 90 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer); |
| 92 |
| 93 scoped_refptr<net::CookieMonster> cookies_; |
| 94 scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_; |
| 95 scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_; |
| 96 scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_; |
| 97 }; |
| 98 |
| 99 // Stores which content setting types actually have blocked content. |
| 100 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; |
| 101 |
| 102 // Stores the blocked/allowed cookies. |
| 103 LocalSharedObjectsContainer allowed_local_shared_objects_; |
| 104 LocalSharedObjectsContainer blocked_local_shared_objects_; |
| 105 |
| 106 // Manages information about Geolocation API usage in this page. |
| 107 GeolocationSettingsState geolocation_settings_state_; |
| 108 |
| 109 Delegate* delegate_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings); |
| 112 }; |
| 113 |
| 114 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
OLD | NEW |