| 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_,
|
|
|