OLD | NEW |
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/google_apis/drive_api_util.h" | 5 #include "chrome/browser/google_apis/drive_api_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/google_apis/drive_switches.h" | 15 #include "chrome/browser/google_apis/drive_switches.h" |
16 | 16 |
17 namespace google_apis { | 17 namespace google_apis { |
18 namespace util { | 18 namespace util { |
19 | 19 |
20 bool IsDriveV2ApiEnabled() { | 20 bool IsDriveV2ApiEnabled() { |
21 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 21 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 22 |
| 23 // Disable Drive API v2 by default. |
| 24 if (!command_line->HasSwitch(switches::kEnableDriveV2Api)) |
| 25 return false; |
| 26 |
22 std::string value = | 27 std::string value = |
23 command_line->GetSwitchValueASCII(switches::kEnableDriveV2Api); | 28 command_line->GetSwitchValueASCII(switches::kEnableDriveV2Api); |
24 StringToLowerASCII(&value); | 29 StringToLowerASCII(&value); |
25 if (value == "false") { | 30 // The value must be "" or "true" for true, or "false" for false. |
26 return false; | 31 DCHECK(value.empty() || value == "true" || value == "false"); |
27 } | 32 return value != "false"; |
28 | |
29 // The value should be empty or "true". | |
30 DCHECK(value.empty() || value == "true"); | |
31 return true; | |
32 } | 33 } |
33 | 34 |
34 } // namespace util | 35 } // namespace util |
35 | 36 |
36 namespace drive { | 37 namespace drive { |
37 namespace util { | 38 namespace util { |
38 | 39 |
39 std::string EscapeQueryStringValue(const std::string& str) { | 40 std::string EscapeQueryStringValue(const std::string& str) { |
40 std::string result; | 41 std::string result; |
41 result.reserve(str.size()); | 42 result.reserve(str.size()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 is_exclusion ? "not " : "", | 111 is_exclusion ? "not " : "", |
111 EscapeQueryStringValue(UTF16ToUTF8(token)).c_str()); | 112 EscapeQueryStringValue(UTF16ToUTF8(token)).c_str()); |
112 } | 113 } |
113 | 114 |
114 return result; | 115 return result; |
115 } | 116 } |
116 | 117 |
117 } // namespace util | 118 } // namespace util |
118 } // namespace drive | 119 } // namespace drive |
119 } // namespace google_apis | 120 } // namespace google_apis |
OLD | NEW |