Chromium Code Reviews| Index: chrome/browser/android/webapk/webapk_installer.cc |
| diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc |
| index 000f98c538baa5e75f3316ae58d3afc63064c3e3..ba1495d8db680ca1e1fec995f5f5c4f48589e7e0 100644 |
| --- a/chrome/browser/android/webapk/webapk_installer.cc |
| +++ b/chrome/browser/android/webapk/webapk_installer.cc |
| @@ -22,7 +22,9 @@ |
| #include "chrome/browser/android/webapk/webapk.pb.h" |
| #include "chrome/browser/android/webapk/webapk_icon_hasher.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/chrome_features.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "components/variations/variations_associated_data.h" |
| #include "components/version_info/version_info.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/common/manifest_util.h" |
| @@ -35,9 +37,12 @@ |
| namespace { |
| // The default WebAPK server URL. |
| -const char kDefaultWebApkServerUrl[] = |
| +const char kDefaultServerUrl[] = |
| "https://webapk.googleapis.com/v1alpha/webApks/?alt=proto"; |
| +// Flag for setting the WebAPK server URL. |
| +const char kServerUrlVariationsParamKey[] = "ServerUrl"; |
| + |
| // The MIME type of the POST data sent to the server. |
| const char kProtoMimeType[] = "application/x-protobuf"; |
| @@ -53,6 +58,17 @@ const int kWorldReadableFilePermission = base::FILE_PERMISSION_READ_BY_USER | |
| base::FILE_PERMISSION_READ_BY_GROUP | |
| base::FILE_PERMISSION_READ_BY_OTHERS; |
| +// Returns the WebAPK server URL based on the command line flags and the |
| +// currently active field trials. |
| +GURL GetServerUrl() { |
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kWebApkServerUrl)) |
| + return GURL(command_line->GetSwitchValueASCII(switches::kWebApkServerUrl)); |
|
dominickn
2016/10/24 00:32:37
For safety, should you test whether this GURL is_v
pkotwicz
2016/10/24 04:33:42
Good point.
UrlFetcher crashes if given an invali
|
| + std::string server_url = variations::GetVariationParamValueByFeature( |
| + features::kWebApk, kServerUrlVariationsParamKey); |
| + return GURL(!server_url.empty() ? server_url : kDefaultServerUrl); |
| +} |
| + |
| // Returns the scope from |info| if it is specified. Otherwise, returns the |
| // default scope. |
| GURL GetScope(const ShortcutInfo& info) { |
| @@ -160,15 +176,11 @@ WebApkInstaller::WebApkInstaller(const ShortcutInfo& shortcut_info, |
| const SkBitmap& shortcut_icon) |
| : shortcut_info_(shortcut_info), |
| shortcut_icon_(shortcut_icon), |
| + server_url_(GetServerUrl()), |
| webapk_download_url_timeout_ms_(kWebApkDownloadUrlTimeoutMs), |
| download_timeout_ms_(kDownloadTimeoutMs), |
| task_type_(UNDEFINED), |
| weak_ptr_factory_(this) { |
| - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| - server_url_ = |
| - GURL(command_line->HasSwitch(switches::kWebApkServerUrl) |
| - ? command_line->GetSwitchValueASCII(switches::kWebApkServerUrl) |
| - : kDefaultWebApkServerUrl); |
| CreateJavaRef(); |
| } |