Commit 5ebbd153 authored by Jon Mann's avatar Jon Mann Committed by Commit Bot

[AndroidSms] Allow custom domains to be configured at runtime.

This allows users to configure a custom domain through the UI at
chrome://flags allowing for easier development and testing. For
simplicity, this also updates the previous command line flags to use
custom app/install urls to a new flag: --custom-android-messages-domain
which accepts a single domain and appends the correct suffixes in code.

Bug: 1055472
Change-Id: Ie3b1a69c258642fbe7e7f579cbf7f0b221d96f95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2154101
Commit-Queue: Jon Mann <jonmann@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760229}
parent ae927a5c
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "cc/base/features.h" #include "cc/base/features.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "chrome/browser/browser_features.h" #include "chrome/browser/browser_features.h"
#include "chrome/browser/chromeos/android_sms/android_sms_switches.h"
#include "chrome/browser/flag_descriptions.h" #include "chrome/browser/flag_descriptions.h"
#include "chrome/browser/net/stub_resolver_config_reader.h" #include "chrome/browser/net/stub_resolver_config_reader.h"
#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/net/system_network_context_manager.h"
...@@ -2076,6 +2077,10 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2076,6 +2077,10 @@ const FeatureEntry kFeatureEntries[] = {
{"use_messages_staging_url", flag_descriptions::kUseMessagesStagingUrlName, {"use_messages_staging_url", flag_descriptions::kUseMessagesStagingUrlName,
flag_descriptions::kUseMessagesStagingUrlDescription, kOsCrOS, flag_descriptions::kUseMessagesStagingUrlDescription, kOsCrOS,
FEATURE_VALUE_TYPE(chromeos::features::kUseMessagesStagingUrl)}, FEATURE_VALUE_TYPE(chromeos::features::kUseMessagesStagingUrl)},
{"use-custom-messages-domain",
flag_descriptions::kUseCustomMessagesDomainName,
flag_descriptions::kUseCustomMessagesDomainDescription, kOsCrOS,
ORIGIN_LIST_VALUE_TYPE(switches::kCustomAndroidMessagesDomain, "")},
{"disable-cancel-all-touches", {"disable-cancel-all-touches",
flag_descriptions::kDisableCancelAllTouchesName, flag_descriptions::kDisableCancelAllTouchesName,
flag_descriptions::kDisableCancelAllTouchesDescription, kOsCrOS, flag_descriptions::kDisableCancelAllTouchesDescription, kOsCrOS,
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
namespace switches { namespace switches {
const char kAlternateAndroidMessagesUrl[] = "alternate-android-messages-url"; const char kCustomAndroidMessagesDomain[] = "custom-android-messages-domain";
const char kAlternateAndroidMessagesInstallUrl[] =
"alternate-android-messages-install-url";
} // namespace switches } // namespace switches
...@@ -8,12 +8,9 @@ ...@@ -8,12 +8,9 @@
namespace switches { namespace switches {
// When specified with a url string as parameter, the given url overrides the // When specified with a url string as parameter, the given url overrides the
// Android Messages for Web url used by AndroidSmsService. // Android Messages for Web PWA installation and app urls using a base of the
extern const char kAlternateAndroidMessagesUrl[]; // given domain with approrpiate suffixes.
extern const char kCustomAndroidMessagesDomain[];
// When specified with a url string as parameter, the given url overrides the
// Android Messages for Web PWA installation url used by AndroidSmsService.
extern const char kAlternateAndroidMessagesInstallUrl[];
} // namespace switches } // namespace switches
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/strcat.h"
#include "chrome/browser/chromeos/android_sms/android_sms_switches.h" #include "chrome/browser/chromeos/android_sms/android_sms_switches.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -28,6 +29,25 @@ const char kStagingAppUrl[] = "https://messages-web.sandbox.google.com/web/"; ...@@ -28,6 +29,25 @@ const char kStagingAppUrl[] = "https://messages-web.sandbox.google.com/web/";
const char kStagingInstallUrl[] = const char kStagingInstallUrl[] =
"https://messages-web.sandbox.google.com/web/authentication"; "https://messages-web.sandbox.google.com/web/authentication";
GURL GetCustomDomain(bool use_install_url) {
std::string custom_domain =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kCustomAndroidMessagesDomain);
if (custom_domain.empty()) {
return GURL::EmptyGURL();
}
GURL url(custom_domain);
GURL::Replacements path;
if (use_install_url) {
path.SetPathStr("/web/authentication");
} else { // App url.
path.SetPathStr("/web/");
}
return url.ReplaceComponents(path);
}
} // namespace } // namespace
std::ostream& operator<<(std::ostream& stream, const PwaDomain& pwa_domain) { std::ostream& operator<<(std::ostream& stream, const PwaDomain& pwa_domain) {
...@@ -53,21 +73,11 @@ PwaDomain GetPreferredPwaDomain() { ...@@ -53,21 +73,11 @@ PwaDomain GetPreferredPwaDomain() {
} }
GURL GetAndroidMessagesURL(bool use_install_url, PwaDomain pwa_domain) { GURL GetAndroidMessagesURL(bool use_install_url, PwaDomain pwa_domain) {
// If present, use commandline override for the preferred domain. // If present, use custom override for the preferred domain.
if (pwa_domain == GetPreferredPwaDomain()) { if (pwa_domain == GetPreferredPwaDomain()) {
std::string url_from_command_line_arg; GURL custom_url = GetCustomDomain(use_install_url);
if (use_install_url) { if (!custom_url.is_empty())
url_from_command_line_arg = return custom_url;
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAlternateAndroidMessagesInstallUrl);
} else {
url_from_command_line_arg =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAlternateAndroidMessagesUrl);
}
if (!url_from_command_line_arg.empty())
return GURL(url_from_command_line_arg);
} }
switch (pwa_domain) { switch (pwa_domain) {
......
...@@ -4065,6 +4065,12 @@ ...@@ -4065,6 +4065,12 @@
// available. // available.
"expiry_milestone": -1 "expiry_milestone": -1
}, },
{
"name": "use-custom-messages-domain",
"owners": [ "azeemarshad", "jonmann", "vecore" ],
// This flag is used for QA and development.
"expiry_milestone": -1
},
{ {
"name": "use-fake-device-for-media-stream", "name": "use-fake-device-for-media-stream",
"owners": [ "mcasas", "chromeos-gfx@google.com" ], "owners": [ "mcasas", "chromeos-gfx@google.com" ],
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
"unsafely-treat-insecure-origin-as-secure", "unsafely-treat-insecure-origin-as-secure",
"update-menu-item-custom-summary", "update-menu-item-custom-summary",
"use-angle", "use-angle",
"use-custom-messages-domain",
"use-fake-device-for-media-stream", "use-fake-device-for-media-stream",
"use_messages_staging_url", "use_messages_staging_url",
"use-sync-sandbox", "use-sync-sandbox",
......
...@@ -110,6 +110,11 @@ const char kUseMessagesStagingUrlDescription[] = ...@@ -110,6 +110,11 @@ const char kUseMessagesStagingUrlDescription[] =
"Use the staging server as part of the \"Messages\" feature under " "Use the staging server as part of the \"Messages\" feature under "
"\"Connected Devices\" settings."; "\"Connected Devices\" settings.";
const char kUseCustomMessagesDomainName[] = "Use custom Messages domain";
const char kUseCustomMessagesDomainDescription[] =
"Use a custom URL as part of the \"Messages\" feature under "
"\"Connected Devices\" settings.";
const char kAndroidPictureInPictureAPIName[] = const char kAndroidPictureInPictureAPIName[] =
"Picture-in-Picture Web API for Android"; "Picture-in-Picture Web API for Android";
const char kAndroidPictureInPictureAPIDescription[] = const char kAndroidPictureInPictureAPIDescription[] =
......
...@@ -93,6 +93,9 @@ extern const char kUpdatedCellularActivationUiDescription[]; ...@@ -93,6 +93,9 @@ extern const char kUpdatedCellularActivationUiDescription[];
extern const char kUseMessagesStagingUrlName[]; extern const char kUseMessagesStagingUrlName[];
extern const char kUseMessagesStagingUrlDescription[]; extern const char kUseMessagesStagingUrlDescription[];
extern const char kUseCustomMessagesDomainName[];
extern const char kUseCustomMessagesDomainDescription[];
extern const char kAndroidPictureInPictureAPIName[]; extern const char kAndroidPictureInPictureAPIName[];
extern const char kAndroidPictureInPictureAPIDescription[]; extern const char kAndroidPictureInPictureAPIDescription[];
......
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