Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: chrome/common/sync_util.cc

Issue 1269773002: Cleanup VersionInfo after componentization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/sync_util.h ('k') | chrome/common/sync_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/common/sync_util.h" 5 #include "chrome/common/sync_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/common/channel_info.h"
9 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/chrome_version_info.h" 11 #include "components/version_info/version_info.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace { 14 namespace {
14 15
15 // Converts version_info::Channel to string for user-agent string. 16 // Converts version_info::Channel to string for user-agent string.
16 std::string ChannelToString(version_info::Channel channel) { 17 std::string ChannelToString(version_info::Channel channel) {
17 switch (channel) { 18 switch (channel) {
18 case version_info::Channel::UNKNOWN: 19 case version_info::Channel::UNKNOWN:
19 return "unknown"; 20 return "unknown";
20 case version_info::Channel::CANARY: 21 case version_info::Channel::CANARY:
(...skipping 17 matching lines...) Expand all
38 const char* kSyncDevServerUrl = "https://clients4.google.com/chrome-sync/dev"; 39 const char* kSyncDevServerUrl = "https://clients4.google.com/chrome-sync/dev";
39 } // namespace internal 40 } // namespace internal
40 41
41 GURL GetSyncServiceURL(const base::CommandLine& command_line) { 42 GURL GetSyncServiceURL(const base::CommandLine& command_line) {
42 // By default, dev, canary, and unbranded Chromium users will go to the 43 // By default, dev, canary, and unbranded Chromium users will go to the
43 // development servers. Development servers have more features than standard 44 // development servers. Development servers have more features than standard
44 // sync servers. Users with officially-branded Chrome stable and beta builds 45 // sync servers. Users with officially-branded Chrome stable and beta builds
45 // will go to the standard sync servers. 46 // will go to the standard sync servers.
46 GURL result(internal::kSyncDevServerUrl); 47 GURL result(internal::kSyncDevServerUrl);
47 48
48 version_info::Channel channel = chrome::VersionInfo::GetChannel(); 49 version_info::Channel channel = chrome::GetChannel();
49 if (channel == version_info::Channel::STABLE || 50 if (channel == version_info::Channel::STABLE ||
50 channel == version_info::Channel::BETA) { 51 channel == version_info::Channel::BETA) {
51 result = GURL(internal::kSyncServerUrl); 52 result = GURL(internal::kSyncServerUrl);
52 } 53 }
53 54
54 // Override the sync server URL from the command-line, if sync server 55 // Override the sync server URL from the command-line, if sync server
55 // command-line argument exists. 56 // command-line argument exists.
56 if (command_line.HasSwitch(switches::kSyncServiceURL)) { 57 if (command_line.HasSwitch(switches::kSyncServiceURL)) {
57 std::string value( 58 std::string value(
58 command_line.GetSwitchValueASCII(switches::kSyncServiceURL)); 59 command_line.GetSwitchValueASCII(switches::kSyncServiceURL));
59 if (!value.empty()) { 60 if (!value.empty()) {
60 GURL custom_sync_url(value); 61 GURL custom_sync_url(value);
61 if (custom_sync_url.is_valid()) { 62 if (custom_sync_url.is_valid()) {
62 result = custom_sync_url; 63 result = custom_sync_url;
63 } else { 64 } else {
64 LOG(WARNING) << "The following sync URL specified at the command-line " 65 LOG(WARNING) << "The following sync URL specified at the command-line "
65 << "is invalid: " << value; 66 << "is invalid: " << value;
66 } 67 }
67 } 68 }
68 } 69 }
69 return result; 70 return result;
70 } 71 }
71 72
72 std::string MakeDesktopUserAgentForSync( 73 std::string MakeDesktopUserAgentForSync() {
73 const chrome::VersionInfo& version_info) {
74 std::string system = ""; 74 std::string system = "";
75 #if defined(OS_WIN) 75 #if defined(OS_WIN)
76 system = "WIN "; 76 system = "WIN ";
77 #elif defined(OS_LINUX) 77 #elif defined(OS_LINUX)
78 system = "LINUX "; 78 system = "LINUX ";
79 #elif defined(OS_FREEBSD) 79 #elif defined(OS_FREEBSD)
80 system = "FREEBSD "; 80 system = "FREEBSD ";
81 #elif defined(OS_OPENBSD) 81 #elif defined(OS_OPENBSD)
82 system = "OPENBSD "; 82 system = "OPENBSD ";
83 #elif defined(OS_MACOSX) 83 #elif defined(OS_MACOSX)
84 system = "MAC "; 84 system = "MAC ";
85 #endif 85 #endif
86 return MakeUserAgentForSync(version_info, system); 86 return MakeUserAgentForSync(system);
87 } 87 }
88 88
89 std::string MakeUserAgentForSync(const chrome::VersionInfo& version_info, 89 std::string MakeUserAgentForSync(const std::string& system) {
90 const std::string& system) {
91 std::string user_agent; 90 std::string user_agent;
92 user_agent = "Chrome "; 91 user_agent = "Chrome ";
93 user_agent += system; 92 user_agent += system;
94 user_agent += version_info.Version(); 93 user_agent += version_info::GetVersionNumber();
95 user_agent += " (" + version_info.LastChange() + ")"; 94 user_agent += " (" + version_info::GetLastChange() + ")";
96 if (!version_info.IsOfficialBuild()) { 95 if (!version_info::IsOfficialBuild()) {
97 user_agent += "-devel"; 96 user_agent += "-devel";
98 } else { 97 } else {
99 user_agent += 98 user_agent += " channel(" + ChannelToString(chrome::GetChannel()) + ")";
100 " channel(" + ChannelToString(version_info.GetChannel()) + ")";
101 } 99 }
102 return user_agent; 100 return user_agent;
103 } 101 }
OLDNEW
« no previous file with comments | « chrome/common/sync_util.h ('k') | chrome/common/sync_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698