Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: chrome/browser/browsing_data_file_system_helper.cc

Issue 9958107: Limiting the "Cookies and site data" form to "web safe" schemes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: License. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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_file_system_helper.h" 5 #include "chrome/browser/browsing_data_file_system_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/browsing_data_helper.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "webkit/fileapi/file_system_context.h" 17 #include "webkit/fileapi/file_system_context.h"
17 #include "webkit/fileapi/file_system_quota_util.h" 18 #include "webkit/fileapi/file_system_quota_util.h"
18 #include "webkit/fileapi/file_system_types.h" 19 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/fileapi/sandbox_mount_point_provider.h" 20 #include "webkit/fileapi/sandbox_mount_point_provider.h"
20 21
21 using content::BrowserContext; 22 using content::BrowserContext;
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 origin_enumerator(BrowserContext::GetFileSystemContext(profile_)-> 118 origin_enumerator(BrowserContext::GetFileSystemContext(profile_)->
118 sandbox_provider()->CreateOriginEnumerator()); 119 sandbox_provider()->CreateOriginEnumerator());
119 120
120 // We don't own this pointer; it's a magic singleton generated by the 121 // We don't own this pointer; it's a magic singleton generated by the
121 // profile's FileSystemContext. Deleting it would be a bad idea. 122 // profile's FileSystemContext. Deleting it would be a bad idea.
122 fileapi::FileSystemQuotaUtil* quota_util = 123 fileapi::FileSystemQuotaUtil* quota_util =
123 BrowserContext::GetFileSystemContext(profile_)->GetQuotaUtil( 124 BrowserContext::GetFileSystemContext(profile_)->GetQuotaUtil(
124 fileapi::kFileSystemTypeTemporary); 125 fileapi::kFileSystemTypeTemporary);
125 126
126 GURL current; 127 GURL current;
128
127 while (!(current = origin_enumerator->Next()).is_empty()) { 129 while (!(current = origin_enumerator->Next()).is_empty()) {
128 if (current.SchemeIs(chrome::kExtensionScheme)) { 130 if (!BrowsingDataHelper::HasValidScheme(current))
129 // Extension state is not considered browsing data. 131 continue; // Non-websafe state is not considered browsing data.
130 continue; 132
131 }
132 // We can call these synchronous methods as we've already verified that 133 // We can call these synchronous methods as we've already verified that
133 // we're running on the FILE thread. 134 // we're running on the FILE thread.
134 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current, 135 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current,
135 fileapi::kFileSystemTypePersistent); 136 fileapi::kFileSystemTypePersistent);
136 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current, 137 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current,
137 fileapi::kFileSystemTypeTemporary); 138 fileapi::kFileSystemTypeTemporary);
138 file_system_info_.push_back( 139 file_system_info_.push_back(
139 FileSystemInfo( 140 FileSystemInfo(
140 current, 141 current,
141 origin_enumerator->HasFileSystemType( 142 origin_enumerator->HasFileSystemType(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 file_system->has_temporary = true; 236 file_system->has_temporary = true;
236 file_system->usage_temporary = size; 237 file_system->usage_temporary = size;
237 } 238 }
238 duplicate_origin = true; 239 duplicate_origin = true;
239 break; 240 break;
240 } 241 }
241 } 242 }
242 if (duplicate_origin) 243 if (duplicate_origin)
243 return; 244 return;
244 245
246 if (!BrowsingDataHelper::HasValidScheme(origin))
247 return; // Non-websafe state is not considered browsing data.
248
245 file_system_info_.push_back(FileSystemInfo( 249 file_system_info_.push_back(FileSystemInfo(
246 origin, 250 origin,
247 (type == fileapi::kFileSystemTypePersistent), 251 (type == fileapi::kFileSystemTypePersistent),
248 (type == fileapi::kFileSystemTypeTemporary), 252 (type == fileapi::kFileSystemTypeTemporary),
249 (type == fileapi::kFileSystemTypePersistent) ? size : 0, 253 (type == fileapi::kFileSystemTypePersistent) ? size : 0,
250 (type == fileapi::kFileSystemTypeTemporary) ? size : 0)); 254 (type == fileapi::kFileSystemTypeTemporary) ? size : 0));
251 } 255 }
252 256
253 void CannedBrowsingDataFileSystemHelper::Reset() { 257 void CannedBrowsingDataFileSystemHelper::Reset() {
254 file_system_info_.clear(); 258 file_system_info_.clear();
(...skipping 23 matching lines...) Expand all
278 completion_callback_.Run(file_system_info_); 282 completion_callback_.Run(file_system_info_);
279 completion_callback_.Reset(); 283 completion_callback_.Reset();
280 } 284 }
281 is_fetching_ = false; 285 is_fetching_ = false;
282 } 286 }
283 287
284 void CannedBrowsingDataFileSystemHelper::CancelNotification() { 288 void CannedBrowsingDataFileSystemHelper::CancelNotification() {
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
286 completion_callback_.Reset(); 290 completion_callback_.Reset();
287 } 291 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_database_helper_unittest.cc ('k') | chrome/browser/browsing_data_file_system_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698