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

Side by Side Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 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/extensions/api/sync_file_system/sync_file_system_api.h" 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return false; 79 return false;
80 } 80 }
81 return true; 81 return true;
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 85
86 bool SyncFileSystemDeleteFileSystemFunction::RunImpl() { 86 bool SyncFileSystemDeleteFileSystemFunction::RunImpl() {
87 std::string url; 87 std::string url;
88 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 88 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
89 fileapi::FileSystemURL file_system_url((GURL(url)));
90 if (!IsValidServiceName(file_system_url.filesystem_id(), &error_)) {
91 return false;
92 }
93 89
94 scoped_refptr<fileapi::FileSystemContext> file_system_context = 90 scoped_refptr<fileapi::FileSystemContext> file_system_context =
95 BrowserContext::GetStoragePartition( 91 BrowserContext::GetStoragePartition(
96 profile(), 92 profile(),
97 render_view_host()->GetSiteInstance())->GetFileSystemContext(); 93 render_view_host()->GetSiteInstance())->GetFileSystemContext();
94 fileapi::FileSystemURL file_system_url(
95 file_system_context->CrackURL(GURL(url)));
96
97 if (!IsValidServiceName(file_system_url.filesystem_id(), &error_))
98 return false;
99
98 BrowserThread::PostTask( 100 BrowserThread::PostTask(
99 BrowserThread::IO, 101 BrowserThread::IO,
100 FROM_HERE, 102 FROM_HERE,
101 Bind(&fileapi::FileSystemContext::DeleteFileSystem, 103 Bind(&fileapi::FileSystemContext::DeleteFileSystem,
102 file_system_context, 104 file_system_context,
103 source_url().GetOrigin(), 105 source_url().GetOrigin(),
104 file_system_url.type(), 106 file_system_url.type(),
105 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem, 107 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem,
106 this))); 108 this)));
107 return true; 109 return true;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 DictionaryValue* dict = new DictionaryValue(); 204 DictionaryValue* dict = new DictionaryValue();
203 SetResult(dict); 205 SetResult(dict);
204 dict->SetString("name", file_system_name); 206 dict->SetString("name", file_system_name);
205 dict->SetString("root", root_url.spec()); 207 dict->SetString("root", root_url.spec());
206 SendResponse(true); 208 SendResponse(true);
207 } 209 }
208 210
209 bool SyncFileSystemGetUsageAndQuotaFunction::RunImpl() { 211 bool SyncFileSystemGetUsageAndQuotaFunction::RunImpl() {
210 std::string url; 212 std::string url;
211 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 213 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
212 fileapi::FileSystemURL file_system_url((GURL(url))); 214
213 if (!IsValidServiceName(file_system_url.filesystem_id(), &error_)) { 215 scoped_refptr<fileapi::FileSystemContext> file_system_context =
216 BrowserContext::GetStoragePartition(
217 profile(),
218 render_view_host()->GetSiteInstance())->GetFileSystemContext();
219 fileapi::FileSystemURL file_system_url(
220 file_system_context->CrackURL(GURL(url)));
221
222 if (!IsValidServiceName(file_system_url.filesystem_id(), &error_))
214 return false; 223 return false;
215 }
216 224
217 scoped_refptr<quota::QuotaManager> quota_manager = 225 scoped_refptr<quota::QuotaManager> quota_manager =
218 BrowserContext::GetStoragePartition( 226 BrowserContext::GetStoragePartition(
219 profile(), 227 profile(),
220 render_view_host()->GetSiteInstance())->GetQuotaManager(); 228 render_view_host()->GetSiteInstance())->GetQuotaManager();
221 229
222 BrowserThread::PostTask( 230 BrowserThread::PostTask(
223 BrowserThread::IO, 231 BrowserThread::IO,
224 FROM_HERE, 232 FROM_HERE,
225 Bind(&quota::QuotaManager::GetUsageAndQuota, 233 Bind(&quota::QuotaManager::GetUsageAndQuota,
226 quota_manager, 234 quota_manager,
227 source_url().GetOrigin(), 235 source_url().GetOrigin(),
228 fileapi::FileSystemTypeToQuotaStorageType(file_system_url.type()), 236 fileapi::FileSystemTypeToQuotaStorageType(file_system_url.type()),
229 Bind(&SyncFileSystemGetUsageAndQuotaFunction::DidGetUsageAndQuota, 237 Bind(&SyncFileSystemGetUsageAndQuotaFunction::DidGetUsageAndQuota,
230 this))); 238 this)));
231 239
232 return true; 240 return true;
233 } 241 }
234 242
235 bool SyncFileSystemGetFileSyncStatusFunction::RunImpl() { 243 bool SyncFileSystemGetFileSyncStatusFunction::RunImpl() {
236 std::string url; 244 std::string url;
237 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 245 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
238 fileapi::FileSystemURL file_system_url((GURL(url))); 246
247 scoped_refptr<fileapi::FileSystemContext> file_system_context =
248 BrowserContext::GetStoragePartition(
249 profile(),
250 render_view_host()->GetSiteInstance())->GetFileSystemContext();
251 fileapi::FileSystemURL file_system_url(
252 file_system_context->CrackURL(GURL(url)));
239 253
240 SyncFileSystemServiceFactory::GetForProfile(profile())->GetFileSyncStatus( 254 SyncFileSystemServiceFactory::GetForProfile(profile())->GetFileSyncStatus(
241 file_system_url, 255 file_system_url,
242 Bind(&SyncFileSystemGetFileSyncStatusFunction::DidGetFileSyncStatus, 256 Bind(&SyncFileSystemGetFileSyncStatusFunction::DidGetFileSyncStatus,
243 this)); 257 this));
244 return true; 258 return true;
245 } 259 }
246 260
247 void SyncFileSystemGetFileSyncStatusFunction::DidGetFileSyncStatus( 261 void SyncFileSystemGetFileSyncStatusFunction::DidGetFileSyncStatus(
248 const fileapi::SyncStatusCode sync_service_status, 262 const fileapi::SyncStatusCode sync_service_status,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 306 }
293 307
294 api::sync_file_system::StorageInfo info; 308 api::sync_file_system::StorageInfo info;
295 info.usage_bytes = usage; 309 info.usage_bytes = usage;
296 info.quota_bytes = quota; 310 info.quota_bytes = quota;
297 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info); 311 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info);
298 SendResponse(true); 312 SendResponse(true);
299 } 313 }
300 314
301 } // namespace extensions 315 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698