diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-01 20:10:32 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-01 20:10:32 +0000 |
commit | 676f267748b546302c0e927df555892e5142e9d6 (patch) | |
tree | ef425c6f4391444550e608944af7d2e0537dec2e | |
parent | 939ffed1297fd1ce468ea28c3580cf1a3be01b43 (diff) | |
download | chromium_src-676f267748b546302c0e927df555892e5142e9d6.zip chromium_src-676f267748b546302c0e927df555892e5142e9d6.tar.gz chromium_src-676f267748b546302c0e927df555892e5142e9d6.tar.bz2 |
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
-rw-r--r-- | chrome/browser/autocomplete/search_provider_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/google/chrome_google_url_tracker_client.cc | 7 | ||||
-rw-r--r-- | chrome/browser/google/chrome_google_url_tracker_client.h | 1 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker.cc | 5 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/google/google_util.cc | 2 | ||||
-rw-r--r-- | chrome/browser/google/google_util_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/search/search_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/toolbar/toolbar_model_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | components/google.gypi | 2 | ||||
-rw-r--r-- | components/google/core/browser/google_switches.cc | 12 | ||||
-rw-r--r-- | components/google/core/browser/google_switches.h | 16 | ||||
-rw-r--r-- | components/google/core/browser/google_url_tracker_client.h | 3 |
16 files changed, 54 insertions, 9 deletions
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 7193a0c..f1b459e 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -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" diff --git a/chrome/browser/google/chrome_google_url_tracker_client.cc b/chrome/browser/google/chrome_google_url_tracker_client.cc index 5416669..5068afe 100644 --- a/chrome/browser/google/chrome_google_url_tracker_client.cc +++ b/chrome/browser/google/chrome_google_url_tracker_client.cc @@ -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, diff --git a/chrome/browser/google/chrome_google_url_tracker_client.h b/chrome/browser/google/chrome_google_url_tracker_client.h index 89215b2..58fdcc9 100644 --- a/chrome/browser/google/chrome_google_url_tracker_client.h +++ b/chrome/browser/google/chrome_google_url_tracker_client.h @@ -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: diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index f4c510f..88233ac 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -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; diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index cd6a3c4..81f9e82 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -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 --------------------------------------- diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc index fbb39f7..6d1b3ce 100644 --- a/chrome/browser/google/google_util.cc +++ b/chrome/browser/google/google_util.cc @@ -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" diff --git a/chrome/browser/google/google_util_unittest.cc b/chrome/browser/google/google_util_unittest.cc index 83794e2..8b8b99b 100644 --- a/chrome/browser/google/google_util_unittest.cc +++ b/chrome/browser/google/google_util_unittest.cc @@ -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; diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc index e8b0e46..6e6b6dc 100644 --- a/chrome/browser/search/search_unittest.cc +++ b/chrome/browser/search/search_unittest.cc @@ -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" diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc index f58fa97..2b78f17 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc +++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc @@ -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" diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc index c178854..80ad61f 100644 --- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc +++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc @@ -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" diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index c754b13..6ec6f25 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -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"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index a6689d5..6902184 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -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[]; diff --git a/components/google.gypi b/components/google.gypi index ea4c75d..69c43ff 100644 --- a/components/google.gypi +++ b/components/google.gypi @@ -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', ], diff --git a/components/google/core/browser/google_switches.cc b/components/google/core/browser/google_switches.cc new file mode 100644 index 0000000..2daf836 --- /dev/null +++ b/components/google/core/browser/google_switches.cc @@ -0,0 +1,12 @@ +// 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 diff --git a/components/google/core/browser/google_switches.h b/components/google/core/browser/google_switches.h new file mode 100644 index 0000000..eadc91a --- /dev/null +++ b/components/google/core/browser/google_switches.h @@ -0,0 +1,16 @@ +// 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_ diff --git a/components/google/core/browser/google_url_tracker_client.h b/components/google/core/browser/google_url_tracker_client.h index ab9e271..5cc4f98 100644 --- a/components/google/core/browser/google_url_tracker_client.h +++ b/components/google/core/browser/google_url_tracker_client.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_; } |