| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/browsing_data_local_storage_helper.h" | 5 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/browser/in_process_webkit/webkit_context.h" | 13 #include "content/browser/in_process_webkit/webkit_context.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 18 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
| 19 | 19 |
| 20 using content::BrowserContext; |
| 20 using content::BrowserThread; | 21 using content::BrowserThread; |
| 21 using WebKit::WebSecurityOrigin; | 22 using WebKit::WebSecurityOrigin; |
| 22 | 23 |
| 23 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo() | 24 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo() |
| 24 : port(0), | 25 : port(0), |
| 25 size(0) { | 26 size(0) { |
| 26 } | 27 } |
| 27 | 28 |
| 28 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo( | 29 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo( |
| 29 const std::string& protocol, | 30 const std::string& protocol, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 BrowserThread::PostTask( | 83 BrowserThread::PostTask( |
| 83 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 84 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 84 base::Bind( | 85 base::Bind( |
| 85 &BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread, | 86 &BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread, |
| 86 this, file_path)); | 87 this, file_path)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread() { | 90 void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread() { |
| 90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 91 file_util::FileEnumerator file_enumerator( | 92 file_util::FileEnumerator file_enumerator( |
| 92 profile_->GetWebKitContext()->data_path().Append( | 93 BrowserContext::GetWebKitContext(profile_)->data_path().Append( |
| 93 DOMStorageContext::kLocalStorageDirectory), | 94 DOMStorageContext::kLocalStorageDirectory), |
| 94 false, file_util::FileEnumerator::FILES); | 95 false, file_util::FileEnumerator::FILES); |
| 95 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); | 96 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); |
| 96 file_path = file_enumerator.Next()) { | 97 file_path = file_enumerator.Next()) { |
| 97 if (file_path.Extension() == DOMStorageContext::kLocalStorageExtension) { | 98 if (file_path.Extension() == DOMStorageContext::kLocalStorageExtension) { |
| 98 WebSecurityOrigin web_security_origin = | 99 WebSecurityOrigin web_security_origin = |
| 99 WebSecurityOrigin::createFromDatabaseIdentifier( | 100 WebSecurityOrigin::createFromDatabaseIdentifier( |
| 100 webkit_glue::FilePathToWebString(file_path.BaseName())); | 101 webkit_glue::FilePathToWebString(file_path.BaseName())); |
| 101 if (EqualsASCII(web_security_origin.protocol(), | 102 if (EqualsASCII(web_security_origin.protocol(), |
| 102 chrome::kExtensionScheme)) { | 103 chrome::kExtensionScheme)) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 132 if (!completion_callback_.is_null()) { | 133 if (!completion_callback_.is_null()) { |
| 133 completion_callback_.Run(local_storage_info_); | 134 completion_callback_.Run(local_storage_info_); |
| 134 completion_callback_.Reset(); | 135 completion_callback_.Reset(); |
| 135 } | 136 } |
| 136 is_fetching_ = false; | 137 is_fetching_ = false; |
| 137 } | 138 } |
| 138 | 139 |
| 139 void BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread( | 140 void BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread( |
| 140 const FilePath& file_path) { | 141 const FilePath& file_path) { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 142 profile_->GetWebKitContext()->dom_storage_context()->DeleteLocalStorageFile( | 143 BrowserContext::GetWebKitContext(profile_)->dom_storage_context()-> |
| 143 file_path); | 144 DeleteLocalStorageFile(file_path); |
| 144 } | 145 } |
| 145 | 146 |
| 146 CannedBrowsingDataLocalStorageHelper::CannedBrowsingDataLocalStorageHelper( | 147 CannedBrowsingDataLocalStorageHelper::CannedBrowsingDataLocalStorageHelper( |
| 147 Profile* profile) | 148 Profile* profile) |
| 148 : BrowsingDataLocalStorageHelper(profile), | 149 : BrowsingDataLocalStorageHelper(profile), |
| 149 profile_(profile) { | 150 profile_(profile) { |
| 150 } | 151 } |
| 151 | 152 |
| 152 CannedBrowsingDataLocalStorageHelper* | 153 CannedBrowsingDataLocalStorageHelper* |
| 153 CannedBrowsingDataLocalStorageHelper::Clone() { | 154 CannedBrowsingDataLocalStorageHelper::Clone() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 215 } |
| 215 if (duplicate) | 216 if (duplicate) |
| 216 continue; | 217 continue; |
| 217 | 218 |
| 218 local_storage_info_.push_back(LocalStorageInfo( | 219 local_storage_info_.push_back(LocalStorageInfo( |
| 219 web_security_origin.protocol().utf8(), | 220 web_security_origin.protocol().utf8(), |
| 220 web_security_origin.host().utf8(), | 221 web_security_origin.host().utf8(), |
| 221 web_security_origin.port(), | 222 web_security_origin.port(), |
| 222 web_security_origin.databaseIdentifier().utf8(), | 223 web_security_origin.databaseIdentifier().utf8(), |
| 223 security_origin, | 224 security_origin, |
| 224 profile_->GetWebKitContext()->dom_storage_context()-> | 225 BrowserContext::GetWebKitContext(profile_)->dom_storage_context()-> |
| 225 GetLocalStorageFilePath(web_security_origin.databaseIdentifier()), | 226 GetLocalStorageFilePath(web_security_origin.databaseIdentifier()), |
| 226 0, | 227 0, |
| 227 base::Time())); | 228 base::Time())); |
| 228 } | 229 } |
| 229 pending_local_storage_info_.clear(); | 230 pending_local_storage_info_.clear(); |
| 230 | 231 |
| 231 BrowserThread::PostTask( | 232 BrowserThread::PostTask( |
| 232 BrowserThread::UI, FROM_HERE, | 233 BrowserThread::UI, FROM_HERE, |
| 233 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread, | 234 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread, |
| 234 this)); | 235 this)); |
| 235 } | 236 } |
| OLD | NEW |