Commit 84091f47 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Get Sync URL from GaiaConfig

The commandline param --gaia-config allows specifying a json file that
overrides various Gaia-related URLs. This CL adds support for
overriding the Sync URL via the same file.

Bug: 1129493
Change-Id: Ieb1fee4b32f247acb69fde659c2c0c9564bcb130
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418334Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808498}
parent 82ad19e1
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/strings/stringize_macros.h" #include "base/strings/stringize_macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/sync/base/sync_base_switches.h" #include "components/sync/base/sync_base_switches.h"
#include "google_apis/gaia/gaia_config.h"
#include "ui/base/device_form_factor.h" #include "ui/base/device_form_factor.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -75,33 +76,47 @@ std::string FormatUserAgentForSync(const std::string& system, ...@@ -75,33 +76,47 @@ std::string FormatUserAgentForSync(const std::string& system,
GURL GetSyncServiceURL(const base::CommandLine& command_line, GURL GetSyncServiceURL(const base::CommandLine& command_line,
version_info::Channel channel) { version_info::Channel channel) {
// By default, dev, canary, and unbranded Chromium users will go to the // Priorities for determining the sync URL:
// development servers. Development servers have more features than standard // 1. Explicitly specified --sync-url
// sync servers. Users with officially-branded Chrome stable and beta builds // 2. Specified as part of the --gaia-config
// will go to the standard sync servers. // 3. Default URL (different for Stable/Beta vs. Dev/Canary/unbranded)
GURL result(internal::kSyncDevServerUrl);
if (channel == version_info::Channel::STABLE || // 1. Get the sync server URL from the --sync-url command-line param, if
channel == version_info::Channel::BETA) { // specified.
result = GURL(internal::kSyncServerUrl);
}
// Override the sync server URL from the command-line, if sync server
// command-line argument exists.
if (command_line.HasSwitch(switches::kSyncServiceURL)) { if (command_line.HasSwitch(switches::kSyncServiceURL)) {
std::string value( std::string value(
command_line.GetSwitchValueASCII(switches::kSyncServiceURL)); command_line.GetSwitchValueASCII(switches::kSyncServiceURL));
if (!value.empty()) { if (!value.empty()) {
GURL custom_sync_url(value); GURL custom_sync_url(value);
if (custom_sync_url.is_valid()) { if (custom_sync_url.is_valid()) {
result = custom_sync_url; return custom_sync_url;
} else { } else {
LOG(WARNING) << "The following sync URL specified at the command-line " LOG(WARNING) << "The following sync URL specified at the command-line "
<< "is invalid: " << value; << "is invalid: " << value;
} }
} }
} }
return result;
// 2. Get the sync server URL from the --gaia-config, if the config exists and
// contains a sync URL.
GaiaConfig* gaia_config = GaiaConfig::GetInstance();
if (gaia_config) {
GURL url;
if (gaia_config->GetURLIfExists("sync_url", &url)) {
return url;
}
}
// 3. By default, dev, canary, and unbranded Chromium users will go to the
// development servers. Development servers have more features than standard
// sync servers. Users with officially-branded Chrome stable and beta builds
// will go to the standard sync servers.
if (channel == version_info::Channel::STABLE ||
channel == version_info::Channel::BETA) {
return GURL(internal::kSyncServerUrl);
}
return GURL(internal::kSyncDevServerUrl);
} }
std::string MakeUserAgentForSync(version_info::Channel channel) { std::string MakeUserAgentForSync(version_info::Channel channel) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment