1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_util.h" 6 7 #include "base/command_line.h" 8 #include "base/logging.h" 9 #include "chrome/browser/sync_file_system/logger.h" 10 11 namespace sync_file_system { 12 13 namespace { 14 15 // A command-line switch to disable Drive API and to make Sync FileSystem API 16 // work on WAPI (http://crbug.com/234557) 17 // TODO(nhiroki): this command-line switch should be temporary. 18 const char kDisableDriveAPI[] = "disable-drive-api-for-syncfs"; 19 20 bool is_drive_api_disabled = false; 21 22 } // namespace 23 24 void SetDisableDriveAPI(bool flag) { 25 is_drive_api_disabled = flag; 26 } 27 28 bool IsDriveAPIDisabled() { 29 return is_drive_api_disabled || 30 CommandLine::ForCurrentProcess()->HasSwitch(kDisableDriveAPI); 31 } 32 33 ScopedDisableDriveAPI::ScopedDisableDriveAPI() 34 : was_disabled_(IsDriveAPIDisabled()) { 35 SetDisableDriveAPI(true); 36 } 37 38 ScopedDisableDriveAPI::~ScopedDisableDriveAPI() { 39 DCHECK(IsDriveAPIDisabled()); 40 SetDisableDriveAPI(was_disabled_); 41 } 42 43 } // namespace sync_file_system 44