Commit 676f2677 authored by blundell@chromium.org's avatar blundell@chromium.org

Eliminate GoogleURLTracker's dependence on //chrome-level switches

- switches::kGoogleBaseURL is moved into the Google component

- The information of whether background networking is enabled is now obtained
  from GoogleURLTrackerClient.

BUG=373222
TBR=thakis

Review URL: https://codereview.chromium.org/301383003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274143 0039d316-1c4b-4281-b951-d872f2087c98
parent 939ffed1
......@@ -37,6 +37,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/google/core/browser/google_switches.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/pref_names.h"
#include "components/variations/entropy_provider.h"
......
......@@ -4,10 +4,12 @@
#include "chrome/browser/google/chrome_google_url_tracker_client.h"
#include "base/command_line.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
......@@ -40,6 +42,11 @@ bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() {
content::NotificationService::AllBrowserContextsAndSources());
}
bool ChromeGoogleURLTrackerClient::IsBackgroundNetworkingEnabled() {
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBackgroundNetworking);
}
void ChromeGoogleURLTrackerClient::Observe(
int type,
const content::NotificationSource& source,
......
......@@ -18,6 +18,7 @@ class ChromeGoogleURLTrackerClient : public GoogleURLTrackerClient,
// GoogleURLTrackerClient:
virtual void SetListeningForNavigationStart(bool listen) OVERRIDE;
virtual bool IsListeningForNavigationStart() OVERRIDE;
virtual bool IsBackgroundNetworkingEnabled() OVERRIDE;
private:
// content::NotificationObserver:
......
......@@ -14,8 +14,8 @@
#include "chrome/browser/google/google_url_tracker_navigation_helper.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/google/core/browser/google_switches.h"
#include "components/google/core/browser/google_url_tracker_client.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_manager.h"
......@@ -241,8 +241,7 @@ void GoogleURLTracker::StartFetchIfDesirable() {
// do background networking, we can't do the necessary fetch, and if the user
// specified a Google base URL manually, we shouldn't bother to look up any
// alternatives or offer to switch to them.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBackgroundNetworking) ||
if (!client_->IsBackgroundNetworkingEnabled() ||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kGoogleBaseURL))
return;
......
......@@ -116,6 +116,7 @@ class TestGoogleURLTrackerClient : public GoogleURLTrackerClient {
virtual void SetListeningForNavigationStart(bool listen) OVERRIDE;
virtual bool IsListeningForNavigationStart() OVERRIDE;
virtual bool IsBackgroundNetworkingEnabled() OVERRIDE;
private:
bool observe_nav_start_;
......@@ -138,6 +139,10 @@ bool TestGoogleURLTrackerClient::IsListeningForNavigationStart() {
return observe_nav_start_;
}
bool TestGoogleURLTrackerClient::IsBackgroundNetworkingEnabled() {
return true;
}
// TestGoogleURLTrackerNavigationHelper ---------------------------------------
......
......@@ -15,9 +15,9 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/google/core/browser/google_switches.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
......
......@@ -5,7 +5,7 @@
#include "base/command_line.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/common/chrome_switches.h"
#include "components/google/core/browser/google_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
using google_util::IsGoogleDomainUrl;
......
......@@ -24,6 +24,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/google/core/browser/google_switches.h"
#include "components/variations/entropy_provider.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
......
......@@ -15,6 +15,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
#include "components/google/core/browser/google_switches.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
......
......@@ -16,6 +16,7 @@
#include "chrome/browser/ui/toolbar/toolbar_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/google/core/browser/google_switches.h"
#include "components/variations/entropy_provider.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/common/ssl_status.h"
......
......@@ -710,9 +710,6 @@ const char kForceFirstRun[] = "force-first-run";
// prefixed with the character "t" will be treated as Trigger Variation Ids.
const char kForceVariationIds[] = "force-variation-ids";
// Specifies an alternate URL to use for speaking to Google. Useful for testing.
const char kGoogleBaseURL[] = "google-base-url";
// Specifies a custom name for the GSSAPI library to load.
const char kGSSAPILibraryName[] = "gssapi-library-name";
......
......@@ -204,7 +204,6 @@ extern const char kFlagSwitchesEnd[];
extern const char kForceAppMode[];
extern const char kForceFirstRun[];
extern const char kForceVariationIds[];
extern const char kGoogleBaseURL[];
extern const char kGSSAPILibraryName[];
extern const char kHelp[];
extern const char kHelpShort[];
......
......@@ -16,6 +16,8 @@
'sources': [
'google/core/browser/google_search_metrics.cc',
'google/core/browser/google_search_metrics.h',
'google/core/browser/google_switches.cc',
'google/core/browser/google_switches.h',
'google/core/browser/google_url_tracker_client.cc',
'google/core/browser/google_url_tracker_client.h',
],
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/google/core/browser/google_switches.h"
namespace switches {
// Specifies an alternate URL to use for speaking to Google. Useful for testing.
const char kGoogleBaseURL[] = "google-base-url";
} // namespace switches
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_SWITCHES_H_
#define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_SWITCHES_H_
namespace switches {
// All switches in alphabetical order. The switches should be documented
// alongside the definition of their values in the .cc file.
extern const char kGoogleBaseURL[];
} // namespace switches
#endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_SWITCHES_H_
......@@ -28,6 +28,9 @@ class GoogleURLTrackerClient {
// starts.
virtual bool IsListeningForNavigationStart() = 0;
// Returns whether background networking is enabled.
virtual bool IsBackgroundNetworkingEnabled() = 0;
protected:
GoogleURLTracker* google_url_tracker() { return google_url_tracker_; }
......
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