| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browsing_data_helper.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/dom_storage_context.h" | 15 #include "content/public/browser/dom_storage_context.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
| 18 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
| 19 | 20 |
| 20 using content::BrowserContext; | 21 using content::BrowserContext; |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 using content::DOMStorageContext; | 23 using content::DOMStorageContext; |
| 23 using WebKit::WebSecurityOrigin; | 24 using WebKit::WebSecurityOrigin; |
| 24 | 25 |
| 25 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo() | 26 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo() |
| 26 : port(0), | 27 : port(0), |
| 27 size(0) { | 28 size(0) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 | 96 |
| 96 void BrowsingDataLocalStorageHelper::FetchLocalStorageInfo( | 97 void BrowsingDataLocalStorageHelper::FetchLocalStorageInfo( |
| 97 const std::vector<FilePath>& files) { | 98 const std::vector<FilePath>& files) { |
| 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 99 for (size_t i = 0; i < files.size(); ++i) { | 100 for (size_t i = 0; i < files.size(); ++i) { |
| 100 FilePath file_path = files[i]; | 101 FilePath file_path = files[i]; |
| 101 WebSecurityOrigin web_security_origin = | 102 WebSecurityOrigin web_security_origin = |
| 102 WebSecurityOrigin::createFromDatabaseIdentifier( | 103 WebSecurityOrigin::createFromDatabaseIdentifier( |
| 103 webkit_glue::FilePathToWebString(file_path.BaseName())); | 104 webkit_glue::FilePathToWebString(file_path.BaseName())); |
| 104 if (EqualsASCII(web_security_origin.protocol(), chrome::kExtensionScheme)) { | 105 if (!BrowsingDataHelper::IsValidScheme(web_security_origin.protocol())) |
| 105 // Extension state is not considered browsing data. | 106 continue; // Non-websafe state is not considered browsing data. |
| 106 continue; | 107 |
| 107 } | |
| 108 base::PlatformFileInfo file_info; | 108 base::PlatformFileInfo file_info; |
| 109 bool ret = file_util::GetFileInfo(file_path, &file_info); | 109 bool ret = file_util::GetFileInfo(file_path, &file_info); |
| 110 if (ret) { | 110 if (ret) { |
| 111 local_storage_info_.push_back(LocalStorageInfo( | 111 local_storage_info_.push_back(LocalStorageInfo( |
| 112 web_security_origin.protocol().utf8(), | 112 web_security_origin.protocol().utf8(), |
| 113 web_security_origin.host().utf8(), | 113 web_security_origin.host().utf8(), |
| 114 web_security_origin.port(), | 114 web_security_origin.port(), |
| 115 web_security_origin.databaseIdentifier().utf8(), | 115 web_security_origin.databaseIdentifier().utf8(), |
| 116 web_security_origin.toString().utf8(), | 116 web_security_origin.toString().utf8(), |
| 117 file_path, | 117 file_path, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 CannedBrowsingDataLocalStorageHelper* clone = | 151 CannedBrowsingDataLocalStorageHelper* clone = |
| 152 new CannedBrowsingDataLocalStorageHelper(profile_); | 152 new CannedBrowsingDataLocalStorageHelper(profile_); |
| 153 | 153 |
| 154 clone->pending_local_storage_info_ = pending_local_storage_info_; | 154 clone->pending_local_storage_info_ = pending_local_storage_info_; |
| 155 clone->local_storage_info_ = local_storage_info_; | 155 clone->local_storage_info_ = local_storage_info_; |
| 156 return clone; | 156 return clone; |
| 157 } | 157 } |
| 158 | 158 |
| 159 void CannedBrowsingDataLocalStorageHelper::AddLocalStorage( | 159 void CannedBrowsingDataLocalStorageHelper::AddLocalStorage( |
| 160 const GURL& origin) { | 160 const GURL& origin) { |
| 161 pending_local_storage_info_.insert(origin); | 161 if (BrowsingDataHelper::HasValidScheme(origin)) |
| 162 pending_local_storage_info_.insert(origin); |
| 162 } | 163 } |
| 163 | 164 |
| 164 void CannedBrowsingDataLocalStorageHelper::Reset() { | 165 void CannedBrowsingDataLocalStorageHelper::Reset() { |
| 165 local_storage_info_.clear(); | 166 local_storage_info_.clear(); |
| 166 pending_local_storage_info_.clear(); | 167 pending_local_storage_info_.clear(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 bool CannedBrowsingDataLocalStorageHelper::empty() const { | 170 bool CannedBrowsingDataLocalStorageHelper::empty() const { |
| 170 return local_storage_info_.empty() && pending_local_storage_info_.empty(); | 171 return local_storage_info_.empty() && pending_local_storage_info_.empty(); |
| 171 } | 172 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 0, | 220 0, |
| 220 base::Time())); | 221 base::Time())); |
| 221 } | 222 } |
| 222 pending_local_storage_info_.clear(); | 223 pending_local_storage_info_.clear(); |
| 223 | 224 |
| 224 BrowserThread::PostTask( | 225 BrowserThread::PostTask( |
| 225 BrowserThread::UI, FROM_HERE, | 226 BrowserThread::UI, FROM_HERE, |
| 226 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread, | 227 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread, |
| 227 this)); | 228 this)); |
| 228 } | 229 } |
| OLD | NEW |