Index: chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc |
diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc |
index f5ea2b65746caa198435d5877430e4fd4c7248cd..7b428153c777a6f0df82ce80a5134fbb2dad08dc 100644 |
--- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc |
+++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc |
@@ -72,13 +72,25 @@ sync_file_system::SyncFileSystemService* GetSyncFileSystemService( |
return service; |
} |
+bool isValidServiceName(const std::string& service_name, std::string* error) { |
kinuko
2013/01/04 10:45:53
naming: please capitalize function names in c++/ch
calvinlo
2013/01/08 03:34:46
Done.
|
+ DCHECK(error); |
+ // TODO(calvinlo): For now only Google Drive cloud service is supported. |
+ if (service_name != std::string(kDriveCloudService)) { |
+ *error = base::StringPrintf(kNotSupportedService, service_name.c_str()); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
} // namespace |
bool SyncFileSystemDeleteFileSystemFunction::RunImpl() { |
- // TODO(calvinlo): Move error code to util function. (http://crbug.com/160496) |
std::string url; |
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
fileapi::FileSystemURL file_system_url((GURL(url))); |
+ if (!isValidServiceName(file_system_url.filesystem_id(), &error_)) { |
+ return false; |
+ } |
scoped_refptr<fileapi::FileSystemContext> file_system_context = |
BrowserContext::GetStoragePartition( |
@@ -124,10 +136,7 @@ void SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem( |
bool SyncFileSystemRequestFileSystemFunction::RunImpl() { |
std::string service_name; |
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &service_name)); |
- |
- // TODO(calvinlo): Move error code to util function. (http://crbug.com/160496) |
- if (service_name != std::string(kDriveCloudService)) { |
- error_ = base::StringPrintf(kNotSupportedService, service_name.c_str()); |
+ if (!isValidServiceName(service_name, &error_)) { |
return false; |
} |
@@ -202,12 +211,7 @@ bool SyncFileSystemGetUsageAndQuotaFunction::RunImpl() { |
std::string url; |
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
fileapi::FileSystemURL file_system_url((GURL(url))); |
- |
- // TODO(calvinlo): For now only gDrive cloud service is supported. |
- // TODO(calvinlo): Move error code to util function. (http://crbug.com/160496) |
- const std::string service_name = file_system_url.filesystem_id(); |
- if (service_name != std::string(kDriveCloudService)) { |
- error_ = base::StringPrintf(kNotSupportedService, service_name.c_str()); |
+ if (!isValidServiceName(file_system_url.filesystem_id(), &error_)) { |
return false; |
} |