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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/google_apis/drive_switches.h" | 9 #include "chrome/browser/google_apis/drive_switches.h" |
10 | 10 |
11 namespace google_apis { | 11 namespace google_apis { |
12 namespace util { | 12 namespace util { |
13 | 13 |
14 bool IsDriveV2ApiEnabled() { | 14 bool IsDriveV2ApiEnabled() { |
15 return CommandLine::ForCurrentProcess()->HasSwitch( | 15 return CommandLine::ForCurrentProcess()->HasSwitch( |
16 switches::kEnableDriveV2Api); | 16 switches::kEnableDriveV2Api); |
17 } | 17 } |
18 | 18 |
19 } // namespace util | 19 } // namespace util |
20 | 20 |
21 namespace drive { | 21 namespace drive { |
22 namespace util { | 22 namespace util { |
23 | 23 |
24 std::string EscapeQueryStringValue(const std::string& str) { | 24 std::string EscapeQueryStringValue(const std::string& str) { |
25 std::string result; | 25 std::string result; |
26 ReplaceChars(str, "'", "\\'", &result); | 26 result.reserve(str.size()); |
| 27 for (size_t i = 0; i < str.size(); ++i) { |
| 28 if (str[i] == '\\' || str[i] == '\'') { |
| 29 result.push_back('\\'); |
| 30 } |
| 31 result.push_back(str[i]); |
| 32 } |
27 return result; | 33 return result; |
28 } | 34 } |
29 | 35 |
30 } // namespace util | 36 } // namespace util |
31 } // namespace drive | 37 } // namespace drive |
32 } // namespace google_apis | 38 } // namespace google_apis |
OLD | NEW |