| OLD | NEW |
| 1 // Copyright (c) 2010 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_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "chrome/browser/geolocation/geolocation_settings_state.h" | 10 #include "chrome/browser/geolocation/geolocation_settings_state.h" |
| 11 #include "chrome/common/content_settings.h" | 11 #include "chrome/common/content_settings.h" |
| 12 #include "chrome/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
| 13 #include "content/browser/tab_contents/navigation_controller.h" | 13 #include "content/browser/tab_contents/navigation_controller.h" |
| 14 #include "content/browser/tab_contents/tab_contents_observer.h" | 14 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 15 #include "content/common/dom_storage_common.h" | 15 #include "content/common/dom_storage_common.h" |
| 16 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
| 17 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
| 18 | 18 |
| 19 class CannedBrowsingDataAppCacheHelper; | 19 class CannedBrowsingDataAppCacheHelper; |
| 20 class CannedBrowsingDataDatabaseHelper; | 20 class CannedBrowsingDataDatabaseHelper; |
| 21 class CannedBrowsingDataFileSystemHelper; |
| 21 class CannedBrowsingDataIndexedDBHelper; | 22 class CannedBrowsingDataIndexedDBHelper; |
| 22 class CannedBrowsingDataLocalStorageHelper; | 23 class CannedBrowsingDataLocalStorageHelper; |
| 23 class CookiesTreeModel; | 24 class CookiesTreeModel; |
| 24 class TabContents; | 25 class TabContents; |
| 25 class Profile; | 26 class Profile; |
| 26 struct ContentSettings; | 27 struct ContentSettings; |
| 27 | 28 |
| 28 namespace net { | 29 namespace net { |
| 29 class CookieList; | 30 class CookieList; |
| 30 class CookieMonster; | 31 class CookieMonster; |
| 31 class CookieOptions; | 32 class CookieOptions; |
| 32 } | 33 } |
| 33 | 34 |
| 34 class TabSpecificContentSettings : public TabContentsObserver, | 35 class TabSpecificContentSettings : public TabContentsObserver, |
| 35 public NotificationObserver { | 36 public NotificationObserver { |
| 36 public: | 37 public: |
| 37 TabSpecificContentSettings(TabContents* tab); | 38 explicit TabSpecificContentSettings(TabContents* tab); |
| 38 | 39 |
| 39 virtual ~TabSpecificContentSettings(); | 40 virtual ~TabSpecificContentSettings(); |
| 40 | 41 |
| 41 // Returns the object given a render view's id. | 42 // Returns the object given a render view's id. |
| 42 static TabSpecificContentSettings* Get(int render_process_id, | 43 static TabSpecificContentSettings* Get(int render_process_id, |
| 43 int render_view_id); | 44 int render_view_id); |
| 44 | 45 |
| 45 // Static methods called on the UI threads. | 46 // Static methods called on the UI threads. |
| 46 // Called when cookies for the given URL were read either from within the | 47 // Called when cookies for the given URL were read either from within the |
| 47 // current page or while loading it. |blocked_by_policy| should be true, if | 48 // current page or while loading it. |blocked_by_policy| should be true, if |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Called when a specific indexed db factory in the current page was | 89 // Called when a specific indexed db factory in the current page was |
| 89 // accessed. If access was blocked due to the user's content settings, | 90 // accessed. If access was blocked due to the user's content settings, |
| 90 // |blocked_by_policy| should be true, and this function should invoke | 91 // |blocked_by_policy| should be true, and this function should invoke |
| 91 // OnContentBlocked. | 92 // OnContentBlocked. |
| 92 static void IndexedDBAccessed(int render_process_id, | 93 static void IndexedDBAccessed(int render_process_id, |
| 93 int render_view_id, | 94 int render_view_id, |
| 94 const GURL& url, | 95 const GURL& url, |
| 95 const string16& description, | 96 const string16& description, |
| 96 bool blocked_by_policy); | 97 bool blocked_by_policy); |
| 97 | 98 |
| 99 // Called when a specific file system in the current page was accessed. |
| 100 // If access was blocked due to the user's content settings, |
| 101 // |blocked_by_policy| should be true, and this function should invoke |
| 102 // OnContentBlocked. |
| 103 static void FileSystemAccessed(int render_process_id, |
| 104 int render_view_id, |
| 105 const GURL& url, |
| 106 bool blocked_by_policy); |
| 107 |
| 98 // Resets the |content_blocked_| and |content_accessed_| arrays, except for | 108 // Resets the |content_blocked_| and |content_accessed_| arrays, except for |
| 99 // CONTENT_SETTINGS_TYPE_COOKIES related information. | 109 // CONTENT_SETTINGS_TYPE_COOKIES related information. |
| 100 void ClearBlockedContentSettingsExceptForCookies(); | 110 void ClearBlockedContentSettingsExceptForCookies(); |
| 101 | 111 |
| 102 // Resets all cookies related information. | 112 // Resets all cookies related information. |
| 103 void ClearCookieSpecificContentSettings(); | 113 void ClearCookieSpecificContentSettings(); |
| 104 | 114 |
| 105 // Clears the Geolocation settings. | 115 // Clears the Geolocation settings. |
| 106 void ClearGeolocationContentSettings(); | 116 void ClearGeolocationContentSettings(); |
| 107 | 117 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 174 |
| 165 // These methods are invoked on the UI thread by the static functions above. | 175 // These methods are invoked on the UI thread by the static functions above. |
| 166 // Public for testing. | 176 // Public for testing. |
| 167 void OnCookiesRead(const GURL& url, | 177 void OnCookiesRead(const GURL& url, |
| 168 const net::CookieList& cookie_list, | 178 const net::CookieList& cookie_list, |
| 169 bool blocked_by_policy); | 179 bool blocked_by_policy); |
| 170 void OnCookieChanged(const GURL& url, | 180 void OnCookieChanged(const GURL& url, |
| 171 const std::string& cookie_line, | 181 const std::string& cookie_line, |
| 172 const net::CookieOptions& options, | 182 const net::CookieOptions& options, |
| 173 bool blocked_by_policy); | 183 bool blocked_by_policy); |
| 184 void OnFileSystemAccessed(const GURL& url, |
| 185 bool blocked_by_policy); |
| 174 void OnIndexedDBAccessed(const GURL& url, | 186 void OnIndexedDBAccessed(const GURL& url, |
| 175 const string16& description, | 187 const string16& description, |
| 176 bool blocked_by_policy); | 188 bool blocked_by_policy); |
| 177 void OnLocalStorageAccessed(const GURL& url, | 189 void OnLocalStorageAccessed(const GURL& url, |
| 178 DOMStorageType storage_type, | 190 DOMStorageType storage_type, |
| 179 bool blocked_by_policy); | 191 bool blocked_by_policy); |
| 180 void OnWebDatabaseAccessed(const GURL& url, | 192 void OnWebDatabaseAccessed(const GURL& url, |
| 181 const string16& name, | 193 const string16& name, |
| 182 const string16& display_name, | 194 const string16& display_name, |
| 183 bool blocked_by_policy); | 195 bool blocked_by_policy); |
| 184 void OnGeolocationPermissionSet(const GURL& requesting_frame, | 196 void OnGeolocationPermissionSet(const GURL& requesting_frame, |
| 185 bool allowed); | 197 bool allowed); |
| 186 | 198 |
| 187 private: | 199 private: |
| 188 class LocalSharedObjectsContainer { | 200 class LocalSharedObjectsContainer { |
| 189 public: | 201 public: |
| 190 explicit LocalSharedObjectsContainer(Profile* profile); | 202 explicit LocalSharedObjectsContainer(Profile* profile); |
| 191 ~LocalSharedObjectsContainer(); | 203 ~LocalSharedObjectsContainer(); |
| 192 | 204 |
| 193 // Empties the container. | 205 // Empties the container. |
| 194 void Reset(); | 206 void Reset(); |
| 195 | 207 |
| 196 net::CookieMonster* cookies() const { return cookies_; } | 208 net::CookieMonster* cookies() const { return cookies_; } |
| 197 CannedBrowsingDataAppCacheHelper* appcaches() const { | 209 CannedBrowsingDataAppCacheHelper* appcaches() const { |
| 198 return appcaches_; | 210 return appcaches_; |
| 199 } | 211 } |
| 200 CannedBrowsingDataDatabaseHelper* databases() const { | 212 CannedBrowsingDataDatabaseHelper* databases() const { |
| 201 return databases_; | 213 return databases_; |
| 202 } | 214 } |
| 215 CannedBrowsingDataFileSystemHelper* file_systems() const { |
| 216 return file_systems_; |
| 217 } |
| 203 CannedBrowsingDataIndexedDBHelper* indexed_dbs() const { | 218 CannedBrowsingDataIndexedDBHelper* indexed_dbs() const { |
| 204 return indexed_dbs_; | 219 return indexed_dbs_; |
| 205 } | 220 } |
| 206 CannedBrowsingDataLocalStorageHelper* local_storages() const { | 221 CannedBrowsingDataLocalStorageHelper* local_storages() const { |
| 207 return local_storages_; | 222 return local_storages_; |
| 208 } | 223 } |
| 209 CannedBrowsingDataLocalStorageHelper* session_storages() const { | 224 CannedBrowsingDataLocalStorageHelper* session_storages() const { |
| 210 return session_storages_; | 225 return session_storages_; |
| 211 } | 226 } |
| 212 | 227 |
| 213 CookiesTreeModel* GetCookiesTreeModel(); | 228 CookiesTreeModel* GetCookiesTreeModel(); |
| 214 | 229 |
| 215 bool empty() const; | 230 bool empty() const; |
| 216 | 231 |
| 217 private: | 232 private: |
| 218 DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer); | 233 DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer); |
| 219 | 234 |
| 220 scoped_refptr<net::CookieMonster> cookies_; | 235 scoped_refptr<net::CookieMonster> cookies_; |
| 221 scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_; | 236 scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_; |
| 222 scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_; | 237 scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_; |
| 238 scoped_refptr<CannedBrowsingDataFileSystemHelper> file_systems_; |
| 223 scoped_refptr<CannedBrowsingDataIndexedDBHelper> indexed_dbs_; | 239 scoped_refptr<CannedBrowsingDataIndexedDBHelper> indexed_dbs_; |
| 224 scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_; | 240 scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_; |
| 225 scoped_refptr<CannedBrowsingDataLocalStorageHelper> session_storages_; | 241 scoped_refptr<CannedBrowsingDataLocalStorageHelper> session_storages_; |
| 226 }; | 242 }; |
| 227 | 243 |
| 228 void AddBlockedResource(ContentSettingsType content_type, | 244 void AddBlockedResource(ContentSettingsType content_type, |
| 229 const std::string& resource_identifier); | 245 const std::string& resource_identifier); |
| 230 | 246 |
| 231 void OnContentAccessed(ContentSettingsType type); | 247 void OnContentAccessed(ContentSettingsType type); |
| 232 | 248 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 258 | 274 |
| 259 // Stores whether the user can load blocked plugins on this page. | 275 // Stores whether the user can load blocked plugins on this page. |
| 260 bool load_plugins_link_enabled_; | 276 bool load_plugins_link_enabled_; |
| 261 | 277 |
| 262 NotificationRegistrar registrar_; | 278 NotificationRegistrar registrar_; |
| 263 | 279 |
| 264 DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings); | 280 DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings); |
| 265 }; | 281 }; |
| 266 | 282 |
| 267 #endif // CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ | 283 #endif // CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |
| OLD | NEW |