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

Unified Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc

Issue 11659005: Added common function to check for supported syncable file system service names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed TODO 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fe7e9a3d211796c6ed48027df2e141672ac14eba 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,24 @@ sync_file_system::SyncFileSystemService* GetSyncFileSystemService(
return service;
}
+bool IsValidServiceName(const std::string& service_name, std::string* error) {
+ DCHECK(error);
+ 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 +135,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 +210,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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698