| 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/drive/drive_api_util.h" | 5 #include "chrome/browser/drive/drive_api_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | |
| 10 #include "base/files/scoped_platform_file_closer.h" | 9 #include "base/files/scoped_platform_file_closer.h" |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/md5.h" | 11 #include "base/md5.h" |
| 13 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 17 #include "base/values.h" |
| 19 #include "chrome/browser/drive/drive_switches.h" | |
| 20 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 21 #include "google_apis/drive/drive_api_parser.h" | 19 #include "google_apis/drive/drive_api_parser.h" |
| 22 #include "google_apis/drive/gdata_wapi_parser.h" | 20 #include "google_apis/drive/gdata_wapi_parser.h" |
| 23 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
| 24 #include "third_party/re2/re2/re2.h" | 22 #include "third_party/re2/re2/re2.h" |
| 25 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 26 | 24 |
| 27 namespace drive { | 25 namespace drive { |
| 28 namespace util { | 26 namespace util { |
| 29 namespace { | 27 namespace { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 140 |
| 143 return resource.Pass(); | 141 return resource.Pass(); |
| 144 } | 142 } |
| 145 | 143 |
| 146 // Returns the argument string. | 144 // Returns the argument string. |
| 147 std::string Identity(const std::string& resource_id) { return resource_id; } | 145 std::string Identity(const std::string& resource_id) { return resource_id; } |
| 148 | 146 |
| 149 } // namespace | 147 } // namespace |
| 150 | 148 |
| 151 | 149 |
| 152 bool IsDriveV2ApiEnabled() { | |
| 153 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 154 | |
| 155 // Enable Drive API v2 by default. | |
| 156 if (!command_line->HasSwitch(switches::kEnableDriveV2Api)) | |
| 157 return true; | |
| 158 | |
| 159 std::string value = | |
| 160 command_line->GetSwitchValueASCII(switches::kEnableDriveV2Api); | |
| 161 StringToLowerASCII(&value); | |
| 162 // The value must be "" or "true" for true, or "false" for false. | |
| 163 DCHECK(value.empty() || value == "true" || value == "false"); | |
| 164 return value != "false"; | |
| 165 } | |
| 166 | |
| 167 std::string EscapeQueryStringValue(const std::string& str) { | 150 std::string EscapeQueryStringValue(const std::string& str) { |
| 168 std::string result; | 151 std::string result; |
| 169 result.reserve(str.size()); | 152 result.reserve(str.size()); |
| 170 for (size_t i = 0; i < str.size(); ++i) { | 153 for (size_t i = 0; i < str.size(); ++i) { |
| 171 if (str[i] == '\\' || str[i] == '\'') { | 154 if (str[i] == '\\' || str[i] == '\'') { |
| 172 result.push_back('\\'); | 155 result.push_back('\\'); |
| 173 } | 156 } |
| 174 result.push_back(str[i]); | 157 result.push_back(str[i]); |
| 175 } | 158 } |
| 176 return result; | 159 return result; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 600 |
| 618 base::MD5Digest digest; | 601 base::MD5Digest digest; |
| 619 base::MD5Final(&digest, &context); | 602 base::MD5Final(&digest, &context); |
| 620 return MD5DigestToBase16(digest); | 603 return MD5DigestToBase16(digest); |
| 621 } | 604 } |
| 622 | 605 |
| 623 const char kWapiRootDirectoryResourceId[] = "folder:root"; | 606 const char kWapiRootDirectoryResourceId[] = "folder:root"; |
| 624 | 607 |
| 625 } // namespace util | 608 } // namespace util |
| 626 } // namespace drive | 609 } // namespace drive |
| OLD | NEW |