Skip to content

Commit

Permalink
ungoogled-chromium: no special hosts/domains
Browse files Browse the repository at this point in the history
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
Change-Id: I3dae6dbb89a90686eb1fc199685a3e7a06f8cfc7
  • Loading branch information
csagan5 authored and chirayudesai committed Apr 2, 2024
1 parent 0693380 commit f214c25
Show file tree
Hide file tree
Showing 52 changed files with 59 additions and 809 deletions.
8 changes: 0 additions & 8 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,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",
Expand Down Expand Up @@ -1956,7 +1952,6 @@ static_library("browser") {
"//chrome/browser/autofill",
"//chrome/browser/devtools",
"//chrome/browser/favicon",
"//chrome/browser/google",

# Circular dependency due to SystemNetworkContextManager.
"//chrome/browser/image_fetcher",
Expand Down Expand Up @@ -1985,7 +1980,6 @@ static_library("browser") {

public_deps = [
"//base",
"//chrome/browser/google",
"//chrome/browser/headless",
"//chrome/browser/profiles",
"//chrome/common",
Expand Down Expand Up @@ -7790,8 +7784,6 @@ static_library("browser") {
"supervised_user/chrome_supervised_user_web_content_handler_base.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",
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/android/metrics/uma_session_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,6 @@ static void JNI_UmaSessionStats_ChangeMetricsReportingConsent(
jint called_from) {
UpdateMetricsPrefsOnPermissionChange(
consent, static_cast<ChangeMetricsReportingStateCalledFrom>(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.
Expand Down
39 changes: 5 additions & 34 deletions chrome/browser/android/signin/signin_manager_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,11 @@ class ProfileDataRemover : public content::BrowsingDataRemover::Observer {
remover_(profile->GetBrowsingDataRemover()) {
remover_->AddObserver(this);

if (all_data) {
chrome_browsing_data_remover::DataType removed_types =
chrome_browsing_data_remover::ALL_DATA_TYPES;
if (password_manager::UsesSplitStoresAndUPMForLocal(
profile_->GetPrefs())) {
// If usesSplitStoresAndUPMForLocal() is true, browser sign-in won't
// upload existing passwords, so there's no reason to wipe them
// immediately before. Similarly, on browser sign-out, account passwords
// should survive (outside of the browser) to be used by other apps,
// until system-level sign-out. In other words, the browser has no
// business deleting any passwords here.
removed_types &= ~chrome_browsing_data_remover::DATA_TYPE_PASSWORDS;
}
remover_->RemoveAndReply(base::Time(), base::Time::Max(), removed_types,
chrome_browsing_data_remover::ALL_ORIGIN_TYPES,
this);
} else {
std::unique_ptr<content::BrowsingDataFilterBuilder> 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);
}
chrome_browsing_data_remover::DataType removed_types =
chrome_browsing_data_remover::ALL_DATA_TYPES;
remover_->RemoveAndReply(base::Time(), base::Time::Max(), removed_types,
chrome_browsing_data_remover::ALL_ORIGIN_TYPES,
this);
}

ProfileDataRemover(const ProfileDataRemover&) = delete;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ BrowserProcessImpl::component_updater() {
std::make_unique<component_updater::TimerUpdateScheduler>();

std::string brand;
google_brand::GetBrand(&brand);
component_updater_ = component_updater::ComponentUpdateServiceFactory(
component_updater::MakeChromeComponentUpdaterConfigurator(
base::CommandLine::ForCurrentProcess(),
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,6 @@ void ProcessSingletonNotificationCallbackImpl(

StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
command_line, current_directory, startup_profile_path_info);

// Record now as the last successful chrome start.
if constexpr (kShouldRecordActiveUse) {
GoogleUpdateSettings::SetLastRunTime();
}
}
#endif // BUILDFLAG(ENABLE_PROCESS_SINGLETON)

Expand Down Expand Up @@ -1781,11 +1776,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
upgrade_util::SaveLastModifiedTimeOfExe();
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)

// Record now as the last successful chrome start.
if constexpr (kShouldRecordActiveUse) {
GoogleUpdateSettings::SetLastRunTime();
}

// Create the RunLoop for MainMessageLoopRun() to use and transfer
// ownership of the browser's lifetime to the BrowserProcess.
DCHECK(!GetMainRunLoopInstance());
Expand Down
35 changes: 3 additions & 32 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kForcePNaClSubzero,
#endif
switches::kForceUIDirection,
switches::kIgnoreGooglePortNumbers,
switches::kJavaScriptHarmony,
switches::kEnableExperimentalWebAssemblyFeatures,
embedder_support::kOriginTrialDisabledFeatures,
Expand Down Expand Up @@ -5010,12 +5009,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
}
#endif

#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
MaybeAddThrottle(
SupervisedUserGoogleAuthNavigationThrottle::MaybeCreate(handle),
&throttles);
#endif

if (auto* throttle_manager =
subresource_filter::ContentSubresourceFilterThrottleManager::
FromNavigationHandle(*handle)) {
Expand Down Expand Up @@ -5558,7 +5551,8 @@ GetClientDataHeader(int frame_tree_node_id) {
}
#endif

std::unique_ptr<blink::URLLoaderThrottle> CreateGoogleURLLoaderThrottle(

#if 0 // std::unique_ptr<blink::URLLoaderThrottle> CreateGoogleURLLoaderThrottle(
#if BUILDFLAG(IS_ANDROID)
const std::string& client_data_header,
#endif
Expand Down Expand Up @@ -5597,7 +5591,7 @@ std::unique_ptr<blink::URLLoaderThrottle> CreateGoogleURLLoaderThrottle(
std::move(bound_session_request_throttled_handler),
#endif
std::move(dynamic_params));
}
#endif // }

std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
ChromeContentBrowserClient::CreateURLLoaderThrottles(
Expand Down Expand Up @@ -5645,15 +5639,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);
Expand Down Expand Up @@ -5708,20 +5693,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;
}

Expand Down
33 changes: 2 additions & 31 deletions chrome/browser/domain_reliability/service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion chrome/browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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";
Expand Down Expand Up @@ -627,10 +626,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(
Expand Down
9 changes: 0 additions & 9 deletions chrome/browser/first_run/first_run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/google/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -82,7 +82,7 @@ source_set("unit_tests") {
sources = [ "google_update_settings_unittest.cc" ]

deps = [
":google",
":google_UNUSED",
"//base",
"//base/test:test_support",
"//chrome/common:constants",
Expand Down
22 changes: 0 additions & 22 deletions chrome/browser/long_screenshots/long_screenshots_tab_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/metrics/chrome_metrics_service_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ ChromeMetricsServiceClient::GetNetworkTimeTracker() {
}

bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) {
return google_brand::GetBrand(brand_code);
return false;
}

metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -343,7 +340,7 @@ ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
cc::switches::kEnableGpuBenchmarking),
},
base::BindRepeating(&PostStoreMetricsClientInfo),
base::BindRepeating(&GoogleUpdateSettings::LoadMetricsClientInfo),
metrics::MetricsStateManager::LoadClientInfoCallback(),
client_id);
}
return metrics_state_manager_.get();
Expand Down
Loading

0 comments on commit f214c25

Please sign in to comment.