Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / sync / engine / net / url_translator.cc
blobe9cae5a183b0fde1fa354f6174714147438be4de
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.
8 #include "sync/engine/net/url_translator.h"
10 #include "base/basictypes.h"
11 #include "base/port.h"
12 #include "net/base/escape.h"
14 using std::string;
16 namespace syncer {
18 namespace {
19 // Parameters that the server understands. (here, a-Z)
20 const char kParameterClient[] = "client";
21 const char kParameterClientID[] = "client_id";
23 #if defined(GOOGLE_CHROME_BUILD)
24 const char kClientName[] = "Google Chrome";
25 #else
26 const char kClientName[] = "Chromium";
27 #endif // defined(GOOGLE_CHROME_BUILD)
30 // Convenience wrappers around CgiEscapePath().
31 string CgiEscapeString(const char* src) {
32 return CgiEscapeString(string(src));
35 string CgiEscapeString(const string& src) {
36 return net::EscapeUrlEncodedData(src, true);
39 // This method appends the query string to the sync server path.
40 string MakeSyncServerPath(const string& path, const string& query_string) {
41 string result = path;
42 result.append("?");
43 result.append(query_string);
44 return result;
47 string MakeSyncQueryString(const string& client_id) {
48 string query;
49 query += kParameterClient;
50 query += "=" + CgiEscapeString(kClientName);
51 query += "&";
52 query += kParameterClientID;
53 query += "=" + CgiEscapeString(client_id);
54 return query;
57 } // namespace syncer