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

Unified Diff: chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc

Issue 2877763002: OneGoogleBarFetcher: replace cmdline flags with feature params (Closed)
Patch Set: rebase Created 3 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc
diff --git a/chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc b/chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc
index f5f3a58be9699f46f60b9d198158596fee5629b3..41cdec8f7afde09915d29b5f6028ec1fdb87c0cb 100644
--- a/chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc
+++ b/chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.cc
@@ -8,15 +8,16 @@
#include <utility>
#include "base/callback.h"
-#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/field_trial_params.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_data.h"
#include "chrome/common/chrome_content_client.h"
+#include "chrome/common/chrome_features.h"
#include "components/google/core/browser/google_url_tracker.h"
#include "components/safe_json/safe_json_parser.h"
#include "components/signin/core/browser/access_token_fetcher.h"
@@ -191,11 +192,12 @@ void OneGoogleBarFetcherImpl::AuthenticatedURLFetcher::Start() {
GURL OneGoogleBarFetcherImpl::AuthenticatedURLFetcher::GetApiUrl(
bool use_oauth) const {
- std::string api_url(kApiUrl);
- // TODO(treib): Attach to feature instead of cmdline.
- base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- if (cmdline->HasSwitch("one-google-api-url"))
- api_url = cmdline->GetSwitchValueASCII("one-google-api-url");
+ std::string api_url = base::GetFieldTrialParamValueByFeature(
+ features::kOneGoogleBarOnLocalNtp, "one-google-api-url");
+ if (api_url.empty()) {
+ api_url = kApiUrl;
+ }
+
// Append the API key only for unauthenticated requests.
if (!use_oauth) {
api_url +=
@@ -207,10 +209,11 @@ GURL OneGoogleBarFetcherImpl::AuthenticatedURLFetcher::GetApiUrl(
std::string OneGoogleBarFetcherImpl::AuthenticatedURLFetcher::GetRequestBody()
const {
- // TODO(treib): Attach to feature instead of cmdline.
- base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- if (cmdline->HasSwitch("one-google-bar-options"))
- return cmdline->GetSwitchValueASCII("one-google-bar-options");
+ std::string override_options = base::GetFieldTrialParamValueByFeature(
+ features::kOneGoogleBarOnLocalNtp, "one-google-bar-options");
+ if (!override_options.empty()) {
+ return override_options;
+ }
base::DictionaryValue dict;
dict.SetInteger("subproduct", 243);
@@ -303,8 +306,9 @@ void OneGoogleBarFetcherImpl::Fetch(OneGoogleCallback callback) {
void OneGoogleBarFetcherImpl::IssueRequestIfNoneOngoing() {
// If there is an ongoing request, let it complete.
- if (pending_request_.get())
+ if (pending_request_.get()) {
return;
+ }
pending_request_ = base::MakeUnique<AuthenticatedURLFetcher>(
signin_manager_, token_service_, request_context_,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698