summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/sync_file_system/local/syncable_file_system_operation.cc3
-rw-r--r--chrome/browser/sync_file_system/sync_file_system_service_factory.cc4
-rw-r--r--chrome/browser/sync_file_system/syncable_file_system_util.cc25
-rw-r--r--chrome/browser/sync_file_system/syncable_file_system_util.h10
4 files changed, 35 insertions, 7 deletions
diff --git a/chrome/browser/sync_file_system/local/syncable_file_system_operation.cc b/chrome/browser/sync_file_system/local/syncable_file_system_operation.cc
index b5a907a889..51a3cbf 100644
--- a/chrome/browser/sync_file_system/local/syncable_file_system_operation.cc
+++ b/chrome/browser/sync_file_system/local/syncable_file_system_operation.cc
@@ -370,7 +370,8 @@ SyncableFileSystemOperation::SyncableFileSystemOperation(
impl_.reset(fileapi::FileSystemOperation::Create(
url_, file_system_context, operation_context.Pass()));
operation_runner_ = backend->sync_context()->operation_runner();
- is_directory_operation_enabled_ = IsSyncFSDirectoryOperationEnabled();
+ is_directory_operation_enabled_ = IsSyncFSDirectoryOperationEnabled(
+ url.origin());
}
void SyncableFileSystemOperation::DidFinish(base::PlatformFileError status) {
diff --git a/chrome/browser/sync_file_system/sync_file_system_service_factory.cc b/chrome/browser/sync_file_system/sync_file_system_service_factory.cc
index 36b8d6f..3a7254e 100644
--- a/chrome/browser/sync_file_system/sync_file_system_service_factory.cc
+++ b/chrome/browser/sync_file_system/sync_file_system_service_factory.cc
@@ -27,7 +27,6 @@ namespace sync_file_system {
namespace {
const char kDisableLastWriteWin[] = "disable-syncfs-last-write-win";
-const char kEnableSyncFileSystemV2[] = "enable-syncfs-v2";
}
// static
@@ -71,8 +70,7 @@ SyncFileSystemServiceFactory::BuildServiceInstanceFor(
scoped_ptr<RemoteFileSyncService> remote_file_service;
if (mock_remote_file_service_) {
remote_file_service = mock_remote_file_service_.Pass();
- } else if (CommandLine::ForCurrentProcess()->HasSwitch(
- kEnableSyncFileSystemV2)) {
+ } else if (sync_file_system::IsV2Enabled()) {
GURL base_drive_url(
google_apis::DriveApiUrlGenerator::kBaseUrlForProduction);
GURL base_download_url(
diff --git a/chrome/browser/sync_file_system/syncable_file_system_util.cc b/chrome/browser/sync_file_system/syncable_file_system_util.cc
index 5e1e3f8..c1c9480 100644
--- a/chrome/browser/sync_file_system/syncable_file_system_util.cc
+++ b/chrome/browser/sync_file_system/syncable_file_system_util.cc
@@ -25,6 +25,9 @@ namespace {
const char kEnableSyncFSDirectoryOperation[] =
"enable-syncfs-directory-operation";
+// A command switch to enable V2 Sync FileSystem.
+const char kEnableSyncFileSystemV2[] = "enable-syncfs-v2";
+
const char kSyncableMountName[] = "syncfs";
const char kSyncableMountNameForInternalSync[] = "syncfs-internal";
@@ -107,9 +110,25 @@ void SetEnableSyncFSDirectoryOperation(bool flag) {
}
bool IsSyncFSDirectoryOperationEnabled() {
+ return IsSyncFSDirectoryOperationEnabled(GURL());
+}
+
+bool IsSyncFSDirectoryOperationEnabled(const GURL& origin) {
return is_directory_operation_enabled ||
CommandLine::ForCurrentProcess()->HasSwitch(
- kEnableSyncFSDirectoryOperation);
+ kEnableSyncFSDirectoryOperation) ||
+ IsV2EnabledForOrigin(origin);
+}
+
+bool IsV2Enabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(kEnableSyncFileSystemV2);
+}
+
+bool IsV2EnabledForOrigin(const GURL& origin) {
+ if (IsV2Enabled())
+ return true;
+ // TODO: Support white listing and/or command line parameter.
+ return false;
}
base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir) {
@@ -119,12 +138,12 @@ base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir) {
}
ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() {
- was_enabled_ = IsSyncFSDirectoryOperationEnabled();
+ was_enabled_ = IsSyncFSDirectoryOperationEnabled(GURL());
SetEnableSyncFSDirectoryOperation(true);
}
ScopedEnableSyncFSDirectoryOperation::~ScopedEnableSyncFSDirectoryOperation() {
- DCHECK(IsSyncFSDirectoryOperationEnabled());
+ DCHECK(IsSyncFSDirectoryOperationEnabled(GURL()));
SetEnableSyncFSDirectoryOperation(was_enabled_);
}
diff --git a/chrome/browser/sync_file_system/syncable_file_system_util.h b/chrome/browser/sync_file_system/syncable_file_system_util.h
index 81df785..7e28607 100644
--- a/chrome/browser/sync_file_system/syncable_file_system_util.h
+++ b/chrome/browser/sync_file_system/syncable_file_system_util.h
@@ -90,6 +90,16 @@ void SetEnableSyncFSDirectoryOperation(bool flag);
// away when we fully support directory operations. (http://crbug.com/161442)
bool IsSyncFSDirectoryOperationEnabled();
+// Checks the same as above, but takes |origin| and sees if directory operation
+// is enabled specifically for this |origin|.
+bool IsSyncFSDirectoryOperationEnabled(const GURL& origin);
+
+// Returns true if V2 is enabled.
+bool IsV2Enabled();
+
+// Returns true if the given |origin| is supposed to run in V2 mode.
+bool IsV2EnabledForOrigin(const GURL& origin);
+
// Returns SyncFileSystem sub-directory path.
base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir);