OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Contains the definition of a few helper functions used for generating sync | 5 // Contains the definition of a few helper functions used for generating sync |
6 // URLs. | 6 // URLs. |
7 | 7 |
8 #include "chrome/browser/sync/engine/net/url_translator.h" | 8 #include "chrome/browser/sync/engine/net/url_translator.h" |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/port.h" | 11 #include "base/port.h" |
12 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
13 | 13 |
14 using std::string; | 14 using std::string; |
15 | 15 |
16 namespace browser_sync { | 16 namespace browser_sync { |
17 | 17 |
18 namespace { | 18 namespace { |
19 // Parameters that the server understands. (here, a-Z) | 19 // Parameters that the server understands. (here, a-Z) |
20 const char kParameterAuthToken[] = "auth"; | 20 const char kParameterAuthToken[] = "auth"; |
21 const char kParameterClientID[] = "client_id"; | 21 const char kParameterClientID[] = "client_id"; |
22 } | 22 } |
23 | 23 |
24 // Convenience wrappers around CgiEscapePath(). | 24 // Convenience wrappers around CgiEscapePath(). |
25 string CgiEscapeString(const char* src) { | 25 string CgiEscapeString(const char* src) { |
26 return CgiEscapeString(string(src)); | 26 return CgiEscapeString(string(src)); |
27 } | 27 } |
28 | 28 |
29 string CgiEscapeString(const string& src) { | 29 string CgiEscapeString(const string& src) { |
30 return EscapeUrlEncodedData(src); | 30 return EscapeUrlEncodedData(src, true); |
31 } | 31 } |
32 | 32 |
33 // This method appends the query string to the sync server path. | 33 // This method appends the query string to the sync server path. |
34 string MakeSyncServerPath(const string& path, const string& query_string) { | 34 string MakeSyncServerPath(const string& path, const string& query_string) { |
35 string result = path; | 35 string result = path; |
36 result.append("?"); | 36 result.append("?"); |
37 result.append(query_string); | 37 result.append(query_string); |
38 return result; | 38 return result; |
39 } | 39 } |
40 | 40 |
41 string MakeSyncQueryString(const string& client_id) { | 41 string MakeSyncQueryString(const string& client_id) { |
42 string query; | 42 string query; |
43 query += kParameterClientID; | 43 query += kParameterClientID; |
44 query += "=" + CgiEscapeString(client_id); | 44 query += "=" + CgiEscapeString(client_id); |
45 return query; | 45 return query; |
46 } | 46 } |
47 | 47 |
48 } // namespace browser_sync | 48 } // namespace browser_sync |
OLD | NEW |