diff options
author | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 11:07:44 +0000 |
---|---|---|
committer | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 11:07:44 +0000 |
commit | 763d91fe15ecbcde91e34892280881bbab7c20a8 (patch) | |
tree | a82cfbc7ad4ea2b08e79c1a859f070d747de67fe /chrome/browser/content_settings | |
parent | 74ec7e6780d4d7489d3ad1cbbac7c6a17e0beed7 (diff) | |
download | chromium_src-763d91fe15ecbcde91e34892280881bbab7c20a8.zip chromium_src-763d91fe15ecbcde91e34892280881bbab7c20a8.tar.gz chromium_src-763d91fe15ecbcde91e34892280881bbab7c20a8.tar.bz2 |
Wrapping blocked filesystems into TabSpecificContentSettings
BUG=63703
TEST=TabSpecificContentSettings* in `unit_tests`
Review URL: http://codereview.chromium.org/6966036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_settings')
3 files changed, 62 insertions, 4 deletions
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index e643bba..7449a6d 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -10,6 +10,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browsing_data_appcache_helper.h" #include "chrome/browser/browsing_data_database_helper.h" +#include "chrome/browser/browsing_data_file_system_helper.h" #include "chrome/browser/browsing_data_indexed_db_helper.h" #include "chrome/browser/browsing_data_local_storage_helper.h" #include "chrome/browser/content_settings/content_settings_details.h" @@ -24,6 +25,7 @@ #include "content/common/notification_service.h" #include "content/common/view_messages.h" #include "net/base/cookie_monster.h" +#include "webkit/fileapi/file_system_types.h" namespace { typedef std::list<TabSpecificContentSettings*> TabSpecificList; @@ -35,6 +37,7 @@ bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const { return cookies_->GetAllCookies().empty() && appcaches_->empty() && databases_->empty() && + file_systems_->empty() && indexed_dbs_->empty() && local_storages_->empty() && session_storages_->empty(); @@ -131,6 +134,15 @@ void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id, settings->OnIndexedDBAccessed(url, description, blocked_by_policy); } +void TabSpecificContentSettings::FileSystemAccessed(int render_process_id, + int render_view_id, + const GURL& url, + bool blocked_by_policy) { + TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); + if (settings) + settings->OnFileSystemAccessed(url, blocked_by_policy); +} + bool TabSpecificContentSettings::IsContentBlocked( ContentSettingsType content_type) const { DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) @@ -270,7 +282,7 @@ void TabSpecificContentSettings::OnIndexedDBAccessed( blocked_local_shared_objects_.indexed_dbs()->AddIndexedDB( url, description); OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); - }else { + } else { allowed_local_shared_objects_.indexed_dbs()->AddIndexedDB( url, description); OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); @@ -321,6 +333,19 @@ void TabSpecificContentSettings::OnAppCacheAccessed( } } +void TabSpecificContentSettings::OnFileSystemAccessed( + const GURL& url, + bool blocked_by_policy) { + if (blocked_by_policy) { + blocked_local_shared_objects_.file_systems()->AddFileSystem(url, + fileapi::kFileSystemTypeTemporary, 0); + OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); + } else { + allowed_local_shared_objects_.file_systems()->AddFileSystem(url, + fileapi::kFileSystemTypeTemporary, 0); + OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); + } +} void TabSpecificContentSettings::OnGeolocationPermissionSet( const GURL& requesting_origin, bool allowed) { @@ -454,6 +479,7 @@ TabSpecificContentSettings::LocalSharedObjectsContainer:: : cookies_(new net::CookieMonster(NULL, NULL)), appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), databases_(new CannedBrowsingDataDatabaseHelper(profile)), + file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)), local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { @@ -475,6 +501,7 @@ void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() { cookies_->SetKeepExpiredCookies(); appcaches_->Reset(); databases_->Reset(); + file_systems_->Reset(); indexed_dbs_->Reset(); local_storages_->Reset(); session_storages_->Reset(); @@ -488,5 +515,6 @@ TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { session_storages_->Clone(), appcaches_->Clone(), indexed_dbs_->Clone(), + file_systems_->Clone(), true); } diff --git a/chrome/browser/content_settings/tab_specific_content_settings.h b/chrome/browser/content_settings/tab_specific_content_settings.h index f8924ea..c90c8e5 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.h +++ b/chrome/browser/content_settings/tab_specific_content_settings.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -18,6 +18,7 @@ class CannedBrowsingDataAppCacheHelper; class CannedBrowsingDataDatabaseHelper; +class CannedBrowsingDataFileSystemHelper; class CannedBrowsingDataIndexedDBHelper; class CannedBrowsingDataLocalStorageHelper; class CookiesTreeModel; @@ -34,7 +35,7 @@ class CookieOptions; class TabSpecificContentSettings : public TabContentsObserver, public NotificationObserver { public: - TabSpecificContentSettings(TabContents* tab); + explicit TabSpecificContentSettings(TabContents* tab); virtual ~TabSpecificContentSettings(); @@ -95,6 +96,15 @@ class TabSpecificContentSettings : public TabContentsObserver, const string16& description, bool blocked_by_policy); + // Called when a specific file system 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 FileSystemAccessed(int render_process_id, + int render_view_id, + const GURL& url, + bool blocked_by_policy); + // Resets the |content_blocked_| and |content_accessed_| arrays, except for // CONTENT_SETTINGS_TYPE_COOKIES related information. void ClearBlockedContentSettingsExceptForCookies(); @@ -171,6 +181,8 @@ class TabSpecificContentSettings : public TabContentsObserver, const std::string& cookie_line, const net::CookieOptions& options, bool blocked_by_policy); + void OnFileSystemAccessed(const GURL& url, + bool blocked_by_policy); void OnIndexedDBAccessed(const GURL& url, const string16& description, bool blocked_by_policy); @@ -200,6 +212,9 @@ class TabSpecificContentSettings : public TabContentsObserver, CannedBrowsingDataDatabaseHelper* databases() const { return databases_; } + CannedBrowsingDataFileSystemHelper* file_systems() const { + return file_systems_; + } CannedBrowsingDataIndexedDBHelper* indexed_dbs() const { return indexed_dbs_; } @@ -220,6 +235,7 @@ class TabSpecificContentSettings : public TabContentsObserver, scoped_refptr<net::CookieMonster> cookies_; scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_; scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_; + scoped_refptr<CannedBrowsingDataFileSystemHelper> file_systems_; scoped_refptr<CannedBrowsingDataIndexedDBHelper> indexed_dbs_; scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_; scoped_refptr<CannedBrowsingDataLocalStorageHelper> session_storages_; diff --git a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc index d0e7553..777cc79 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -78,6 +78,20 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); } +TEST_F(TabSpecificContentSettingsTest, BlockedFileSystems) { + TabSpecificContentSettings content_settings(contents()); + + // Access a file system. + content_settings.OnFileSystemAccessed(GURL("http://google.com"), false); + EXPECT_FALSE( + content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); + + // Block access to a file system. + content_settings.OnFileSystemAccessed(GURL("http://google.com"), true); + EXPECT_TRUE( + content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); +} + TEST_F(TabSpecificContentSettingsTest, AllowedContent) { TabSpecificContentSettings content_settings(contents()); net::CookieOptions options; |