Files
cromite/build/patches/autofill-miscellaneous.patch
2024-03-15 16:24:42 +01:00

245 lines
11 KiB
Diff

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 <jengelh@inai.de>)
Disable autofill download manager (Jan Engelhardt <jengelh@inai.de>)
Disable autofill assistant and CC (csagan5)
Disable autofill server communication by default (Daniel Micay <danielmicay@gmail.com>)
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 | 2 +-
.../ui/autofill/chrome_autofill_client.cc | 7 +-
.../core/browser/browser_autofill_manager.h | 4 +-
.../autofill_crowdsourcing_manager.cc | 69 ++-----------------
.../autofill_crowdsourcing_manager.h | 2 -
.../autofill/core/common/autofill_features.cc | 1 +
.../autofill/core/common/autofill_prefs.cc | 10 +--
.../password_generation_frame_helper.cc | 4 --
8 files changed, 15 insertions(+), 84 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
@@ -1344,7 +1344,7 @@ void RegisterProfilePrefsForMigration(
#endif
// Deprecated 12/2023.
- registry->RegisterBooleanPref(kDownloadDuplicateFilePromptEnabled, true);
+ registry->RegisterBooleanPref(kDownloadDuplicateFilePromptEnabled, false);
// Deprecated 12/2023.
registry->RegisterInt64Pref(kModelQualityLoggingClientId, true);
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
@@ -242,12 +242,7 @@ ChromeAutofillClient::GetURLLoaderFactory() {
}
AutofillCrowdsourcingManager* ChromeAutofillClient::GetCrowdsourcingManager() {
- if (!crowdsourcing_manager_) {
- // Lazy initialization to avoid virtual function calls in the constructor.
- crowdsourcing_manager_ = std::make_unique<AutofillCrowdsourcingManager>(
- this, GetChannel(), GetLogManager());
- }
- return crowdsourcing_manager_.get();
+ return nullptr;
}
AutofillOptimizationGuide* ChromeAutofillClient::GetAutofillOptimizationGuide()
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
@@ -577,9 +577,9 @@ class BrowserAutofillManager : public AutofillManager {
manual_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 shown Autofill suggestions at least once?
- bool did_show_suggestions_ = false;
+ bool did_show_suggestions_ = true;
// Has the user manually edited at least one form field among the autofillable
// ones?
bool user_did_type_ = false;
diff --git a/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc b/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc
--- a/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc
+++ b/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc
@@ -475,33 +475,6 @@ std::optional<std::string> 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(RequestType::kRequestQuery, "1234", "GET") will return
-// "/v1/pages/1234".
-// * GetAPIMethodUrl(RequestType::kRequestQuery, "1234", "POST") will return
-// "/v1/pages:get".
-// * GetAPIMethodUrl(RequestType::kRequestUpload, "", "POST") will return
-// "/v1/forms:vote".
-std::string GetAPIMethodUrl(RequestType type,
- std::string_view resource_id,
- std::string_view method) {
- const char* api_method_url = [&] {
- switch (type) {
- case RequestType::kRequestQuery:
- return method == "POST" ? "/v1/pages:get" : "/v1/pages";
- case RequestType::kRequestUpload:
- 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.
std::optional<std::string> GetAPIBodyPayload(std::string payload,
RequestType type) {
@@ -533,18 +506,7 @@ std::optional<std::string> GetAPIQueryPayload(
}
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();
}
std::optional<std::vector<variations::VariationID>>& GetActiveExperiments() {
@@ -774,34 +736,13 @@ size_t AutofillCrowdsourcingManager::GetPayloadLength(
std::tuple<GURL, std::string> AutofillCrowdsourcingManager::GetRequestURLAndMethod(
const FormRequestData& request_data) const {
- // ID of the resource to add to the API request URL. Nothing will be added if
- // `resource_id` is empty.
- std::string resource_id;
- std::string method = "POST";
-
- if (request_data.request_type == RequestType::kRequestQuery) {
- if (GetPayloadLength(request_data.payload) <= kMaxQueryGetSize) {
- resource_id = request_data.payload;
- method = "GET";
- base::UmaHistogramBoolean(kUmaApiUrlIsTooLong, false);
- } else {
- base::UmaHistogramBoolean(kUmaApiUrlIsTooLong, true);
- }
- base::UmaHistogramBoolean(kUmaMethod, method != "GET");
- }
-
- // Make the canonical URL to query the API, e.g.,
- // https://autofill.googleapis.com/v1/forms/1234?alt=proto.
- GURL url = autofill_server_url_.Resolve(
- GetAPIMethodUrl(request_data.request_type, resource_id, method));
-
- // Add the query parameter to set the response format to a serialized proto.
- url = net::AppendQueryParameter(url, "alt", "proto");
-
- return std::make_tuple(std::move(url), std::move(method));
+ std::string method2("GET");
+ GURL url2 = GURL("about:blank");
+ return std::make_tuple(std::move(url2), std::move(method2));
}
bool AutofillCrowdsourcingManager::StartRequest(FormRequestData request_data) {
+ if ((true)) return false;
// kRequestUploads 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/crowdsourcing/autofill_crowdsourcing_manager.h b/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.h
--- a/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.h
+++ b/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.h
@@ -33,8 +33,6 @@ namespace autofill {
class AutofillClient;
class LogManager;
-inline 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/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
@@ -775,6 +775,7 @@ BASE_FEATURE(kAutofillUploadThrottling,
"AutofillUploadThrottling",
base::FEATURE_ENABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_DISABLED(kAutofillServerCommunication);
} // namespace test
} // namespace autofill::features
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
@@ -39,7 +39,7 @@ int GetSyncTransportOptInBitFieldForAccount(const PrefService* prefs,
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,
@@ -48,10 +48,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
prefs::kAutofillHasSeenIban, false,
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);
registry->RegisterBooleanPref(
kAutofillPaymentCardBenefits, true,
@@ -94,9 +94,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);
registry->RegisterIntegerPref(
prefs::kAutofillLastVersionDisusedAddressesDeleted, 0);
registry->RegisterIntegerPref(
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> logger;
@@ -105,9 +104,6 @@ bool PasswordGenerationFrameHelper::IsGenerationEnabled(
}
GURL url = driver_->GetLastCommittedURL();
- if (url.DomainIs("google.com"))
- return false;
-
if (!password_manager_util::IsAbleToSavePasswords(client_)) {
if (logger) {
logger->LogMessage(
--