summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:28:43 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:28:43 +0000
commit19eb8015c483fff874bf1eddb80bd26cf4167f33 (patch)
treebe896411dde17d24eb8dbcd67e7b4c5cad2ef1b6 /content/browser
parentf02074331bddc7d89b20e6b3a8fb934e6891207c (diff)
downloadchromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.zip
chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.gz
chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.bz2
Add an accessor for an ExtensionSpecialStoragePolicy to the Profile class
and use it in the extension service, data remover, and storage subsystems. BUG=52357 TEST=extension_service_unittest.cc Review URL: http://codereview.chromium.org/6551028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc16
-rw-r--r--content/browser/appcache/chrome_appcache_service.h7
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc2
-rw-r--r--content/browser/file_system/browser_file_system_helper.cc4
-rw-r--r--content/browser/file_system/browser_file_system_helper.h7
-rw-r--r--content/browser/in_process_webkit/dom_storage_context.cc36
-rw-r--r--content/browser/in_process_webkit/dom_storage_context.h17
-rw-r--r--content/browser/in_process_webkit/webkit_context.cc14
-rw-r--r--content/browser/in_process_webkit/webkit_context.h4
-rw-r--r--content/browser/in_process_webkit/webkit_context_unittest.cc3
10 files changed, 52 insertions, 58 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 68c7ece..5f6107a 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -38,6 +38,7 @@ ChromeAppCacheService::ChromeAppCacheService()
void ChromeAppCacheService::InitializeOnIOThread(
const FilePath& profile_path, bool is_incognito,
scoped_refptr<HostContentSettingsMap> content_settings_map,
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
bool clear_local_state_on_exit) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -57,6 +58,7 @@ void ChromeAppCacheService::InitializeOnIOThread(
Initialize(cache_path_,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
set_appcache_policy(this);
+ set_special_storage_policy(special_storage_policy);
}
ChromeAppCacheService::~ChromeAppCacheService() {
@@ -69,20 +71,8 @@ ChromeAppCacheService::~ChromeAppCacheService() {
}
}
-void ChromeAppCacheService::SetOriginQuotaInMemory(
- const GURL& origin, int64 quota) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (storage())
- storage()->SetOriginQuotaInMemory(origin, quota);
-}
-
-void ChromeAppCacheService::ResetOriginQuotaInMemory(const GURL& origin) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (storage())
- storage()->ResetOriginQuotaInMemory(origin);
-}
-
void ChromeAppCacheService::SetClearLocalStateOnExit(bool clear_local_state) {
+ // TODO(michaeln): How is 'protected' status granted to apps in this case?
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
diff --git a/content/browser/appcache/chrome_appcache_service.h b/content/browser/appcache/chrome_appcache_service.h
index 8081122..ad77477 100644
--- a/content/browser/appcache/chrome_appcache_service.h
+++ b/content/browser/appcache/chrome_appcache_service.h
@@ -12,6 +12,7 @@
#include "content/browser/browser_thread.h"
#include "webkit/appcache/appcache_policy.h"
#include "webkit/appcache/appcache_service.h"
+#include "webkit/quota/special_storage_policy.h"
class ChromeURLRequestContext;
class FilePath;
@@ -36,13 +37,9 @@ class ChromeAppCacheService
void InitializeOnIOThread(
const FilePath& profile_path, bool is_incognito,
scoped_refptr<HostContentSettingsMap> content_settings_map,
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
bool clear_local_state_on_exit);
- // Helpers used by the extension service to grant and revoke
- // unlimited storage to app extensions.
- void SetOriginQuotaInMemory(const GURL& origin, int64 quota);
- void ResetOriginQuotaInMemory(const GURL& origin);
-
void SetClearLocalStateOnExit(bool clear_local_state);
private:
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index 0c5c512..fb6b80e 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -49,6 +49,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
&ChromeAppCacheService::InitializeOnIOThread,
temp_dir_.path(), false,
scoped_refptr<HostContentSettingsMap>(NULL),
+ scoped_refptr<quota::SpecialStoragePolicy>(NULL),
false));
// Make the steps needed to initialize the storage of AppCache data.
message_loop_.RunAllPending();
@@ -79,6 +80,7 @@ TEST_F(ChromeAppCacheServiceTest, RemoveOnDestruction) {
&ChromeAppCacheService::InitializeOnIOThread,
temp_dir_.path(), false,
scoped_refptr<HostContentSettingsMap>(NULL),
+ scoped_refptr<quota::SpecialStoragePolicy>(NULL),
true));
// Make the steps needed to initialize the storage of AppCache data.
message_loop_.RunAllPending();
diff --git a/content/browser/file_system/browser_file_system_helper.cc b/content/browser/file_system/browser_file_system_helper.cc
index 81666f0..960d838 100644
--- a/content/browser/file_system/browser_file_system_helper.cc
+++ b/content/browser/file_system/browser_file_system_helper.cc
@@ -10,10 +10,12 @@
#include "content/browser/browser_thread.h"
scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext(
- const FilePath& profile_path, bool is_incognito) {
+ const FilePath& profile_path, bool is_incognito,
+ quota::SpecialStoragePolicy* special_storage_policy) {
return new fileapi::FileSystemContext(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
+ special_storage_policy,
profile_path,
is_incognito,
CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/content/browser/file_system/browser_file_system_helper.h b/content/browser/file_system/browser_file_system_helper.h
index 55c6e3a..84eb26c 100644
--- a/content/browser/file_system/browser_file_system_helper.h
+++ b/content/browser/file_system/browser_file_system_helper.h
@@ -9,9 +9,14 @@
#include "base/scoped_ptr.h"
#include "webkit/fileapi/file_system_context.h"
+namespace quota {
+class SpecialStoragePolicy;
+}
+
// Helper method that returns FileSystemContext constructed for
// the browser process.
scoped_refptr<fileapi::FileSystemContext> CreateFileSystemContext(
- const FilePath& profile_path, bool is_incognito);
+ const FilePath& profile_path, bool is_incognito,
+ quota::SpecialStoragePolicy* special_storage_policy);
#endif // CONTENT_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_
diff --git a/content/browser/in_process_webkit/dom_storage_context.cc b/content/browser/in_process_webkit/dom_storage_context.cc
index c39d75a..184cb24 100644
--- a/content/browser/in_process_webkit/dom_storage_context.cc
+++ b/content/browser/in_process_webkit/dom_storage_context.cc
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/string_util.h"
+#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/common/dom_storage_common.h"
#include "chrome/common/url_constants.h"
#include "content/browser/browser_thread.h"
@@ -17,14 +18,14 @@
#include "content/browser/in_process_webkit/webkit_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "webkit/quota/special_storage_policy.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebSecurityOrigin;
namespace {
-void ClearLocalState(const FilePath& domstorage_path,
- const char* url_scheme_to_be_skipped) {
+void ClearLocalState(const FilePath& domstorage_path) {
file_util::FileEnumerator file_enumerator(
domstorage_path, false, file_util::FileEnumerator::FILES);
for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
@@ -33,8 +34,9 @@ void ClearLocalState(const FilePath& domstorage_path,
WebSecurityOrigin web_security_origin =
WebSecurityOrigin::createFromDatabaseIdentifier(
webkit_glue::FilePathToWebString(file_path.BaseName()));
+ // TODO(michaeln): how is protected status provided to apps at this time?
if (!EqualsASCII(web_security_origin.protocol(),
- url_scheme_to_be_skipped)) {
+ chrome::kExtensionScheme)) {
file_util::Delete(file_path, false);
}
}
@@ -49,11 +51,14 @@ const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] =
const FilePath::CharType DOMStorageContext::kLocalStorageExtension[] =
FILE_PATH_LITERAL(".localstorage");
-DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context)
+DOMStorageContext::DOMStorageContext(
+ WebKitContext* webkit_context,
+ quota::SpecialStoragePolicy* special_storage_policy)
: last_storage_area_id_(0),
last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId),
last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId),
- clear_local_state_on_exit_(false) {
+ clear_local_state_on_exit_(false),
+ special_storage_policy_(special_storage_policy) {
data_path_ = webkit_context->data_path();
}
@@ -71,8 +76,7 @@ DOMStorageContext::~DOMStorageContext() {
// where no clean up is needed.
if (clear_local_state_on_exit_ &&
BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) {
- ClearLocalState(data_path_.Append(kLocalStorageDirectory),
- chrome::kExtensionScheme);
+ ClearLocalState(data_path_.Append(kLocalStorageDirectory));
}
}
@@ -176,10 +180,7 @@ void DOMStorageContext::PurgeMemory() {
local_storage->PurgeMemory();
}
-void DOMStorageContext::DeleteDataModifiedSince(
- const base::Time& cutoff,
- const char* url_scheme_to_be_skipped,
- const std::vector<string16>& protected_origins) {
+void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
// Make sure that we don't delete a database that's currently being accessed
// by unloading all of the databases temporarily.
PurgeMemory();
@@ -189,16 +190,9 @@ void DOMStorageContext::DeleteDataModifiedSince(
file_util::FileEnumerator::FILES);
for (FilePath path = file_enumerator.Next(); !path.value().empty();
path = file_enumerator.Next()) {
- WebSecurityOrigin web_security_origin =
- WebSecurityOrigin::createFromDatabaseIdentifier(
- webkit_glue::FilePathToWebString(path.BaseName()));
- if (EqualsASCII(web_security_origin.protocol(), url_scheme_to_be_skipped))
- continue;
-
- std::vector<string16>::const_iterator find_iter =
- std::find(protected_origins.begin(), protected_origins.end(),
- web_security_origin.databaseIdentifier());
- if (find_iter != protected_origins.end())
+ GURL origin(WebSecurityOrigin::createFromDatabaseIdentifier(
+ webkit_glue::FilePathToWebString(path.BaseName())).toString());
+ if (special_storage_policy_->IsStorageProtected(origin))
continue;
file_util::FileEnumerator::FindInfo find_info;
diff --git a/content/browser/in_process_webkit/dom_storage_context.h b/content/browser/in_process_webkit/dom_storage_context.h
index 6810453..c865d8a 100644
--- a/content/browser/in_process_webkit/dom_storage_context.h
+++ b/content/browser/in_process_webkit/dom_storage_context.h
@@ -10,6 +10,7 @@
#include <set>
#include "base/file_path.h"
+#include "base/ref_counted.h"
#include "base/string16.h"
#include "base/time.h"
@@ -18,6 +19,10 @@ class DOMStorageMessageFilter;
class DOMStorageNamespace;
class WebKitContext;
+namespace quota {
+class SpecialStoragePolicy;
+}
+
// This is owned by WebKitContext and is all the dom storage information that's
// shared by all the DOMStorageMessageFilters that share the same profile. The
// specifics of responsibilities are fairly well documented here and in
@@ -27,7 +32,8 @@ class WebKitContext;
// NOTE: Virtual methods facilitate mocking functions for testing.
class DOMStorageContext {
public:
- explicit DOMStorageContext(WebKitContext* webkit_context);
+ DOMStorageContext(WebKitContext* webkit_context,
+ quota::SpecialStoragePolicy* special_storage_policy);
virtual ~DOMStorageContext();
// Invalid storage id. No storage session will ever report this value.
@@ -70,10 +76,9 @@ class DOMStorageContext {
virtual void PurgeMemory();
// Delete any local storage files that have been touched since the cutoff
- // date that's supplied.
- void DeleteDataModifiedSince(const base::Time& cutoff,
- const char* url_scheme_to_be_skipped,
- const std::vector<string16>& protected_origins);
+ // date that's supplied. Protected origins, per the SpecialStoragePolicy,
+ // are not deleted by this method.
+ void DeleteDataModifiedSince(const base::Time& cutoff);
// Deletes a single local storage file.
void DeleteLocalStorageFile(const FilePath& file_path);
@@ -151,6 +156,8 @@ class DOMStorageContext {
typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap;
StorageNamespaceMap storage_namespace_map_;
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext);
};
diff --git a/content/browser/in_process_webkit/webkit_context.cc b/content/browser/in_process_webkit/webkit_context.cc
index b19fdbf..41cd58e 100644
--- a/content/browser/in_process_webkit/webkit_context.cc
+++ b/content/browser/in_process_webkit/webkit_context.cc
@@ -5,6 +5,7 @@
#include "content/browser/in_process_webkit/webkit_context.h"
#include "base/command_line.h"
+#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/profiles/profile.h"
#include "content/browser/browser_thread.h"
@@ -13,7 +14,8 @@ WebKitContext::WebKitContext(Profile* profile, bool clear_local_state_on_exit)
is_incognito_(profile->IsOffTheRecord()),
clear_local_state_on_exit_(clear_local_state_on_exit),
ALLOW_THIS_IN_INITIALIZER_LIST(
- dom_storage_context_(new DOMStorageContext(this))),
+ dom_storage_context_(new DOMStorageContext(
+ this, profile->GetExtensionSpecialStoragePolicy()))),
ALLOW_THIS_IN_INITIALIZER_LIST(
indexed_db_context_(new IndexedDBContext(this))) {
}
@@ -52,20 +54,16 @@ void WebKitContext::PurgeMemory() {
dom_storage_context_->PurgeMemory();
}
-void WebKitContext::DeleteDataModifiedSince(
- const base::Time& cutoff,
- const char* url_scheme_to_be_skipped,
- const std::vector<string16>& protected_origins) {
+void WebKitContext::DeleteDataModifiedSince(const base::Time& cutoff) {
if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) {
BrowserThread::PostTask(
BrowserThread::WEBKIT, FROM_HERE,
NewRunnableMethod(this, &WebKitContext::DeleteDataModifiedSince,
- cutoff, url_scheme_to_be_skipped, protected_origins));
+ cutoff));
return;
}
- dom_storage_context_->DeleteDataModifiedSince(
- cutoff, url_scheme_to_be_skipped, protected_origins);
+ dom_storage_context_->DeleteDataModifiedSince(cutoff);
}
diff --git a/content/browser/in_process_webkit/webkit_context.h b/content/browser/in_process_webkit/webkit_context.h
index 5f647ef..c912c62 100644
--- a/content/browser/in_process_webkit/webkit_context.h
+++ b/content/browser/in_process_webkit/webkit_context.h
@@ -57,9 +57,7 @@ class WebKitContext
// Tell all children (where applicable) to delete any objects that were
// last modified on or after the following time.
- void DeleteDataModifiedSince(const base::Time& cutoff,
- const char* url_scheme_to_be_skipped,
- const std::vector<string16>& protected_origins);
+ void DeleteDataModifiedSince(const base::Time& cutoff);
// Delete the session storage namespace associated with this id. Can be
// called from any thread.
diff --git a/content/browser/in_process_webkit/webkit_context_unittest.cc b/content/browser/in_process_webkit/webkit_context_unittest.cc
index 811a3d0..9998142 100644
--- a/content/browser/in_process_webkit/webkit_context_unittest.cc
+++ b/content/browser/in_process_webkit/webkit_context_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/browser_thread.h"
#include "content/browser/in_process_webkit/dom_storage_context.h"
@@ -11,7 +12,7 @@
class MockDOMStorageContext : public DOMStorageContext {
public:
explicit MockDOMStorageContext(WebKitContext* webkit_context)
- : DOMStorageContext(webkit_context),
+ : DOMStorageContext(webkit_context, new ExtensionSpecialStoragePolicy),
purge_count_(0) {
}