summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-26 00:37:06 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-26 00:37:06 +0000
commit35b9be0331299803c6fa724cbe8e416ec593c6fc (patch)
treee5928c2df4255e4efe6c08399e661892c6d5c28a /chrome
parent182c44faa58c15e474682f2ad349eca5a6a2235f (diff)
downloadchromium_src-35b9be0331299803c6fa724cbe8e416ec593c6fc.zip
chromium_src-35b9be0331299803c6fa724cbe8e416ec593c6fc.tar.gz
chromium_src-35b9be0331299803c6fa724cbe8e416ec593c6fc.tar.bz2
For now, let's clear local storage whenever we clear cookies.
BUG=28788 TEST="Clear private data..." from the menu, check cookies, and tell it ok. Data in "Local Storage" inside the profile's data dir should be deleted and any open websites that were using that data should no longer be able to see it. Review URL: http://codereview.chromium.org/441012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browsing_data_remover.cc2
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.cc17
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.h5
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.cc14
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.h5
5 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 652251c..11581b9 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/url_request_context_getter.h"
@@ -111,6 +112,7 @@ void BrowsingDataRemover::Remove(int remove_mask) {
profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster();
if (cookie_monster)
cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true);
+ profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_);
}
if (remove_mask & REMOVE_PASSWORDS) {
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc
index 3de5f6d..36804f8 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_context.cc
@@ -145,3 +145,20 @@ void DOMStorageContext::PurgeMemory() {
if (local_storage)
local_storage->PurgeMemory();
}
+
+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();
+
+ file_util::FileEnumerator file_enumerator(
+ webkit_context_->data_path().AppendASCII(kLocalStorageDirectory), false,
+ file_util::FileEnumerator::FILES);
+ for (FilePath path = file_enumerator.Next(); !path.value().empty();
+ path = file_enumerator.Next()) {
+ file_util::FileEnumerator::FindInfo find_info;
+ file_enumerator.GetFindInfo(&find_info);
+ if (file_util::HasFileBeenModifiedSince(find_info, cutoff))
+ file_util::Delete(path, false);
+ }
+}
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.h b/chrome/browser/in_process_webkit/dom_storage_context.h
index e652aa6..2d79117 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.h
+++ b/chrome/browser/in_process_webkit/dom_storage_context.h
@@ -9,6 +9,7 @@
#include <set>
#include "base/file_path.h"
+#include "base/time.h"
class DOMStorageDispatcherHost;
class StorageArea;
@@ -60,6 +61,10 @@ class DOMStorageContext {
// Tells storage namespaces to purge any memory they do not need.
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);
+
// The special ID used for local storage.
static const int64 kLocalStorageNamespaceId = 0;
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index 384e491..5fdb358 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -42,3 +42,17 @@ void WebKitContext::PurgeMemory() {
NewRunnableMethod(this, &WebKitContext::PurgeMemory));
}
}
+
+void WebKitContext::DeleteDataModifiedSince(const base::Time& cutoff) {
+ // DOMStorageContext::DeleteDataModifiedSince() should only be called on the
+ // WebKit thread.
+ if (ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
+ dom_storage_context_->DeleteDataModifiedSince(cutoff);
+ } else {
+ bool result = ChromeThread::PostTask(
+ ChromeThread::WEBKIT, FROM_HERE,
+ NewRunnableMethod(this, &WebKitContext::DeleteDataModifiedSince,
+ cutoff));
+ DCHECK(result);
+ }
+}
diff --git a/chrome/browser/in_process_webkit/webkit_context.h b/chrome/browser/in_process_webkit/webkit_context.h
index d83d530..38d9d7d 100644
--- a/chrome/browser/in_process_webkit/webkit_context.h
+++ b/chrome/browser/in_process_webkit/webkit_context.h
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "base/time.h"
#include "chrome/browser/in_process_webkit/dom_storage_context.h"
class WebKitThread;
@@ -38,6 +39,10 @@ class WebKitContext : public base::RefCountedThreadSafe<WebKitContext> {
// Tells the DOMStorageContext to purge any memory it does not need.
void PurgeMemory();
+ // 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);
+
private:
friend class base::RefCountedThreadSafe<WebKitContext>;
~WebKitContext();