OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // source code is governed by a BSD-style license that can be found in the | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/in_process_webkit/dom_storage_context.h" | 5 #include "chrome/browser/in_process_webkit/dom_storage_context.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/string_util.h" |
9 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/in_process_webkit/dom_storage_area.h" | 11 #include "chrome/browser/in_process_webkit/dom_storage_area.h" |
11 #include "chrome/browser/in_process_webkit/dom_storage_namespace.h" | 12 #include "chrome/browser/in_process_webkit/dom_storage_namespace.h" |
12 #include "chrome/browser/in_process_webkit/webkit_context.h" | 13 #include "chrome/browser/in_process_webkit/webkit_context.h" |
13 #include "chrome/common/dom_storage_common.h" | 14 #include "chrome/common/dom_storage_common.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
14 #include "webkit/glue/glue_util.h" | 17 #include "webkit/glue/glue_util.h" |
| 18 #include "webkit/glue/webkit_glue.h" |
15 | 19 |
16 const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] = | 20 const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] = |
17 FILE_PATH_LITERAL("Local Storage"); | 21 FILE_PATH_LITERAL("Local Storage"); |
18 | 22 |
19 const FilePath::CharType DOMStorageContext::kLocalStorageExtension[] = | 23 const FilePath::CharType DOMStorageContext::kLocalStorageExtension[] = |
20 FILE_PATH_LITERAL(".localstorage"); | 24 FILE_PATH_LITERAL(".localstorage"); |
21 | 25 |
22 static const FilePath::CharType kLocalStorageOldPath[] = | 26 static const FilePath::CharType kLocalStorageOldPath[] = |
23 FILE_PATH_LITERAL("localStorage"); | 27 FILE_PATH_LITERAL("localStorage"); |
24 | 28 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 /* static */ | 233 /* static */ |
230 void DOMStorageContext::CompleteCloningSessionStorage( | 234 void DOMStorageContext::CompleteCloningSessionStorage( |
231 DOMStorageContext* context, int64 existing_id, int64 clone_id) { | 235 DOMStorageContext* context, int64 existing_id, int64 clone_id) { |
232 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 236 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
233 DOMStorageNamespace* existing_namespace = | 237 DOMStorageNamespace* existing_namespace = |
234 context->GetStorageNamespace(existing_id, false); | 238 context->GetStorageNamespace(existing_id, false); |
235 // If nothing exists, then there's nothing to clone. | 239 // If nothing exists, then there's nothing to clone. |
236 if (existing_namespace) | 240 if (existing_namespace) |
237 context->RegisterStorageNamespace(existing_namespace->Copy(clone_id)); | 241 context->RegisterStorageNamespace(existing_namespace->Copy(clone_id)); |
238 } | 242 } |
| 243 |
| 244 // static |
| 245 void DOMStorageContext::ClearLocalState(const FilePath& profile_path, |
| 246 const char* url_scheme_to_be_skip) { |
| 247 file_util::FileEnumerator file_enumerator(profile_path.Append( |
| 248 kLocalStorageDirectory), false, file_util::FileEnumerator::FILES); |
| 249 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); |
| 250 file_path = file_enumerator.Next()) { |
| 251 if (file_path.Extension() == kLocalStorageExtension) { |
| 252 scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin( |
| 253 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( |
| 254 webkit_glue::FilePathToWebString(file_path.BaseName()))); |
| 255 if (!EqualsASCII(web_security_origin->protocol(), url_scheme_to_be_skip)) |
| 256 file_util::Delete(file_path, false); |
| 257 } |
| 258 } |
| 259 } |
OLD | NEW |