diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-07 17:06:18 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-07 17:06:18 +0000 |
commit | 9a611a900b2fccd740f234ff16fe5520c993b7b2 (patch) | |
tree | 2eb8c01776bc84592d2c24f7edf52e91adcb6ab3 /chrome/browser/content_settings/tab_specific_content_settings.h | |
parent | c894476c4bc71d15d878f4157c4125423e10cfb2 (diff) | |
download | chromium_src-9a611a900b2fccd740f234ff16fe5520c993b7b2.zip chromium_src-9a611a900b2fccd740f234ff16fe5520c993b7b2.tar.gz chromium_src-9a611a900b2fccd740f234ff16fe5520c993b7b2.tar.bz2 |
More work on removing content settings code from src\content.
BUG=76793
Review URL: http://codereview.chromium.org/6928053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_settings/tab_specific_content_settings.h')
-rw-r--r-- | chrome/browser/content_settings/tab_specific_content_settings.h | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.h b/chrome/browser/content_settings/tab_specific_content_settings.h new file mode 100644 index 0000000..ddeaf58 --- /dev/null +++ b/chrome/browser/content_settings/tab_specific_content_settings.h @@ -0,0 +1,230 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ +#define CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ +#pragma once + +#include "base/basictypes.h" +#include "chrome/browser/geolocation/geolocation_settings_state.h" +#include "chrome/common/content_settings.h" +#include "chrome/common/content_settings_types.h" +#include "content/browser/renderer_host/render_view_host_delegate.h" +#include "content/browser/tab_contents/navigation_controller.h" +#include "content/browser/tab_contents/tab_contents_observer.h" + +class CannedBrowsingDataAppCacheHelper; +class CannedBrowsingDataDatabaseHelper; +class CannedBrowsingDataIndexedDBHelper; +class CannedBrowsingDataLocalStorageHelper; +class CookiesTreeModel; +class TabContents; +class Profile; + +namespace net { +class CookieMonster; +} + +class TabSpecificContentSettings + : public RenderViewHostDelegate::ContentSettings, + public TabContentsObserver { + public: + TabSpecificContentSettings(TabContents* tab); + + virtual ~TabSpecificContentSettings(); + + // Returns the object given a render view's id. + static TabSpecificContentSettings* Get(int render_process_id, + int render_view_id); + + // Static methods called on the UI threads. + // Called when a specific Web database in the current page was accessed. If + // access was blocked due to the user's content settings, + // |blocked_by_policy| should be true, and this function should invoke + // OnContentBlocked. + static void WebDatabaseAccessed(int render_process_id, + int render_view_id, + const GURL& url, + const string16& name, + const string16& display_name, + bool blocked_by_policy); + + // Called when a specific DOM storage area in the current page was + // accessed. If access was blocked due to the user's content settings, + // |blocked_by_policy| should be true, and this function should invoke + // OnContentBlocked. + static void DOMStorageAccessed(int render_process_id, + int render_view_id, + const GURL& url, + DOMStorageType storage_type, + bool blocked_by_policy); + + // Called when a specific indexed db factory in the current page was + // accessed. If access was blocked due to the user's content settings, + // |blocked_by_policy| should be true, and this function should invoke + // OnContentBlocked. + static void IndexedDBAccessed(int render_process_id, + int render_view_id, + const GURL& url, + const string16& description, + bool blocked_by_policy); + + // Resets the |content_blocked_| and |content_accessed_| arrays, except for + // CONTENT_SETTINGS_TYPE_COOKIES related information. + void ClearBlockedContentSettingsExceptForCookies(); + + // Resets all cookies related information. + void ClearCookieSpecificContentSettings(); + + // Clears the Geolocation settings. + void ClearGeolocationContentSettings(); + + // Changes the |content_blocked_| entry for popups. + void SetPopupsBlocked(bool blocked); + + // Updates Geolocation settings on navigation. + void GeolocationDidNavigate( + const NavigationController::LoadCommittedDetails& details); + + // Returns whether a particular kind of content has been blocked for this + // page. + bool IsContentBlocked(ContentSettingsType content_type) const; + + // Returns true if content blockage was indicated to the user. + bool IsBlockageIndicated(ContentSettingsType content_type) const; + + void SetBlockageHasBeenIndicated(ContentSettingsType content_type); + + // Returns whether a particular kind of content has been accessed. Currently + // only tracks cookies. + bool IsContentAccessed(ContentSettingsType content_type) const; + + const std::set<std::string>& BlockedResourcesForType( + ContentSettingsType content_type) const; + + // Returns the GeolocationSettingsState that controls the + // geolocation API usage on this page. + const GeolocationSettingsState& geolocation_settings_state() const { + return geolocation_settings_state_; + } + + // Returns a CookiesTreeModel object for the recoreded allowed cookies. + CookiesTreeModel* GetAllowedCookiesTreeModel(); + + // Returns a CookiesTreeModel object for the recoreded blocked cookies. + CookiesTreeModel* GetBlockedCookiesTreeModel(); + + bool load_plugins_link_enabled() { return load_plugins_link_enabled_; } + void set_load_plugins_link_enabled(bool enabled) { + load_plugins_link_enabled_ = enabled; + } + + // RenderViewHostDelegate::ContentSettings implementation. + virtual void OnContentBlocked(ContentSettingsType type, + const std::string& resource_identifier); + virtual void OnCookiesRead(const GURL& url, + const net::CookieList& cookie_list, + bool blocked_by_policy); + virtual void OnCookieChanged(const GURL& url, + const std::string& cookie_line, + const net::CookieOptions& options, + bool blocked_by_policy); + virtual void OnIndexedDBAccessed(const GURL& url, + const string16& description, + bool blocked_by_policy); + virtual void OnLocalStorageAccessed(const GURL& url, + DOMStorageType storage_type, + bool blocked_by_policy); + virtual void OnWebDatabaseAccessed(const GURL& url, + const string16& name, + const string16& display_name, + bool blocked_by_policy); + virtual void OnAppCacheAccessed(const GURL& manifest_url, + bool blocked_by_policy); + virtual void OnGeolocationPermissionSet(const GURL& requesting_frame, + bool allowed); + + // TabContentsObserver overrides. + virtual void DidNavigateMainFramePostCommit( + const NavigationController::LoadCommittedDetails& details, + const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; + virtual void DidStartProvisionalLoadForFrame(int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page) OVERRIDE; + + private: + class LocalSharedObjectsContainer { + public: + explicit LocalSharedObjectsContainer(Profile* profile); + ~LocalSharedObjectsContainer(); + + // Empties the container. + void Reset(); + + net::CookieMonster* cookies() const { return cookies_; } + CannedBrowsingDataAppCacheHelper* appcaches() const { + return appcaches_; + } + CannedBrowsingDataDatabaseHelper* databases() const { + return databases_; + } + CannedBrowsingDataIndexedDBHelper* indexed_dbs() const { + return indexed_dbs_; + } + CannedBrowsingDataLocalStorageHelper* local_storages() const { + return local_storages_; + } + CannedBrowsingDataLocalStorageHelper* session_storages() const { + return session_storages_; + } + + CookiesTreeModel* GetCookiesTreeModel(); + + bool empty() const; + + private: + DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer); + + scoped_refptr<net::CookieMonster> cookies_; + scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_; + scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_; + scoped_refptr<CannedBrowsingDataIndexedDBHelper> indexed_dbs_; + scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_; + scoped_refptr<CannedBrowsingDataLocalStorageHelper> session_storages_; + }; + + void AddBlockedResource(ContentSettingsType content_type, + const std::string& resource_identifier); + + void OnContentAccessed(ContentSettingsType type); + + // Stores which content setting types actually have blocked content. + bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; + + // Stores if the blocked content was messaged to the user. + bool content_blockage_indicated_to_user_[CONTENT_SETTINGS_NUM_TYPES]; + + // Stores which content setting types actually were accessed. + bool content_accessed_[CONTENT_SETTINGS_NUM_TYPES]; + + // Stores the blocked resources for each content type. + // Currently only used for plugins. + scoped_ptr<std::set<std::string> > + blocked_resources_[CONTENT_SETTINGS_NUM_TYPES]; + + // Stores the blocked/allowed cookies. + LocalSharedObjectsContainer allowed_local_shared_objects_; + LocalSharedObjectsContainer blocked_local_shared_objects_; + + // Manages information about Geolocation API usage in this page. + GeolocationSettingsState geolocation_settings_state_; + + // Stores whether the user can load blocked plugins on this page. + bool load_plugins_link_enabled_; + + DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings); +}; + +#endif // CHROME_BROWSER_CONTENT_SETTINGS_TAB_SPECIFIC_CONTENT_SETTINGS_H_ |