summaryrefslogtreecommitdiffstats
path: root/chrome/browser/in_process_webkit
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 02:35:08 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 02:35:08 +0000
commit4ef795df1f1a20a0aed61979fba034d4c7bcbd8d (patch)
tree0706238073f27beaed3b420d0cd9c13d28cdb56d /chrome/browser/in_process_webkit
parent43f28f83bc268dea720843a2616058b64b3e8810 (diff)
downloadchromium_src-4ef795df1f1a20a0aed61979fba034d4c7bcbd8d.zip
chromium_src-4ef795df1f1a20a0aed61979fba034d4c7bcbd8d.tar.gz
chromium_src-4ef795df1f1a20a0aed61979fba034d4c7bcbd8d.tar.bz2
Reland 37913. Clear local state on exit.
BUG=32719 TEST=none Review URL: http://codereview.chromium.org/560024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/in_process_webkit')
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.cc27
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.h10
2 files changed, 31 insertions, 6 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc
index c19b6cf..4156576 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_context.cc
@@ -1,17 +1,21 @@
-// Copyright (c) 2009 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.
+// 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.
#include "chrome/browser/in_process_webkit/dom_storage_context.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/string_util.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/in_process_webkit/dom_storage_area.h"
#include "chrome/browser/in_process_webkit/dom_storage_namespace.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/common/dom_storage_common.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webkit_glue.h"
const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] =
FILE_PATH_LITERAL("Local Storage");
@@ -236,3 +240,20 @@ void DOMStorageContext::CompleteCloningSessionStorage(
if (existing_namespace)
context->RegisterStorageNamespace(existing_namespace->Copy(clone_id));
}
+
+// static
+void DOMStorageContext::ClearLocalState(const FilePath& profile_path,
+ const char* url_scheme_to_be_skip) {
+ file_util::FileEnumerator file_enumerator(profile_path.Append(
+ kLocalStorageDirectory), false, file_util::FileEnumerator::FILES);
+ for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
+ file_path = file_enumerator.Next()) {
+ if (file_path.Extension() == kLocalStorageExtension) {
+ scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin(
+ WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
+ webkit_glue::FilePathToWebString(file_path.BaseName())));
+ if (!EqualsASCII(web_security_origin->protocol(), url_scheme_to_be_skip))
+ file_util::Delete(file_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 4981c07..49e3712 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.h
+++ b/chrome/browser/in_process_webkit/dom_storage_context.h
@@ -1,6 +1,6 @@
-// Copyright (c) 2009 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.
+// 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_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
#define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
@@ -78,6 +78,10 @@ class DOMStorageContext {
// The local storage file extension.
static const FilePath::CharType kLocalStorageExtension[];
+ // Delete all non-extension local storage files.
+ static void ClearLocalState(const FilePath& profile_path,
+ const char* url_scheme_to_be_skipped);
+
private:
// Get the local storage instance. The object is owned by this class.
DOMStorageNamespace* CreateLocalStorage();