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

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2441203002: Add field trial for the WebAPK server URL (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/chrome_features.h » ('j') | chrome/common/chrome_features.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | chrome/common/chrome_features.h » ('j') | chrome/common/chrome_features.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698