1 // Copyright 2015 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.
5 #include "components/sync_driver/sync_util.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "components/sync_driver/sync_driver_switches.h"
13 const char* kSyncServerUrl
= "https://clients4.google.com/chrome-sync";
15 const char* kSyncDevServerUrl
= "https://clients4.google.com/chrome-sync/dev";
16 } // namespace internal
18 GURL
GetSyncServiceURL(const base::CommandLine
& command_line
,
19 version_info::Channel channel
) {
20 // By default, dev, canary, and unbranded Chromium users will go to the
21 // development servers. Development servers have more features than standard
22 // sync servers. Users with officially-branded Chrome stable and beta builds
23 // will go to the standard sync servers.
24 GURL
result(internal::kSyncDevServerUrl
);
26 if (channel
== version_info::Channel::STABLE
||
27 channel
== version_info::Channel::BETA
) {
28 result
= GURL(internal::kSyncServerUrl
);
31 // Override the sync server URL from the command-line, if sync server
32 // command-line argument exists.
33 if (command_line
.HasSwitch(switches::kSyncServiceURL
)) {
35 command_line
.GetSwitchValueASCII(switches::kSyncServiceURL
));
37 GURL
custom_sync_url(value
);
38 if (custom_sync_url
.is_valid()) {
39 result
= custom_sync_url
;
41 LOG(WARNING
) << "The following sync URL specified at the command-line "
42 << "is invalid: " << value
;
49 std::string
MakeDesktopUserAgentForSync(version_info::Channel channel
) {
50 std::string system
= "";
53 #elif defined(OS_LINUX)
55 #elif defined(OS_FREEBSD)
57 #elif defined(OS_OPENBSD)
59 #elif defined(OS_MACOSX)
62 return MakeUserAgentForSync(system
, channel
);
65 std::string
MakeUserAgentForSync(const std::string
& system
,
66 version_info::Channel channel
) {
67 std::string user_agent
;
68 user_agent
= "Chrome ";
70 user_agent
+= version_info::GetVersionNumber();
71 user_agent
+= " (" + version_info::GetLastChange() + ")";
72 if (!version_info::IsOfficialBuild()) {
73 user_agent
+= "-devel";
75 user_agent
+= " channel(" + version_info::GetChannelString(channel
) + ")";