From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Mon, 11 Apr 2022 23:29:29 +0200 Subject: autofill: miscellaneous Make sure that autofill is disabled by default (Jan Engelhardt ) Disable autofill download manager (Jan Engelhardt ) Disable autofill assistant and CC (csagan5) Disable autofill server communication by default (Daniel Micay ) Do not skip google.com domains for password generation (csagan5) License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- chrome/browser/prefs/browser_prefs.cc | 6 +-- .../ui/autofill/chrome_autofill_client.cc | 7 +-- .../core/browser/autofill_download_manager.cc | 43 +++---------------- .../core/browser/autofill_download_manager.h | 2 - .../core/browser/browser_autofill_manager.h | 4 +- .../autofill/core/common/autofill_features.cc | 4 +- .../autofill/core/common/autofill_prefs.cc | 10 ++--- .../password_generation_frame_helper.cc | 4 -- 8 files changed, 20 insertions(+), 60 deletions(-) diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -1133,11 +1133,11 @@ void RegisterProfilePrefsForMigration( PrefRegistry::LOSSY_PREF); // Deprecated 11/2022. - registry->RegisterBooleanPref(kAutofillAssistantEnabled, true); + registry->RegisterBooleanPref(kAutofillAssistantEnabled, false); registry->RegisterBooleanPref(kAutofillAssistantConsent, false); - registry->RegisterBooleanPref(kAutofillAssistantTriggerScriptsEnabled, true); + registry->RegisterBooleanPref(kAutofillAssistantTriggerScriptsEnabled, false); registry->RegisterBooleanPref(kAutofillAssistantTriggerScriptsIsFirstTimeUser, - true); + false); // Deprecated 12/2022. registry->RegisterBooleanPref(kAutofillWalletImportStorageCheckboxState, diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc --- a/chrome/browser/ui/autofill/chrome_autofill_client.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc @@ -215,12 +215,7 @@ ChromeAutofillClient::GetURLLoaderFactory() { } AutofillDownloadManager* ChromeAutofillClient::GetDownloadManager() { - if (!download_manager_) { - // Lazy initialization to avoid virtual function calls in the constructor. - download_manager_ = std::make_unique( - this, GetChannel(), GetLogManager()); - } - return download_manager_.get(); + return nullptr; } AutofillOptimizationGuide* ChromeAutofillClient::GetAutofillOptimizationGuide() diff --git a/components/autofill/core/browser/autofill_download_manager.cc b/components/autofill/core/browser/autofill_download_manager.cc --- a/components/autofill/core/browser/autofill_download_manager.cc +++ b/components/autofill/core/browser/autofill_download_manager.cc @@ -458,29 +458,6 @@ absl::optional GetUploadPayloadForApi( return std::move(payload); } -// Gets an API method URL given its type (query or upload), an optional -// resource ID, and the HTTP method to be used. -// Example usage: -// * GetAPIMethodUrl(REQUEST_QUERY, "1234", "GET") will return "/v1/pages/1234". -// * GetAPIMethodUrl(REQUEST_QUERY, "1234", "POST") will return "/v1/pages:get". -// * GetAPIMethodUrl(REQUEST_UPLOAD, "", "POST") will return "/v1/forms:vote". -std::string GetAPIMethodUrl(AutofillDownloadManager::RequestType type, - base::StringPiece resource_id, - base::StringPiece method) { - const char* api_method_url = [&] { - switch (type) { - case AutofillDownloadManager::REQUEST_QUERY: - return method == "POST" ? "/v1/pages:get" : "/v1/pages"; - case AutofillDownloadManager::REQUEST_UPLOAD: - return "/v1/forms:vote"; - } - NOTREACHED_NORETURN(); - }(); - if (resource_id.empty()) { - return std::string(api_method_url); - } - return base::StrCat({api_method_url, "/", resource_id}); -} // Gets HTTP body payload for API POST request. absl::optional GetAPIBodyPayload( @@ -521,18 +498,7 @@ bool IsRawMetadataUploadingEnabled(version_info::Channel channel) { } std::string GetAPIKeyForUrl(version_info::Channel channel) { - // First look if we can get API key from command line flag. - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kAutofillAPIKey)) { - return command_line.GetSwitchValueASCII(switches::kAutofillAPIKey); - } - - // Get the API key from Chrome baked keys. - if (channel == version_info::Channel::STABLE) { - return google_apis::GetAPIKey(); - } - return google_apis::GetNonStableAPIKey(); + return std::string(); } } // namespace @@ -744,6 +710,7 @@ std::tuple AutofillDownloadManager::GetRequestURLAndMethod( // ID of the resource to add to the API request URL. Nothing will be added if // |resource_id| is empty. std::string resource_id; +#if 0 std::string method = "POST"; if (request_data.request_type == AutofillDownloadManager::REQUEST_QUERY) { @@ -764,11 +731,15 @@ std::tuple AutofillDownloadManager::GetRequestURLAndMethod( // Add the query parameter to set the response format to a serialized proto. url = net::AppendQueryParameter(url, "alt", "proto"); - +#else + std::string method("GET"); + GURL url = GURL("about:blank"); +#endif return std::make_tuple(std::move(url), std::move(method)); } bool AutofillDownloadManager::StartRequest(FormRequestData request_data) { + if ((true)) return false; // REQUEST_UPLOADs take no IsolationInfo because Password Manager uploads when // RenderFrameHostImpl::DidCommitNavigation() is called, in which case // AutofillDriver::IsolationInfo() may crash because there is no committing diff --git a/components/autofill/core/browser/autofill_download_manager.h b/components/autofill/core/browser/autofill_download_manager.h --- a/components/autofill/core/browser/autofill_download_manager.h +++ b/components/autofill/core/browser/autofill_download_manager.h @@ -38,8 +38,6 @@ namespace autofill { class AutofillClient; class LogManager; -constexpr size_t kMaxQueryGetSize = 10240; // 10 KiB - // A helper to make sure that tests which modify the set of active autofill // experiments do not interfere with one another. struct ScopedActiveAutofillExperiments { diff --git a/components/autofill/core/browser/browser_autofill_manager.h b/components/autofill/core/browser/browser_autofill_manager.h --- a/components/autofill/core/browser/browser_autofill_manager.h +++ b/components/autofill/core/browser/browser_autofill_manager.h @@ -766,9 +766,9 @@ class BrowserAutofillManager : public AutofillManager, autocomplete_unrecognized_fallback_logger_; // Have we logged whether Autofill is enabled for this page load? - bool has_logged_autofill_enabled_ = false; + bool has_logged_autofill_enabled_ = true; // Have we logged an address suggestions count metric for this page? - bool has_logged_address_suggestions_count_ = false; + bool has_logged_address_suggestions_count_ = true; // Have we shown Autofill suggestions at least once? bool did_show_suggestions_ = false; // Has the user manually edited at least one form field among the autofillable diff --git a/components/autofill/core/common/autofill_features.cc b/components/autofill/core/common/autofill_features.cc --- a/components/autofill/core/common/autofill_features.cc +++ b/components/autofill/core/common/autofill_features.cc @@ -797,8 +797,8 @@ BASE_FEATURE(kAutofillLogToTerminal, // "upload" resources. // i.e., https://other.autofill.server:port/tbproxy/af/ BASE_FEATURE(kAutofillServerCommunication, - "AutofillServerCommunication", - base::FEATURE_ENABLED_BY_DEFAULT); + "AutofillServerCommunication", // disabled by default + base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite // Controls attaching the autofill type predictions to their respective // element in the DOM. diff --git a/components/autofill/core/common/autofill_prefs.cc b/components/autofill/core/common/autofill_prefs.cc --- a/components/autofill/core/common/autofill_prefs.cc +++ b/components/autofill/core/common/autofill_prefs.cc @@ -144,7 +144,7 @@ const char kAutofillUsingVirtualViewStructure[] = void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { // Synced prefs. Used for cross-device choices, e.g., credit card Autofill. registry->RegisterBooleanPref( - prefs::kAutofillProfileEnabled, true, + prefs::kAutofillProfileEnabled, false, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterIntegerPref( prefs::kAutofillLastVersionDeduped, 0, @@ -156,10 +156,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { prefs::kAutofillLastVersionDisusedAddressesDeleted, 0, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterBooleanPref( - prefs::kAutofillCreditCardEnabled, true, + prefs::kAutofillCreditCardEnabled, false, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterBooleanPref( - prefs::kAutofillPaymentCvcStorage, true, + prefs::kAutofillPaymentCvcStorage, false, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); // Non-synced prefs. Used for per-device choices, e.g., signin promo. @@ -201,9 +201,9 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { #endif // Deprecated prefs registered for migration. - registry->RegisterBooleanPref(prefs::kAutofillEnabledDeprecated, true); + registry->RegisterBooleanPref(prefs::kAutofillEnabledDeprecated, false); registry->RegisterBooleanPref(prefs::kAutofillOrphanRowsRemoved, false); - registry->RegisterBooleanPref(prefs::kAutofillIbanEnabled, true); + registry->RegisterBooleanPref(prefs::kAutofillIbanEnabled, false); #if BUILDFLAG(IS_ANDROID) registry->RegisterBooleanPref(prefs::kAutofillUsingVirtualViewStructure, diff --git a/components/password_manager/core/browser/password_generation_frame_helper.cc b/components/password_manager/core/browser/password_generation_frame_helper.cc --- a/components/password_manager/core/browser/password_generation_frame_helper.cc +++ b/components/password_manager/core/browser/password_generation_frame_helper.cc @@ -95,7 +95,6 @@ void PasswordGenerationFrameHelper::ProcessPasswordRequirements( // In order for password generation to be enabled, we need to make sure: // (1) Password sync is enabled, and // (2) Password saving is enabled -// (3) The current page is not *.google.com. bool PasswordGenerationFrameHelper::IsGenerationEnabled( bool log_debug_data) const { std::unique_ptr logger; @@ -105,9 +104,6 @@ bool PasswordGenerationFrameHelper::IsGenerationEnabled( } GURL url = driver_->GetLastCommittedURL(); - if (url.DomainIs("google.com")) - return false; - if (!client_->IsSavingAndFillingEnabled(url)) { if (logger) logger->LogMessage(Logger::STRING_GENERATION_DISABLED_SAVING_DISABLED); -- 2.25.1