From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Mon, 12 Feb 2018 21:36:33 +0100 Subject: ungoogled-chromium: no special hosts/domains Disables various detections of Google hosts and functionality specific to them Disable domain reliability detection License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- chrome/browser/BUILD.gn | 8 - .../android/metrics/uma_session_stats.cc | 10 - .../android/signin/signin_manager_android.cc | 27 +- chrome/browser/browser_process_impl.cc | 1 - .../browser/chrome_content_browser_client.cc | 35 +- .../domain_reliability/service_factory.cc | 33 +- chrome/browser/extensions/BUILD.gn | 1 - .../log_sources/chrome_internal_log_source.cc | 5 - chrome/browser/first_run/first_run.cc | 9 - chrome/browser/google/BUILD.gn | 4 +- .../long_screenshots_tab_service.cc | 22 -- .../metrics/chrome_metrics_service_client.cc | 2 +- .../chrome_metrics_services_manager_client.cc | 5 +- .../metrics/metrics_reporting_state.cc | 78 +---- .../net/system_network_context_manager.cc | 1 - .../modules/recipes/recipes_service.cc | 3 +- .../one_google_bar_loader_impl.cc | 3 +- .../new_tab_page/promos/promo_service.cc | 6 +- .../from_gws_page_load_metrics_observer.cc | 6 +- .../page_load_metrics_initialize.cc | 2 - chrome/browser/safe_browsing/BUILD.gn | 1 - .../ui_thread_search_terms_data.cc | 4 - chrome/browser/ui/BUILD.gn | 1 - .../ui/webui/new_tab_page/new_tab_page_ui.cc | 5 - .../webui/settings/reset_settings_handler.cc | 1 - .../upgrade_detector/upgrade_detector_impl.cc | 2 +- chrome/common/BUILD.gn | 2 - .../google_accounts_private_api_util.cc | 1 + .../url_loader_throttle_provider_impl.cc | 11 - chrome/test/BUILD.gn | 1 - components/domain_reliability/BUILD.gn | 5 +- .../domain_reliability/bake_in_configs.py | 2 +- .../domain_reliability/context_manager.cc | 22 +- .../domain_reliability/google_configs.cc | 10 +- .../domain_reliability/google_configs.h | 8 +- components/domain_reliability/monitor.cc | 8 - components/domain_reliability/uploader.cc | 2 +- components/google/core/common/google_util.cc | 313 +----------------- components/google/core/common/google_util.h | 15 +- .../browser/page_load_metrics_util.cc | 4 +- .../common/page_load_metrics_util.cc | 33 +- .../search_engines/search_engine_utils.cc | 1 + .../search_engines/search_terms_data.cc | 4 +- components/search_engines/template_url.cc | 6 +- components/search_provider_logos/BUILD.gn | 2 - .../logo_service_impl.cc | 16 +- components/url_matcher/url_util.cc | 83 ----- content/common/features.cc | 4 +- content/public/common/content_features.cc | 6 +- net/base/url_util.cc | 21 -- services/network/network_context.cc | 2 +- 51 files changed, 60 insertions(+), 797 deletions(-) diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -1039,10 +1039,6 @@ static_library("browser") { "page_load_metrics/observers/foreground_duration_ukm_observer.h", "page_load_metrics/observers/formfill_page_load_metrics_observer.cc", "page_load_metrics/observers/formfill_page_load_metrics_observer.h", - "page_load_metrics/observers/from_gws_page_load_metrics_observer.cc", - "page_load_metrics/observers/from_gws_page_load_metrics_observer.h", - "page_load_metrics/observers/gws_page_load_metrics_observer.cc", - "page_load_metrics/observers/gws_page_load_metrics_observer.h", "page_load_metrics/observers/histogram_suffixes.cc", "page_load_metrics/observers/histogram_suffixes.h", "page_load_metrics/observers/https_engagement_metrics/https_engagement_page_load_metrics_observer.cc", @@ -1989,7 +1985,6 @@ static_library("browser") { "//chrome/browser/autofill", "//chrome/browser/devtools", "//chrome/browser/favicon", - "//chrome/browser/google", "//chrome/browser/profiling_host", # TODO(crbug.com/1335199): break this dep when favicon is in its own target @@ -2013,7 +2008,6 @@ static_library("browser") { public_deps = [ "//base", - "//chrome/browser/google", "//chrome/browser/headless", "//chrome/common", "//chrome/common:buildflags", @@ -7789,8 +7783,6 @@ static_library("browser") { "supervised_user/kids_chrome_management/kids_chrome_management_client_factory.h", "supervised_user/supervised_user_browser_utils.cc", "supervised_user/supervised_user_browser_utils.h", - "supervised_user/supervised_user_google_auth_navigation_throttle.cc", - "supervised_user/supervised_user_google_auth_navigation_throttle.h", "supervised_user/supervised_user_interstitial_tab_closer.cc", "supervised_user/supervised_user_interstitial_tab_closer.h", "supervised_user/supervised_user_metrics_service_factory.cc", diff --git a/chrome/browser/android/metrics/uma_session_stats.cc b/chrome/browser/android/metrics/uma_session_stats.cc --- a/chrome/browser/android/metrics/uma_session_stats.cc +++ b/chrome/browser/android/metrics/uma_session_stats.cc @@ -256,16 +256,6 @@ static void JNI_UmaSessionStats_ChangeMetricsReportingConsent( jint called_from) { UpdateMetricsPrefsOnPermissionChange( consent, static_cast(called_from)); - - // This function ensures a consent file in the data directory is either - // created, or deleted, depending on consent. Starting up metrics services - // will ensure that the consent file contains the ClientID. The ID is passed - // to the renderer for crash reporting when things go wrong. - GoogleUpdateSettings::CollectStatsConsentTaskRunner()->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent), - consent)); } // Initialize the local consent bool variable to false. Used only for testing. diff --git a/chrome/browser/android/signin/signin_manager_android.cc b/chrome/browser/android/signin/signin_manager_android.cc --- a/chrome/browser/android/signin/signin_manager_android.cc +++ b/chrome/browser/android/signin/signin_manager_android.cc @@ -58,29 +58,10 @@ class ProfileDataRemover : public content::BrowsingDataRemover::Observer { remover_(profile->GetBrowsingDataRemover()) { remover_->AddObserver(this); - if (all_data) { - remover_->RemoveAndReply(base::Time(), base::Time::Max(), - chrome_browsing_data_remover::ALL_DATA_TYPES, - chrome_browsing_data_remover::ALL_ORIGIN_TYPES, - this); - } else { - std::unique_ptr google_tld_filter = - content::BrowsingDataFilterBuilder::Create( - content::BrowsingDataFilterBuilder::Mode::kDelete); - - // TODO(msramek): BrowsingDataFilterBuilder was not designed for - // large filters. Optimize it. - for (const std::string& domain : - google_util::GetGoogleRegistrableDomains()) { - google_tld_filter->AddRegisterableDomain(domain); - } - - remover_->RemoveWithFilterAndReply( - base::Time(), base::Time::Max(), - content::BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE, - chrome_browsing_data_remover::ALL_ORIGIN_TYPES, - std::move(google_tld_filter), this); - } + remover_->RemoveAndReply(base::Time(), base::Time::Max(), + chrome_browsing_data_remover::ALL_DATA_TYPES, + chrome_browsing_data_remover::ALL_ORIGIN_TYPES, + this); } ProfileDataRemover(const ProfileDataRemover&) = delete; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -1121,7 +1121,6 @@ BrowserProcessImpl::component_updater() { std::make_unique(); std::string brand; - google_brand::GetBrand(&brand); component_updater_ = component_updater::ComponentUpdateServiceFactory( component_updater::MakeChromeComponentUpdaterConfigurator( base::CommandLine::ForCurrentProcess(), diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -2916,7 +2916,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( switches::kForcePNaClSubzero, #endif switches::kForceUIDirection, - switches::kIgnoreGooglePortNumbers, switches::kJavaScriptHarmony, switches::kEnableExperimentalWebAssemblyFeatures, embedder_support::kOriginTrialDisabledFeatures, @@ -5131,12 +5130,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( } #endif -#if BUILDFLAG(ENABLE_SUPERVISED_USERS) - MaybeAddThrottle( - SupervisedUserGoogleAuthNavigationThrottle::MaybeCreate(handle), - &throttles); -#endif - if (auto* throttle_manager = subresource_filter::ContentSubresourceFilterThrottleManager:: FromNavigationHandle(*handle)) { @@ -5662,7 +5655,8 @@ GetClientDataHeader(int frame_tree_node_id) { } #endif -std::unique_ptr CreateGoogleURLLoaderThrottle( + +#if 0 // std::unique_ptr CreateGoogleURLLoaderThrottle( #if BUILDFLAG(IS_ANDROID) const std::string& client_data_header, #endif @@ -5701,7 +5695,7 @@ std::unique_ptr CreateGoogleURLLoaderThrottle( std::move(bound_session_request_throttled_listener), #endif std::move(dynamic_params)); -} +#endif // } std::vector> ChromeContentBrowserClient::CreateURLLoaderThrottles( @@ -5747,15 +5741,6 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles( GetClientDataHeader(frame_tree_node_id); #endif - if (auto google_throttle = CreateGoogleURLLoaderThrottle( -#if BUILDFLAG(IS_ANDROID) - client_data_header, -#endif - profile); - google_throttle) { - result.push_back(std::move(google_throttle)); - } - { auto* factory = ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context); @@ -5809,20 +5794,6 @@ ChromeContentBrowserClient::CreateURLLoaderThrottlesForKeepAlive( } #endif -#if BUILDFLAG(IS_ANDROID) - auto [client_data_header, unused_is_custom_tab] = - GetClientDataHeader(frame_tree_node_id); -#endif - - if (auto google_throttle = CreateGoogleURLLoaderThrottle( -#if BUILDFLAG(IS_ANDROID) - client_data_header, -#endif - profile); - google_throttle) { - result.push_back(std::move(google_throttle)); - } - return result; } diff --git a/chrome/browser/domain_reliability/service_factory.cc b/chrome/browser/domain_reliability/service_factory.cc --- a/chrome/browser/domain_reliability/service_factory.cc +++ b/chrome/browser/domain_reliability/service_factory.cc @@ -14,40 +14,11 @@ namespace domain_reliability { -namespace { - -// If Domain Reliability is enabled in the absence of a flag or field trial. -const bool kDefaultEnabled = true; - -// The name and value of the field trial to turn Domain Reliability on. -const char kFieldTrialName[] = "DomRel-Enable"; -const char kFieldTrialValueEnable[] = "enable"; - -bool IsDomainReliabilityAllowed() { - return g_browser_process->local_state()->GetBoolean( - prefs::kDomainReliabilityAllowedByPolicy); -} - -} // namespace - +// Identifies Chrome as the source of Domain Reliability uploads it sends. const char kUploadReporterString[] = "chrome"; bool ShouldCreateService() { - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kDisableDomainReliability)) - return false; - if (command_line->HasSwitch(switches::kEnableDomainReliability)) - return true; - if (!IsDomainReliabilityAllowed()) { - return false; - } - if (!ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()) - return false; - if (base::FieldTrialList::TrialExists(kFieldTrialName)) { - std::string value = base::FieldTrialList::FindFullName(kFieldTrialName); - return (value == kFieldTrialValueEnable); - } - return kDefaultEnabled; + return false; } } // namespace domain_reliability diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn @@ -822,7 +822,6 @@ static_library("extensions") { "//chrome/browser/devtools", "//chrome/browser/extensions:cws_item_service_proto", "//chrome/browser/favicon", - "//chrome/browser/google", "//chrome/browser/image_decoder", "//chrome/browser/media/router", "//chrome/browser/media/router:media_router_feature", diff --git a/chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc b/chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc --- a/chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc +++ b/chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc @@ -119,7 +119,6 @@ constexpr char kOsVersionTag[] = "OS VERSION"; #if BUILDFLAG(IS_WIN) constexpr char kUsbKeyboardDetected[] = "usb_keyboard_detected"; constexpr char kIsEnrolledToDomain[] = "enrolled_to_domain"; -constexpr char kInstallerBrandCode[] = "installer_brand_code"; #if BUILDFLAG(GOOGLE_CHROME_BRANDING) constexpr char kUpdateErrorCode[] = "update_error_code"; constexpr char kUpdateHresult[] = "update_hresult"; @@ -622,10 +621,6 @@ void ChromeInternalLogSource::PopulateEnrolledToDomain( void ChromeInternalLogSource::PopulateInstallerBrandCode( SystemLogsResponse* response) { - std::string brand; - google_brand::GetBrand(&brand); - response->emplace(kInstallerBrandCode, - brand.empty() ? "Unknown brand code" : brand); } void ChromeInternalLogSource::PopulateLastUpdateState( diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -298,15 +298,6 @@ void SetupInitialPrefsFromInstallPrefs( // -- Platform-specific functions -- -#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_BSD) && \ - !BUILDFLAG(IS_FUCHSIA) -bool IsOrganicFirstRun() { - std::string brand; - google_brand::GetBrand(&brand); - return google_brand::IsOrganicFirstRun(brand); -} -#endif - FirstRunState DetermineFirstRunState(bool has_sentinel, bool force_first_run, bool no_first_run) { diff --git a/chrome/browser/google/BUILD.gn b/chrome/browser/google/BUILD.gn --- a/chrome/browser/google/BUILD.gn +++ b/chrome/browser/google/BUILD.gn @@ -5,7 +5,7 @@ import("//build/config/chrome_build.gni") import("//build/config/chromeos/ui_mode.gni") -source_set("google") { +source_set("google_UNUSED") { sources = [ "google_brand.cc", "google_brand.h", @@ -81,7 +81,7 @@ source_set("unit_tests") { sources = [ "google_update_settings_unittest.cc" ] deps = [ - ":google", + ":google_UNUSED", "//base", "//base/test:test_support", "//chrome/common:constants", diff --git a/chrome/browser/long_screenshots/long_screenshots_tab_service.cc b/chrome/browser/long_screenshots/long_screenshots_tab_service.cc --- a/chrome/browser/long_screenshots/long_screenshots_tab_service.cc +++ b/chrome/browser/long_screenshots/long_screenshots_tab_service.cc @@ -34,13 +34,11 @@ constexpr size_t kMaxPerCaptureSizeBytes = 50 * 1000L * 1000L; // 50 MB. // Host/regex pattern for Google AMP Cache URLs. // See https://developers.google.com/amp/cache/overview#amp-cache-url-format // for a definition of the format of AMP Cache URLs. -const char kGoogleAmpCacheHost[] = "cdn.ampproject.org"; const char kGoogleAmpCachePathPattern[] = "/[a-z]/(s/)?(.*)"; // Regex pattern for the path of Google AMP Viewer URLs. const char kGoogleAmpViewerPathPattern[] = "/amp/(s/)?(.*)"; -const char kGoogleNewsHost[] = "news.google.com"; const char kGoogleNewsPathPattern[] = "/articles/(.*)"; } // namespace @@ -229,26 +227,6 @@ bool LongScreenshotsTabService::IsAmpUrl(const GURL& url) { return false; } - // Check for "*.cdn.ampproject.org" URLs. - if (url.DomainIs(kGoogleAmpCacheHost) && - re2::RE2::FullMatch(url.path(), google_amp_cache_path_regex_)) { - return true; - } - - // Check for "www.google.TLD/amp/" URLs. - if (google_util::IsGoogleDomainUrl( - url, google_util::DISALLOW_SUBDOMAIN, - google_util::DISALLOW_NON_STANDARD_PORTS) && - re2::RE2::FullMatch(url.path(), google_amp_viewer_path_regex_)) { - return true; - } - - // Check for "news.google.com/articles/*". - if (url.DomainIs(kGoogleNewsHost) && - re2::RE2::FullMatch(url.path(), google_news_path_regex_)) { - return true; - } - return false; } diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -629,7 +629,7 @@ ChromeMetricsServiceClient::GetNetworkTimeTracker() { } bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { - return google_brand::GetBrand(brand_code); + return false; } metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { diff --git a/chrome/browser/metrics/chrome_metrics_services_manager_client.cc b/chrome/browser/metrics/chrome_metrics_services_manager_client.cc --- a/chrome/browser/metrics/chrome_metrics_services_manager_client.cc +++ b/chrome/browser/metrics/chrome_metrics_services_manager_client.cc @@ -103,9 +103,6 @@ void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { // This must happen on the same sequence as the tasks to enable/disable // metrics reporting. Otherwise, this may run while disabling metrics // reporting if the user quickly enables and disables metrics reporting. - GoogleUpdateSettings::CollectStatsConsentTaskRunner()->PostTask( - FROM_HERE, base::BindOnce(&GoogleUpdateSettings::StoreMetricsClientInfo, - client_info)); } #if BUILDFLAG(IS_ANDROID) @@ -338,7 +335,7 @@ ChromeMetricsServicesManagerClient::GetMetricsStateManager() { cc::switches::kEnableGpuBenchmarking), }, base::BindRepeating(&PostStoreMetricsClientInfo), - base::BindRepeating(&GoogleUpdateSettings::LoadMetricsClientInfo), + metrics::MetricsStateManager::LoadClientInfoCallback(), client_id); } return metrics_state_manager_.get(); diff --git a/chrome/browser/metrics/metrics_reporting_state.cc b/chrome/browser/metrics/metrics_reporting_state.cc --- a/chrome/browser/metrics/metrics_reporting_state.cc +++ b/chrome/browser/metrics/metrics_reporting_state.cc @@ -34,71 +34,6 @@ #include "components/policy/core/common/features.h" #endif // BUILDFLAG(IS_ANDROID) -namespace { - -enum MetricsReportingChangeHistogramValue { - METRICS_REPORTING_ERROR, - METRICS_REPORTING_DISABLED, - METRICS_REPORTING_ENABLED, - METRICS_REPORTING_MAX -}; - -void RecordMetricsReportingHistogramValue( - MetricsReportingChangeHistogramValue value) { - UMA_HISTOGRAM_ENUMERATION( - "UMA.MetricsReporting.Toggle", value, METRICS_REPORTING_MAX); -} - -// Tries to set metrics reporting status to |enabled| and returns whatever is -// the result of the update. -bool SetGoogleUpdateSettings(bool enabled) { - GoogleUpdateSettings::SetCollectStatsConsent(enabled); - bool updated_pref = GoogleUpdateSettings::GetCollectStatsConsent(); - if (enabled != updated_pref) - DVLOG(1) << "Unable to set metrics reporting status to " << enabled; - - return updated_pref; -} - -// Does the necessary changes for MetricsReportingEnabled changes which needs -// to be done in the main thread. -// As arguments this function gets: -// |to_update_pref| which indicates what the desired update should be, -// |callback_fn| is the callback function to be called in the end, -// |called_from| is from where the call was made, -// |updated_pref| is the result of attempted update. -// Update considers to be successful if |to_update_pref| and |updated_pref| are -// the same. -void SetMetricsReporting(bool to_update_pref, - OnMetricsReportingCallbackType callback_fn, - ChangeMetricsReportingStateCalledFrom called_from, - bool updated_pref) { - g_browser_process->local_state()->SetBoolean( - metrics::prefs::kMetricsReportingEnabled, updated_pref); - -#if BUILDFLAG(IS_CHROMEOS_ASH) - metrics::structured::NeutrinoDevicesLogWithClientId( - g_browser_process->local_state()->GetString( - metrics::prefs::kMetricsClientID), - metrics::structured::NeutrinoDevicesLocation::kSetMetricsReporting); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) - UpdateMetricsPrefsOnPermissionChange(updated_pref, called_from); - - // Uses the current state of whether reporting is enabled to enable services. - g_browser_process->GetMetricsServicesManager()->UpdateUploadPermissions(true); - - if (to_update_pref == updated_pref) { - RecordMetricsReportingHistogramValue(updated_pref ? - METRICS_REPORTING_ENABLED : METRICS_REPORTING_DISABLED); - } else { - RecordMetricsReportingHistogramValue(METRICS_REPORTING_ERROR); - } - if (!callback_fn.is_null()) - std::move(callback_fn).Run(updated_pref); -} - -} // namespace - void ChangeMetricsReportingState( bool enabled, ChangeMetricsReportingStateCalledFrom called_from) { @@ -139,11 +74,6 @@ void ChangeMetricsReportingStateWithReply( metrics::structured::NeutrinoDevicesLocation:: kChangeMetricsReportingStateWithReply); #endif // BUILDFLAG(IS_CHROMEOS_ASH) - GoogleUpdateSettings::CollectStatsConsentTaskRunner() - ->PostTaskAndReplyWithResult( - FROM_HERE, base::BindOnce(&SetGoogleUpdateSettings, enabled), - base::BindOnce(&SetMetricsReporting, enabled, std::move(callback_fn), - called_from)); } void UpdateMetricsPrefsOnPermissionChange( @@ -215,13 +145,7 @@ void UpdateMetricsPrefsOnPermissionChange( crash_keys::ClearMetricsClientId(); } -void ApplyMetricsReportingPolicy() { - GoogleUpdateSettings::CollectStatsConsentTaskRunner()->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&GoogleUpdateSettings::SetCollectStatsConsent), - ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled())); -} +void ApplyMetricsReportingPolicy() {} bool IsMetricsReportingPolicyManaged() { #if BUILDFLAG(IS_CHROMEOS_ASH) diff --git a/chrome/browser/net/system_network_context_manager.cc b/chrome/browser/net/system_network_context_manager.cc --- a/chrome/browser/net/system_network_context_manager.cc +++ b/chrome/browser/net/system_network_context_manager.cc @@ -819,7 +819,6 @@ void SystemNetworkContextManager::AddSSLConfigToNetworkContextParams( void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams( network::mojom::NetworkContextParams* network_context_params) { variations::UpdateCorsExemptHeaderForVariations(network_context_params); - GoogleURLLoaderThrottle::UpdateCorsExemptHeader(network_context_params); network_context_params->enable_brotli = true; diff --git a/chrome/browser/new_tab_page/modules/recipes/recipes_service.cc b/chrome/browser/new_tab_page/modules/recipes/recipes_service.cc --- a/chrome/browser/new_tab_page/modules/recipes/recipes_service.cc +++ b/chrome/browser/new_tab_page/modules/recipes/recipes_service.cc @@ -52,9 +52,10 @@ const char* GetExperimentGroupParam() { } GURL GetApiUrl(const std::string& application_locale) { + if ((true)) return GURL(); GURL google_base_url = google_util::CommandLineGoogleBaseURL(); if (!google_base_url.is_valid()) { - google_base_url = GURL(google_util::kGoogleHomepageURL); + google_base_url = GURL(); } auto url = net::AppendQueryParameter(google_base_url.Resolve(kPath), "hl", application_locale); diff --git a/chrome/browser/new_tab_page/one_google_bar/one_google_bar_loader_impl.cc b/chrome/browser/new_tab_page/one_google_bar/one_google_bar_loader_impl.cc --- a/chrome/browser/new_tab_page/one_google_bar/one_google_bar_loader_impl.cc +++ b/chrome/browser/new_tab_page/one_google_bar/one_google_bar_loader_impl.cc @@ -313,10 +313,11 @@ bool OneGoogleBarLoaderImpl::SetAdditionalQueryParams( } GURL OneGoogleBarLoaderImpl::GetApiUrl() const { + if ((true)) return GURL(); GURL api_url; GURL google_base_url = google_util::CommandLineGoogleBaseURL(); if (!google_base_url.is_valid()) { - google_base_url = GURL(google_util::kGoogleHomepageURL); + google_base_url = GURL(); } api_url = google_base_url.Resolve(kNewTabOgbApiPath); diff --git a/chrome/browser/new_tab_page/promos/promo_service.cc b/chrome/browser/new_tab_page/promos/promo_service.cc --- a/chrome/browser/new_tab_page/promos/promo_service.cc +++ b/chrome/browser/new_tab_page/promos/promo_service.cc @@ -80,11 +80,7 @@ bool CanBlockPromos() { } GURL GetGoogleBaseUrl() { - GURL google_base_url = google_util::CommandLineGoogleBaseURL(); - if (!google_base_url.is_valid()) { - google_base_url = GURL(google_util::kGoogleHomepageURL); - } - return google_base_url; + return GURL(); } GURL GetApiUrl() { diff --git a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc --- a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc +++ b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc @@ -393,8 +393,7 @@ FromGWSPageLoadMetricsLogger::~FromGWSPageLoadMetricsLogger() = default; void FromGWSPageLoadMetricsLogger::SetPreviouslyCommittedUrl(const GURL& url) { if (page_load_metrics::IsGoogleSearchResultUrl(url)) { previously_committed_url_is_search_results_ = true; - navigation_initiated_search_mode_ = - google_util::GoogleSearchModeFromUrl(url); + navigation_initiated_search_mode_ = google_util::GoogleSearchMode::kWeb; } previously_committed_url_is_search_redirector_ = page_load_metrics::IsGoogleSearchRedirectorUrl(url); @@ -411,8 +410,7 @@ void FromGWSPageLoadMetricsLogger::SetNavigationStateForSidePanel( initiating_side_panel_url_ = initiating_side_panel_url; navigation_initiated_via_link_ = navigation_initiated_via_link; if (page_load_metrics::IsGoogleSearchResultUrl(initiating_side_panel_url)) { - navigation_initiated_search_mode_ = - google_util::GoogleSearchModeFromUrl(initiating_side_panel_url); + navigation_initiated_search_mode_ = google_util::GoogleSearchMode::kWeb; } } diff --git a/chrome/browser/page_load_metrics/page_load_metrics_initialize.cc b/chrome/browser/page_load_metrics/page_load_metrics_initialize.cc --- a/chrome/browser/page_load_metrics/page_load_metrics_initialize.cc +++ b/chrome/browser/page_load_metrics/page_load_metrics_initialize.cc @@ -124,8 +124,6 @@ void PageLoadMetricsEmbedder::RegisterEmbedderObservers( tracker->AddObserver(std::make_unique()); tracker->AddObserver(std::make_unique()); tracker->AddObserver(std::make_unique()); - tracker->AddObserver(std::make_unique()); - tracker->AddObserver(std::make_unique()); tracker->AddObserver(std::make_unique()); tracker->AddObserver( std::make_unique()); diff --git a/chrome/browser/safe_browsing/BUILD.gn b/chrome/browser/safe_browsing/BUILD.gn --- a/chrome/browser/safe_browsing/BUILD.gn +++ b/chrome/browser/safe_browsing/BUILD.gn @@ -24,7 +24,6 @@ static_library("safe_browsing") { "//build:branding_buildflags", "//chrome/app:generated_resources", "//chrome/browser:browser_process", - "//chrome/browser/google", "//chrome/browser/profiles", "//chrome/browser/profiles:profile", "//chrome/common", diff --git a/chrome/browser/search_engines/ui_thread_search_terms_data.cc b/chrome/browser/search_engines/ui_thread_search_terms_data.cc --- a/chrome/browser/search_engines/ui_thread_search_terms_data.cc +++ b/chrome/browser/search_engines/ui_thread_search_terms_data.cc @@ -33,10 +33,6 @@ UIThreadSearchTermsData::UIThreadSearchTermsData() { std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || BrowserThread::CurrentlyOn(BrowserThread::UI)); - GURL base_url(google_util::CommandLineGoogleBaseURL()); - if (base_url.is_valid()) - return base_url.spec(); - return SearchTermsData::GoogleBaseURLValue(); } diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -423,7 +423,6 @@ static_library("ui") { "//chrome/browser/companion/core", "//chrome/browser/devtools", "//chrome/browser/favicon", - "//chrome/browser/google", "//chrome/browser/image_decoder", "//chrome/browser/media:mojo_bindings", "//chrome/browser/media/router:media_router_feature", diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc @@ -621,11 +621,6 @@ content::WebUIDataSource* CreateAndAddNewTabPageUiHtmlSource(Profile* profile) { // chrome-untrusted://new-tab-page for other external content and resources. // NOTE: Use caution when overriding content security policies as that cean // lead to subtle security bugs such as https://crbug.com/1251541. - source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::ChildSrc, - base::StringPrintf("child-src https: %s %s;", - google_util::CommandLineGoogleBaseURL().spec().c_str(), - chrome::kChromeUIUntrustedNewTabPageUrl)); return source; } diff --git a/chrome/browser/ui/webui/settings/reset_settings_handler.cc b/chrome/browser/ui/webui/settings/reset_settings_handler.cc --- a/chrome/browser/ui/webui/settings/reset_settings_handler.cc +++ b/chrome/browser/ui/webui/settings/reset_settings_handler.cc @@ -87,7 +87,6 @@ bool ResetSettingsHandler::ShouldShowResetProfileBanner(Profile* profile) { ResetSettingsHandler::ResetSettingsHandler(Profile* profile) : profile_(profile) { - google_brand::GetBrand(&brandcode_); } ResetSettingsHandler::~ResetSettingsHandler() {} diff --git a/chrome/browser/upgrade_detector/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector/upgrade_detector_impl.cc --- a/chrome/browser/upgrade_detector/upgrade_detector_impl.cc +++ b/chrome/browser/upgrade_detector/upgrade_detector_impl.cc @@ -207,7 +207,7 @@ void UpgradeDetectorImpl::StartOutdatedBuildDetector() { // an outdated build is being simulated by command line switches. if (!simulating_outdated_) { std::string brand; - if (google_brand::GetBrand(&brand) && !google_brand::IsOrganic(brand)) + if ((true)) return; #if BUILDFLAG(IS_WIN) diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -142,8 +142,6 @@ static_library("common_lib") { "content_restriction.h", "crash_keys.cc", "crash_keys.h", - "google_url_loader_throttle.cc", - "google_url_loader_throttle.h", "logging_chrome.cc", "logging_chrome.h", "media/cdm_registration.cc", diff --git a/chrome/renderer/google_accounts_private_api_util.cc b/chrome/renderer/google_accounts_private_api_util.cc --- a/chrome/renderer/google_accounts_private_api_util.cc +++ b/chrome/renderer/google_accounts_private_api_util.cc @@ -22,6 +22,7 @@ const url::Origin& GetAllowedGoogleAccountsOrigin() { bool ShouldExposeGoogleAccountsJavascriptApi( content::RenderFrame* render_frame) { + if ((true)) return false; DCHECK(render_frame); const url::Origin origin = render_frame->GetWebFrame()->GetSecurityOrigin(); diff --git a/chrome/renderer/url_loader_throttle_provider_impl.cc b/chrome/renderer/url_loader_throttle_provider_impl.cc --- a/chrome/renderer/url_loader_throttle_provider_impl.cc +++ b/chrome/renderer/url_loader_throttle_provider_impl.cc @@ -219,17 +219,6 @@ URLLoaderThrottleProviderImpl::CreateThrottles( } #endif - throttles.emplace_back(std::make_unique( -#if BUILDFLAG(IS_ANDROID) - client_data_header, -#endif -#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS) - chrome_content_renderer_client_->GetChromeObserver() - ->CreateBoundSessionRequestThrottledListener(), -#endif - chrome_content_renderer_client_->GetChromeObserver() - ->GetDynamicParams())); - #if BUILDFLAG(IS_CHROMEOS_ASH) throttles.emplace_back(std::make_unique( chrome_content_renderer_client_->GetChromeObserver() diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -6506,7 +6506,6 @@ test("unit_tests") { "//chrome/browser/favicon", "//chrome/browser/feature_guide/notifications:unit_tests", "//chrome/browser/first_party_sets", - "//chrome/browser/google:unit_tests", "//chrome/browser/media/router", "//chrome/browser/media/router:media_router_feature", "//chrome/browser/media/router:unittests", diff --git a/components/domain_reliability/BUILD.gn b/components/domain_reliability/BUILD.gn --- a/components/domain_reliability/BUILD.gn +++ b/components/domain_reliability/BUILD.gn @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -action("bake_in_configs") { +action("bake_in_configs_EXCLUDED") { visibility = [ ":*" ] script = "bake_in_configs.py" @@ -73,12 +73,9 @@ component("domain_reliability") { "util.cc", "util.h", ] - sources += get_target_outputs(":bake_in_configs") - defines = [ "DOMAIN_RELIABILITY_IMPLEMENTATION" ] deps = [ - ":bake_in_configs", ":prefs", "//base", "//net", diff --git a/components/domain_reliability/bake_in_configs.py b/components/domain_reliability/bake_in_configs.py --- a/components/domain_reliability/bake_in_configs.py +++ b/components/domain_reliability/bake_in_configs.py @@ -490,7 +490,7 @@ def origin_is_whitelisted(origin): domain = origin[8:-1] else: return False - return any(domain == e or domain.endswith('.' + e) for e in DOMAIN_WHITELIST) + return False def quote_and_wrap_text(text, width=79, prefix=' "', suffix='"'): diff --git a/components/domain_reliability/context_manager.cc b/components/domain_reliability/context_manager.cc --- a/components/domain_reliability/context_manager.cc +++ b/components/domain_reliability/context_manager.cc @@ -41,26 +41,8 @@ void DomainReliabilityContextManager::RouteBeacon( DomainReliabilityContext* superdomain_context = GetSuperdomainContext(beacon_host); - // Try to get a Google config which may match the host itself, or the host's - // parent domain. - std::unique_ptr google_config = - MaybeGetGoogleConfig(beacon_host); - - if (!google_config) { - if (superdomain_context) - superdomain_context->OnBeacon(std::move(beacon)); - return; - } - - context_to_use = superdomain_context; - bool google_config_is_exact = (google_config->origin.host() == beacon_host); - - // An exact match takes priority over an existing superdomain context, if any - // exists. - if (google_config_is_exact || !context_to_use) - context_to_use = AddContextForConfig(std::move(google_config)); - - context_to_use->OnBeacon(std::move(beacon)); + if (superdomain_context) + superdomain_context->OnBeacon(std::move(beacon)); } void DomainReliabilityContextManager::ClearBeacons( diff --git a/components/domain_reliability/google_configs.cc b/components/domain_reliability/google_configs.cc --- a/components/domain_reliability/google_configs.cc +++ b/components/domain_reliability/google_configs.cc @@ -9,7 +9,7 @@ #include "base/strings/string_util.h" #include "net/base/url_util.h" -namespace domain_reliability { +namespace domain_reliability_disabled { namespace { @@ -28,7 +28,7 @@ struct GoogleConfigParams { bool duplicate_for_www; }; -const GoogleConfigParams kGoogleConfigs[] = { +/*const GoogleConfigParams kGoogleConfigs[] = { // Origins with subdomains and same-origin collectors. Currently, all // origins with same-origin collectors also run collectors on their www // subdomain. (e.g., both foo.com and www.foo.com.) @@ -550,11 +550,11 @@ std::unique_ptr CreateGoogleConfig( config->failure_sample_rate = 1.00; config->path_prefixes.clear(); return config; -} +}*/ } // namespace -std::unique_ptr MaybeGetGoogleConfig( +/*std::unique_ptr MaybeGetGoogleConfig( const std::string& hostname) { bool is_www_subdomain = base::StartsWith(hostname, "www.", base::CompareCase::SENSITIVE); @@ -604,6 +604,6 @@ GetAllGoogleConfigsForTesting() { configs_out.push_back(CreateGoogleConfig(params, true)); } return configs_out; -} +} */ } // namespace domain_reliability diff --git a/components/domain_reliability/google_configs.h b/components/domain_reliability/google_configs.h --- a/components/domain_reliability/google_configs.h +++ b/components/domain_reliability/google_configs.h @@ -26,11 +26,11 @@ namespace domain_reliability { // the www subdomain. A superdomain match occurs if removing the first label of // |hostname| yields a string equal to a Google config's hostname and that // config specifies that it includes subdomains. -std::unique_ptr DOMAIN_RELIABILITY_EXPORT -MaybeGetGoogleConfig(const std::string& hostname); +//std::unique_ptr DOMAIN_RELIABILITY_EXPORT +//MaybeGetGoogleConfig(const std::string& hostname); -std::vector> - DOMAIN_RELIABILITY_EXPORT GetAllGoogleConfigsForTesting(); +//std::vector> +// DOMAIN_RELIABILITY_EXPORT GetAllGoogleConfigsForTesting(); } // namespace domain_reliability diff --git a/components/domain_reliability/monitor.cc b/components/domain_reliability/monitor.cc --- a/components/domain_reliability/monitor.cc +++ b/components/domain_reliability/monitor.cc @@ -94,14 +94,6 @@ void DomainReliabilityMonitor::Shutdown() { } void DomainReliabilityMonitor::AddBakedInConfigs() { - for (size_t i = 0; kBakedInJsonConfigs[i]; ++i) { - base::StringPiece json(kBakedInJsonConfigs[i]); - std::unique_ptr config = - DomainReliabilityConfig::FromJSON(json); - // Guard against accidentally checking in malformed JSON configs. - DCHECK(config->IsValid()); - context_manager_.AddContextForConfig(std::move(config)); - } } void DomainReliabilityMonitor::SetDiscardUploads(bool discard_uploads) { diff --git a/components/domain_reliability/uploader.cc b/components/domain_reliability/uploader.cc --- a/components/domain_reliability/uploader.cc +++ b/components/domain_reliability/uploader.cc @@ -80,7 +80,7 @@ class DomainReliabilityUploaderImpl : public DomainReliabilityUploader, if (discard_uploads_) discarded_upload_count_++; - if (discard_uploads_ || shutdown_) { + if ((true)) { DVLOG(1) << "Discarding report instead of uploading."; UploadResult result; result.status = UploadResult::SUCCESS; diff --git a/components/google/core/common/google_util.cc b/components/google/core/common/google_util.cc --- a/components/google/core/common/google_util.cc +++ b/components/google/core/common/google_util.cc @@ -31,60 +31,6 @@ namespace google_util { namespace { -bool IsPathHomePageBase(base::StringPiece path) { - return (path == "/") || (path == "/webhp"); -} - -// Removes a single trailing dot if present in |host|. -void StripTrailingDot(base::StringPiece* host) { - if (base::EndsWith(*host, ".")) - host->remove_suffix(1); -} - -// True if the given canonical |host| is "[www.]." -// with a valid TLD that appears in |allowed_tlds|. If |subdomain_permission| is -// ALLOW_SUBDOMAIN, we check against host "*.." -// instead. -template -bool IsValidHostName(base::StringPiece host, - base::StringPiece domain_in_lower_case, - SubdomainPermission subdomain_permission, - const Container& allowed_tlds) { - // Fast path to avoid searching the registry set. - if (host.find(domain_in_lower_case) == base::StringPiece::npos) - return false; - - size_t tld_length = - net::registry_controlled_domains::GetCanonicalHostRegistryLength( - host, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, - net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); - if ((tld_length == 0) || (tld_length == std::string::npos)) - return false; - - // Removes the tld and the preceding dot. - base::StringPiece host_minus_tld = - host.substr(0, host.length() - tld_length - 1); - - base::StringPiece tld = host.substr(host.length() - tld_length); - // Remove the trailing dot from tld if present, as for Google domains it's the - // same page. - StripTrailingDot(&tld); - if (!allowed_tlds.contains(tld)) - return false; - - if (base::EqualsCaseInsensitiveASCII(host_minus_tld, domain_in_lower_case)) - return true; - - if (subdomain_permission == ALLOW_SUBDOMAIN) { - std::string dot_domain = base::StrCat({".", domain_in_lower_case}); - return base::EndsWith(host_minus_tld, dot_domain, - base::CompareCase::INSENSITIVE_ASCII); - } - - std::string www_domain = base::StrCat({"www.", domain_in_lower_case}); - return base::EqualsCaseInsensitiveASCII(host_minus_tld, www_domain); -} - // True if |url| is a valid URL with HTTP or HTTPS scheme. If |port_permission| // is DISALLOW_NON_STANDARD_PORTS, this also requires |url| to use the standard // port for its scheme (80 for HTTP, 443 for HTTPS). @@ -99,57 +45,14 @@ bool IsValidURL(const GURL& url, PortPermission port_permission) { bool IsCanonicalHostGoogleHostname(base::StringPiece canonical_host, SubdomainPermission subdomain_permission) { - const GURL& base_url(CommandLineGoogleBaseURL()); - if (base_url.is_valid() && (canonical_host == base_url.host_piece())) - return true; - - static constexpr auto google_tlds = - base::MakeFixedFlatSet({GOOGLE_TLD_LIST}); - return IsValidHostName(canonical_host, "google", subdomain_permission, - google_tlds); -} - -bool IsCanonicalHostYoutubeHostname(base::StringPiece canonical_host, - SubdomainPermission subdomain_permission) { - static constexpr auto youtube_tlds = - base::MakeFixedFlatSet({YOUTUBE_TLD_LIST}); - - return IsValidHostName(canonical_host, "youtube", subdomain_permission, - youtube_tlds); -} - -// True if |url| is a valid URL with a host that is in the static list of -// Google subdomains for google search, and an HTTP or HTTPS scheme. Requires -// |url| to use the standard port for its scheme (80 for HTTP, 443 for HTTPS). -bool IsGoogleSearchSubdomainUrl(const GURL& url) { - if (!IsValidURL(url, PortPermission::DISALLOW_NON_STANDARD_PORTS)) - return false; - - base::StringPiece host(url.host_piece()); - StripTrailingDot(&host); - - static constexpr auto google_subdomains = - base::MakeFixedFlatSet( - {"ipv4.google.com", "ipv6.google.com"}); - - return google_subdomains.contains(host); + return false; } } // namespace // Global functions ----------------------------------------------------------- -const char kGoogleHomepageURL[] = "https://www.google.com/"; - -bool HasGoogleSearchQueryParam(base::StringPiece str) { - url::Component query(0, static_cast(str.length())), key, value; - while (url::ExtractQueryKeyValue(str.data(), &query, &key, &value)) { - base::StringPiece key_str = str.substr(key.begin, key.len); - if (key_str == "q" || key_str == "as_q" || key_str == "imgurl") - return true; - } - return false; -} +const char kGoogleHomepageURL_Checked[] = "https://www.google.com/"; std::string GetGoogleLocale(const std::string& application_locale) { // Google does not recognize "nb" for Norwegian Bokmal; it uses "no". @@ -158,30 +61,11 @@ std::string GetGoogleLocale(const std::string& application_locale) { GURL AppendGoogleLocaleParam(const GURL& url, const std::string& application_locale) { - return net::AppendQueryParameter(url, "hl", - GetGoogleLocale(application_locale)); + return url; } std::string GetGoogleCountryCode(const GURL& google_homepage_url) { - base::StringPiece google_hostname = google_homepage_url.host_piece(); - // TODO(igorcov): This needs a fix for case when the host has a trailing dot, - // like "google.com./". https://crbug.com/720295. - const size_t last_dot = google_hostname.find_last_of('.'); - if (last_dot == std::string::npos) - return std::string(); - base::StringPiece country_code = google_hostname.substr(last_dot + 1); - // Assume the com TLD implies the US. - if (country_code == "com") - return "us"; - // Google uses the Unicode Common Locale Data Repository (CLDR), and the CLDR - // code for the UK is "gb". - if (country_code == "uk") - return "gb"; - // Catalonia does not have a CLDR country code, since it's a region in Spain, - // so use Spain instead. - if (country_code == "cat") - return "es"; - return std::string(country_code); + return std::string(); } GURL GetGoogleSearchURL(const GURL& google_homepage_url) { @@ -227,206 +111,25 @@ bool IsGoogleDomainUrl(const GURL& url, bool IsGoogleHostname(base::StringPiece host, SubdomainPermission subdomain_permission) { - url::CanonHostInfo host_info; - return IsCanonicalHostGoogleHostname(net::CanonicalizeHost(host, &host_info), - subdomain_permission); + return false; } bool IsGoogleHomePageUrl(const GURL& url) { - // First check to see if this has a Google domain. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, - DISALLOW_NON_STANDARD_PORTS) && - !IsGoogleSearchSubdomainUrl(url)) { - return false; - } - - // Make sure the path is a known home page path. - base::StringPiece path(url.path_piece()); - return IsPathHomePageBase(path) || - base::StartsWith(path, "/ig", base::CompareCase::INSENSITIVE_ASCII); + return false; } bool IsGoogleSearchUrl(const GURL& url) { - // First check to see if this has a Google domain. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, - DISALLOW_NON_STANDARD_PORTS) && - !IsGoogleSearchSubdomainUrl(url)) { - return false; - } - - // Make sure the path is a known search path. - base::StringPiece path(url.path_piece()); - bool is_home_page_base = IsPathHomePageBase(path); - if (!is_home_page_base && path != "/search" && path != "/imgres") - return false; - - // Check for query parameter in URL parameter and hash fragment, depending on - // the path type. - return HasGoogleSearchQueryParam(url.ref_piece()) || - (!is_home_page_base && HasGoogleSearchQueryParam(url.query_piece())); + return false; } bool IsYoutubeDomainUrl(const GURL& url, SubdomainPermission subdomain_permission, PortPermission port_permission) { - return IsValidURL(url, port_permission) && - IsCanonicalHostYoutubeHostname(url.host_piece(), subdomain_permission); + return false; } bool IsGoogleAssociatedDomainUrl(const GURL& url) { - if (IsGoogleDomainUrl(url, ALLOW_SUBDOMAIN, ALLOW_NON_STANDARD_PORTS)) - return true; - - if (IsYoutubeDomainUrl(url, ALLOW_SUBDOMAIN, ALLOW_NON_STANDARD_PORTS)) - return true; - - // Some domains don't have international TLD extensions, so testing for them - // is very straightforward. - static const char* kSuffixesToSetHeadersFor[] = { - ".android.com", - ".doubleclick.com", - ".doubleclick.net", - ".ggpht.com", - ".googleadservices.com", - ".googleapis.com", - ".googlesyndication.com", - ".googleusercontent.com", - ".googlevideo.com", - ".gstatic.com", - ".litepages.googlezip.net", - ".youtubekids.com", - ".ytimg.com", - }; - const std::string host = url.host(); - for (size_t i = 0; i < std::size(kSuffixesToSetHeadersFor); ++i) { - if (base::EndsWith(host, kSuffixesToSetHeadersFor[i], - base::CompareCase::INSENSITIVE_ASCII)) { - return true; - } - } - - // Exact hostnames in lowercase to set headers for. - static const char* kHostsToSetHeadersFor[] = { - "googleweblight.com", - }; - for (size_t i = 0; i < std::size(kHostsToSetHeadersFor); ++i) { - if (base::EqualsCaseInsensitiveASCII(host, kHostsToSetHeadersFor[i])) - return true; - } - return false; } -const std::vector& GetGoogleRegistrableDomains() { - static base::NoDestructor> - kGoogleRegisterableDomains([]() { - std::vector domains; - - std::vector tlds{GOOGLE_TLD_LIST}; - for (const std::string& tld : tlds) { - std::string domain = "google." + tld; - - // The Google TLD list might contain domains that are not considered - // to be registrable domains by net::registry_controlled_domains. - if (GetDomainAndRegistry(domain, - net::registry_controlled_domains:: - INCLUDE_PRIVATE_REGISTRIES) != domain) { - continue; - } - - domains.push_back(domain); - } - - return domains; - }()); - - return *kGoogleRegisterableDomains; -} - -GURL AppendToAsyncQueryParam(const GURL& url, - const std::string& key, - const std::string& value) { - const std::string param_name = "async"; - const std::string key_value = key + ":" + value; - bool replaced = false; - const base::StringPiece input = url.query_piece(); - url::Component cursor(0, input.size()); - std::string output; - url::Component key_range, value_range; - while (url::ExtractQueryKeyValue(input.data(), &cursor, &key_range, - &value_range)) { - const base::StringPiece input_key = - input.substr(key_range.begin, key_range.len); - std::string key_value_pair( - input.substr(key_range.begin, value_range.end() - key_range.begin)); - if (!replaced && input_key == param_name) { - // Check |replaced| as only the first match should be replaced. - replaced = true; - key_value_pair += "," + key_value; - } - if (!output.empty()) { - output += "&"; - } - - output += key_value_pair; - } - if (!replaced) { - if (!output.empty()) { - output += "&"; - } - - output += (param_name + "=" + key_value); - } - GURL::Replacements replacements; - replacements.SetQueryStr(output); - return url.ReplaceComponents(replacements); -} - -GoogleSearchMode GoogleSearchModeFromUrl(const GURL& url) { - static_assert(GoogleSearchMode::kMaxValue == GoogleSearchMode::kFlights, - "This function should be updated if new values are added to " - "GoogleSearchMode"); - - base::StringPiece query_str = url.query_piece(); - url::Component query(0, static_cast(url.query_piece().length())); - url::Component key, value; - GoogleSearchMode mode = GoogleSearchMode::kUnspecified; - while (url::ExtractQueryKeyValue(query_str.data(), &query, &key, &value)) { - base::StringPiece key_str = query_str.substr(key.begin, key.len); - if (key_str != "tbm") { - continue; - } - if (mode != GoogleSearchMode::kUnspecified) { - // There is more than one tbm parameter, which is not expected. Return - // kUnknown to signify the result can't be trusted. - return GoogleSearchMode::kUnknown; - } - base::StringPiece value_str = query_str.substr(value.begin, value.len); - if (value_str == "isch") { - mode = GoogleSearchMode::kImages; - } else if (value_str == "web") { - mode = GoogleSearchMode::kWeb; - } else if (value_str == "nws") { - mode = GoogleSearchMode::kNews; - } else if (value_str == "shop") { - mode = GoogleSearchMode::kShopping; - } else if (value_str == "vid") { - mode = GoogleSearchMode::kVideos; - } else if (value_str == "bks") { - mode = GoogleSearchMode::kBooks; - } else if (value_str == "flm") { - mode = GoogleSearchMode::kFlights; - } else if (value_str == "lcl") { - mode = GoogleSearchMode::kLocal; - } else { - mode = GoogleSearchMode::kUnknown; - } - } - if (mode == GoogleSearchMode::kUnspecified) { - // No tbm query parameter means this is the Web mode. - mode = GoogleSearchMode::kWeb; - } - return mode; -} - } // namespace google_util diff --git a/components/google/core/common/google_util.h b/components/google/core/common/google_util.h --- a/components/google/core/common/google_util.h +++ b/components/google/core/common/google_util.h @@ -40,7 +40,7 @@ enum class GoogleSearchMode { kMaxValue = kFlights, }; -extern const char kGoogleHomepageURL[]; +extern const char kGoogleHomepageURL_Checked[]; // True iff |str| contains a "q=" or "as_q=" query parameter with a non-empty // value. |str| should be a query or a hash fragment, without the ? or # (as @@ -133,14 +133,6 @@ bool IsYoutubeDomainUrl(const GURL& url, // True if |url| is hosted by Google. bool IsGoogleAssociatedDomainUrl(const GURL& url); -// Returns the list of all Google's registerable domains, i.e. domains named -// google. owned by Google. -// TODO(msramek): This is currently only used to ensure the deletion of Google -// service workers on signout. Remove this once we have other options to do it, -// such as service workers discovering that signin cookies are missing and -// unregistering themselves. -const std::vector& GetGoogleRegistrableDomains(); - // Appends the provided |key| and |value| pair to the "async" query param list, // according to the format used by the Google servers: // @@ -154,11 +146,6 @@ GURL AppendToAsyncQueryParam(const GURL& url, const std::string& key, const std::string& value); -// Returns Google Search mode used by the user. This corresponds to the tab -// (e.g. web result, image results, video results, etc.) the user is on. This -// information is extracted from the "tbm" query parameter on the Search URL. -GoogleSearchMode GoogleSearchModeFromUrl(const GURL& url); - } // namespace google_util #endif // COMPONENTS_GOOGLE_CORE_COMMON_GOOGLE_UTIL_H_ diff --git a/components/page_load_metrics/browser/page_load_metrics_util.cc b/components/page_load_metrics/browser/page_load_metrics_util.cc --- a/components/page_load_metrics/browser/page_load_metrics_util.cc +++ b/components/page_load_metrics/browser/page_load_metrics_util.cc @@ -281,9 +281,7 @@ bool DidObserveLoadingBehaviorInAnyFrame( } bool IsGoogleSearchHostname(const GURL& url) { - absl::optional result = - page_load_metrics::GetGoogleHostnamePrefix(url); - return result && result.value() == "www"; + return false; } bool IsGoogleSearchResultUrl(const GURL& url) { diff --git a/components/page_load_metrics/common/page_load_metrics_util.cc b/components/page_load_metrics/common/page_load_metrics_util.cc --- a/components/page_load_metrics/common/page_load_metrics_util.cc +++ b/components/page_load_metrics/common/page_load_metrics_util.cc @@ -24,38 +24,7 @@ const int kExtraBufferTimerDelayMillis = 50; } // namespace absl::optional GetGoogleHostnamePrefix(const GURL& url) { - const size_t registry_length = - net::registry_controlled_domains::GetRegistryLength( - url, - - // Do not include unknown registries (registries that don't have any - // matches in effective TLD names). - net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, - - // Do not include private registries, such as appspot.com. We don't - // want to match URLs like www.google.appspot.com. - net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); - - const base::StringPiece hostname = url.host_piece(); - if (registry_length == 0 || registry_length == std::string::npos || - registry_length >= hostname.length()) { - return absl::optional(); - } - - // Removes the tld and the preceding dot. - const base::StringPiece hostname_minus_registry = - hostname.substr(0, hostname.length() - (registry_length + 1)); - - if (hostname_minus_registry == "google") - return std::string(""); - - if (!base::EndsWith(hostname_minus_registry, ".google", - base::CompareCase::INSENSITIVE_ASCII)) { - return absl::optional(); - } - - return std::string(hostname_minus_registry.substr( - 0, hostname_minus_registry.length() - strlen(".google"))); + return std::string(""); } bool IsGoogleHostname(const GURL& url) { diff --git a/components/search_engines/search_engine_utils.cc b/components/search_engines/search_engine_utils.cc --- a/components/search_engines/search_engine_utils.cc +++ b/components/search_engines/search_engine_utils.cc @@ -26,6 +26,7 @@ bool SameDomain(const GURL& given_url, const GURL& prepopulated_url) { SearchEngineType GetEngineType(const GURL& url) { DCHECK(url.is_valid()); + if ((true)) return SEARCH_ENGINE_OTHER; // Check using TLD+1s, in order to more aggressively match search engine types // for data imported from other browsers. diff --git a/components/search_engines/search_terms_data.cc b/components/search_engines/search_terms_data.cc --- a/components/search_engines/search_terms_data.cc +++ b/components/search_engines/search_terms_data.cc @@ -107,7 +107,7 @@ SearchTermsData::SearchTermsData() = default; SearchTermsData::~SearchTermsData() = default; std::string SearchTermsData::GoogleBaseURLValue() const { - return google_util::kGoogleHomepageURL; + return google_util::kGoogleHomepageURL_Checked; } std::string SearchTermsData::GoogleBaseSearchByImageURLValue() const { @@ -119,7 +119,7 @@ std::string SearchTermsData::GoogleBaseSearchByImageURLValue() const { } #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - return google_util::kGoogleHomepageURL + kGoogleHomepageURLPath; + return google_util::kGoogleHomepageURL_Checked + kGoogleHomepageURLPath; } std::string SearchTermsData::GoogleBaseSuggestURLValue() const { diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc --- a/components/search_engines/template_url.cc +++ b/components/search_engines/template_url.cc @@ -561,11 +561,7 @@ std::u16string TemplateURLRef::SearchTermToString16( bool TemplateURLRef::HasGoogleBaseURLs( const SearchTermsData& search_terms_data) const { ParseIfNecessary(search_terms_data); - return base::ranges::any_of( - replacements_, [](const Replacement& replacement) { - return replacement.type == GOOGLE_BASE_URL || - replacement.type == GOOGLE_BASE_SUGGEST_URL; - }); + return false; } bool TemplateURLRef::ExtractSearchTermsFromURL( diff --git a/components/search_provider_logos/BUILD.gn b/components/search_provider_logos/BUILD.gn --- a/components/search_provider_logos/BUILD.gn +++ b/components/search_provider_logos/BUILD.gn @@ -6,8 +6,6 @@ static_library("search_provider_logos") { sources = [ "fixed_logo_api.cc", "fixed_logo_api.h", - "google_logo_api.cc", - "google_logo_api.h", "logo_cache.cc", "logo_cache.h", "logo_common.cc", diff --git a/components/search_provider_logos/logo_service_impl.cc b/components/search_provider_logos/logo_service_impl.cc --- a/components/search_provider_logos/logo_service_impl.cc +++ b/components/search_provider_logos/logo_service_impl.cc @@ -249,8 +249,7 @@ void LogoServiceImpl::GetLogo(LogoCallbacks callbacks, bool for_webui_ntp) { GURL base_url; GURL doodle_url; - const bool is_google = template_url->url_ref().HasGoogleBaseURLs( - template_url_service_->search_terms_data()); + const bool is_google = false; if (is_google) { // TODO(treib): Put the Google doodle URL into prepopulated_engines.json. base_url = @@ -275,23 +274,12 @@ void LogoServiceImpl::GetLogo(LogoCallbacks callbacks, bool for_webui_ntp) { clock_ = base::DefaultClock::GetInstance(); } - const bool use_fixed_logo = !doodle_url.is_valid(); + const bool use_fixed_logo = true; if (use_fixed_logo) { SetServerAPI( logo_url, base::BindRepeating(&search_provider_logos::ParseFixedLogoResponse), base::BindRepeating(&search_provider_logos::UseFixedLogoUrl)); - } else { - // We encode the type of doodle (regular or gray) in the URL so that the - // logo cache gets cleared when that value changes. - GURL prefilled_url = AppendPreliminaryParamsToDoodleURL( - want_gray_logo_getter_.Run(), for_webui_ntp, doodle_url); - SetServerAPI( - prefilled_url, - base::BindRepeating(&search_provider_logos::ParseDoodleLogoResponse, - base_url), - base::BindRepeating( - &search_provider_logos::AppendFingerprintParamToDoodleURL)); } DCHECK(!logo_url_.is_empty()); diff --git a/components/url_matcher/url_util.cc b/components/url_matcher/url_util.cc --- a/components/url_matcher/url_util.cc +++ b/components/url_matcher/url_util.cc @@ -37,30 +37,18 @@ namespace { // Host/regex pattern for Google AMP Cache URLs. // See https://developers.google.com/amp/cache/overview#amp-cache-url-format // for a definition of the format of AMP Cache URLs. -const char kGoogleAmpCacheHost[] = "cdn.ampproject.org"; const char kGoogleAmpCachePathPattern[] = "/[a-z]/(s/)?(.*)"; // Regex pattern for the path of Google AMP Viewer URLs. const char kGoogleAmpViewerPathPattern[] = "/amp/(s/)?(.*)"; // Host, path prefix, and query regex pattern for Google web cache URLs. -const char kGoogleWebCacheHost[] = "webcache.googleusercontent.com"; -const char kGoogleWebCachePathPrefix[] = "/search"; const char kGoogleWebCacheQueryPattern[] = "cache:(.{12}:)?(https?://)?([^ :]*)( [^:]*)?"; -const char kGoogleTranslateSubdomain[] = "translate."; -const char kAlternateGoogleTranslateHost[] = "translate.googleusercontent.com"; - // Maximum filters allowed. Filters over this index are ignored. const size_t kMaxFiltersAllowed = 1000; -// Returns a full URL using either "http" or "https" as the scheme. -GURL BuildURL(bool is_https, const std::string& host_and_path) { - std::string scheme = is_https ? url::kHttpsScheme : url::kHttpScheme; - return GURL(scheme + "://" + host_and_path); -} - void ProcessQueryToConditions( url_matcher::URLMatcherConditionFactory* condition_factory, const std::string& query, @@ -118,77 +106,6 @@ class EmbeddedURLExtractor { // Implements url_filter::GetEmbeddedURL(). GURL GetEmbeddedURL(const GURL& url) { - // Check for "*.cdn.ampproject.org" URLs. - if (url.DomainIs(kGoogleAmpCacheHost)) { - std::string s; - std::string embedded; - if (re2::RE2::FullMatch(url.path(), google_amp_cache_path_regex_, &s, - &embedded)) { - if (url.has_query()) - embedded += "?" + url.query(); - return BuildURL(!s.empty(), embedded); - } - } - - // Check for "www.google.TLD/amp/" URLs. - if (google_util::IsGoogleDomainUrl( - url, google_util::DISALLOW_SUBDOMAIN, - google_util::DISALLOW_NON_STANDARD_PORTS)) { - std::string s; - std::string embedded; - if (re2::RE2::FullMatch(url.path(), google_amp_viewer_path_regex_, &s, - &embedded)) { - // The embedded URL may be percent-encoded. Undo that. - embedded = base::UnescapeBinaryURLComponent(embedded); - return BuildURL(!s.empty(), embedded); - } - } - - // Check for Google web cache URLs - // ("webcache.googleusercontent.com/search?q=cache:..."). - std::string query; - if (url.host_piece() == kGoogleWebCacheHost && - base::StartsWith(url.path_piece(), kGoogleWebCachePathPrefix) && - net::GetValueForKeyInQuery(url, "q", &query)) { - std::string fingerprint; - std::string scheme; - std::string embedded; - if (re2::RE2::FullMatch(query, google_web_cache_query_regex_, - &fingerprint, &scheme, &embedded)) { - return BuildURL(scheme == "https://", embedded); - } - } - - // Check for Google translate URLs ("translate.google.TLD/...?...&u=URL" or - // "translate.googleusercontent.com/...?...&u=URL"). - bool is_translate = false; - if (base::StartsWith(url.host_piece(), kGoogleTranslateSubdomain)) { - // Remove the "translate." prefix. - GURL::Replacements replace; - replace.SetHostStr( - url.host_piece().substr(strlen(kGoogleTranslateSubdomain))); - GURL trimmed = url.ReplaceComponents(replace); - // Check that the remainder is a Google URL. Note: IsGoogleDomainUrl - // checks for [www.]google.TLD, but we don't want the "www.", so - // explicitly exclude that. - // TODO(treib,pam): Instead of excluding "www." manually, teach - // IsGoogleDomainUrl a mode that doesn't allow it. - is_translate = google_util::IsGoogleDomainUrl( - trimmed, google_util::DISALLOW_SUBDOMAIN, - google_util::DISALLOW_NON_STANDARD_PORTS) && - !base::StartsWith(trimmed.host_piece(), "www."); - } - bool is_alternate_translate = - url.host_piece() == kAlternateGoogleTranslateHost; - if (is_translate || is_alternate_translate) { - std::string embedded; - if (net::GetValueForKeyInQuery(url, "u", &embedded)) { - // The embedded URL may or may not include a scheme. Fix it if - // necessary. - return url_formatter::FixupURL(embedded, /*desired_tld=*/std::string()); - } - } - return GURL(); } diff --git a/content/common/features.cc b/content/common/features.cc --- a/content/common/features.cc +++ b/content/common/features.cc @@ -178,8 +178,8 @@ BASE_FEATURE(kExperimentalContentSecurityPolicyFeatures, // parsing the signin status HTTP headers. // kFedCmIdpSigninStatusEnabled takes precedence over this feature flag. BASE_FEATURE(kFedCmIdpSigninStatusMetrics, - "FedCmIdpSigninStatusMetrics", - base::FEATURE_ENABLED_BY_DEFAULT); + "FedCmIdpSigninStatusMetrics", // disabled + base::FEATURE_DISABLED_BY_DEFAULT); // by default // If enabled, limits the number of FLEDGE auctions that can be run between page // load and unload -- any attempt to run more than this number of auctions will diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc @@ -380,9 +380,9 @@ BASE_FEATURE(kFedCmSelectiveDisclosure, // Enables the IDP signin status API for use with FedCM, including avoiding // network requests when not signed in and mismatch handling. -BASE_FEATURE(kFedCmIdpSigninStatusEnabled, - "FedCmIdpSigninStatusEnabled", - base::FEATURE_DISABLED_BY_DEFAULT); +BASE_FEATURE(kFedCmIdpSigninStatusEnabled, // disabled + "FedCmIdpSigninStatusEnabled", // by default + base::FEATURE_DISABLED_BY_DEFAULT); // on bromite // Enables bypassing the well-known file enforcement. BASE_FEATURE(kFedCmWithoutWellKnownEnforcement, diff --git a/net/base/url_util.cc b/net/base/url_util.cc --- a/net/base/url_util.cc +++ b/net/base/url_util.cc @@ -489,27 +489,6 @@ bool HasGoogleHost(const GURL& url) { } bool IsGoogleHost(base::StringPiece host) { - static const char* kGoogleHostSuffixes[] = { - ".google.com", - ".youtube.com", - ".gmail.com", - ".doubleclick.net", - ".gstatic.com", - ".googlevideo.com", - ".googleusercontent.com", - ".googlesyndication.com", - ".google-analytics.com", - ".googleadservices.com", - ".googleapis.com", - ".ytimg.com", - }; - for (const char* suffix : kGoogleHostSuffixes) { - // Here it's possible to get away with faster case-sensitive comparisons - // because the list above is all lowercase, and a GURL's host name will - // always be canonicalized to lowercase as well. - if (base::EndsWith(host, suffix)) - return true; - } return false; } diff --git a/services/network/network_context.cc b/services/network/network_context.cc --- a/services/network/network_context.cc +++ b/services/network/network_context.cc @@ -2846,7 +2846,7 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext( } #endif // BUILDFLAG(IS_CT_SUPPORTED) - if (params_->enable_domain_reliability) { + if ((false) /*params_->enable_domain_reliability*/) { domain_reliability_monitor_ = std::make_unique( result.url_request_context.get(), -- 2.25.1