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

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: The others. 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/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/child_process_security_policy.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
24 namespace { 25 namespace {
25 26
(...skipping 91 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
129 content::ChildProcessSecurityPolicy* policy =
130 content::ChildProcessSecurityPolicy::GetInstance();
127 while (!(current = origin_enumerator->Next()).is_empty()) { 131 while (!(current = origin_enumerator->Next()).is_empty()) {
128 if (current.SchemeIs(chrome::kExtensionScheme)) { 132 if (!policy->IsWebSafeScheme(current.scheme()))
129 // Extension state is not considered browsing data. 133 continue; // Non-websafe state is not considered browsing data.
130 continue; 134
131 }
132 // We can call these synchronous methods as we've already verified that 135 // We can call these synchronous methods as we've already verified that
133 // we're running on the FILE thread. 136 // we're running on the FILE thread.
134 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current, 137 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current,
135 fileapi::kFileSystemTypePersistent); 138 fileapi::kFileSystemTypePersistent);
136 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current, 139 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current,
137 fileapi::kFileSystemTypeTemporary); 140 fileapi::kFileSystemTypeTemporary);
138 file_system_info_.push_back( 141 file_system_info_.push_back(
139 FileSystemInfo( 142 FileSystemInfo(
140 current, 143 current,
141 origin_enumerator->HasFileSystemType( 144 origin_enumerator->HasFileSystemType(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 file_system->has_temporary = true; 238 file_system->has_temporary = true;
236 file_system->usage_temporary = size; 239 file_system->usage_temporary = size;
237 } 240 }
238 duplicate_origin = true; 241 duplicate_origin = true;
239 break; 242 break;
240 } 243 }
241 } 244 }
242 if (duplicate_origin) 245 if (duplicate_origin)
243 return; 246 return;
244 247
248 content::ChildProcessSecurityPolicy* policy =
249 content::ChildProcessSecurityPolicy::GetInstance();
250 if (!policy->IsWebSafeScheme(origin.scheme()))
251 return; // Non-websafe state is not considered browsing data.
252
245 file_system_info_.push_back(FileSystemInfo( 253 file_system_info_.push_back(FileSystemInfo(
246 origin, 254 origin,
247 (type == fileapi::kFileSystemTypePersistent), 255 (type == fileapi::kFileSystemTypePersistent),
248 (type == fileapi::kFileSystemTypeTemporary), 256 (type == fileapi::kFileSystemTypeTemporary),
249 (type == fileapi::kFileSystemTypePersistent) ? size : 0, 257 (type == fileapi::kFileSystemTypePersistent) ? size : 0,
250 (type == fileapi::kFileSystemTypeTemporary) ? size : 0)); 258 (type == fileapi::kFileSystemTypeTemporary) ? size : 0));
251 } 259 }
252 260
253 void CannedBrowsingDataFileSystemHelper::Reset() { 261 void CannedBrowsingDataFileSystemHelper::Reset() {
254 file_system_info_.clear(); 262 file_system_info_.clear();
(...skipping 23 matching lines...) Expand all
278 completion_callback_.Run(file_system_info_); 286 completion_callback_.Run(file_system_info_);
279 completion_callback_.Reset(); 287 completion_callback_.Reset();
280 } 288 }
281 is_fetching_ = false; 289 is_fetching_ = false;
282 } 290 }
283 291
284 void CannedBrowsingDataFileSystemHelper::CancelNotification() { 292 void CannedBrowsingDataFileSystemHelper::CancelNotification() {
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
286 completion_callback_.Reset(); 294 completion_callback_.Reset();
287 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698