OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 // | |
5 // Contains the definition of a few helper functions used for generating sync | |
6 // URLs. | |
7 | |
8 #include "sync/engine/net/url_translator.h" | |
9 | |
10 #include "net/base/escape.h" | |
11 | |
12 using std::string; | |
13 | |
14 namespace syncer { | |
15 | |
16 namespace { | |
17 // Parameters that the server understands. (here, a-Z) | |
18 const char kParameterClient[] = "client"; | |
19 const char kParameterClientID[] = "client_id"; | |
20 | |
21 #if defined(GOOGLE_CHROME_BUILD) | |
22 const char kClientName[] = "Google Chrome"; | |
23 #else | |
24 const char kClientName[] = "Chromium"; | |
25 #endif // defined(GOOGLE_CHROME_BUILD) | |
26 } // namespace | |
27 | |
28 // Convenience wrappers around CgiEscapePath(). | |
29 string CgiEscapeString(const char* src) { | |
30 return CgiEscapeString(string(src)); | |
31 } | |
32 | |
33 string CgiEscapeString(const string& src) { | |
34 return net::EscapeUrlEncodedData(src, true); | |
35 } | |
36 | |
37 // This method appends the query string to the sync server path. | |
38 string MakeSyncServerPath(const string& path, const string& query_string) { | |
39 string result = path; | |
40 result.append("?"); | |
41 result.append(query_string); | |
42 return result; | |
43 } | |
44 | |
45 string MakeSyncQueryString(const string& client_id) { | |
46 string query; | |
47 query += kParameterClient; | |
48 query += "=" + CgiEscapeString(kClientName); | |
49 query += "&"; | |
50 query += kParameterClientID; | |
51 query += "=" + CgiEscapeString(client_id); | |
52 return query; | |
53 } | |
54 | |
55 } // namespace syncer | |
OLD | NEW |