Files
cromite/build/patches/autofill-miscellaneous.patch
T
2025-06-24 16:26:13 +02:00

323 lines
15 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_password_manager_client.cc | 4 --
.../ui/autofill/chrome_autofill_client.cc | 9 ---
.../ui/autofill/chrome_autofill_client.h | 1 -
.../browser/android_autofill_client.cc | 11 ----
.../browser/android_autofill_client.h | 1 -
.../autofill_crowdsourcing_manager.cc | 63 ++-----------------
.../autofill_crowdsourcing_manager.h | 2 -
.../browser/crowdsourcing/votes_uploader.cc | 3 -
.../browser/foundations/autofill_client.h | 4 --
.../browser/foundations/autofill_manager.cc | 11 ----
.../autofill/core/common/autofill_features.cc | 2 +
.../autofill/core/common/autofill_prefs.cc | 8 +--
.../password_generation_frame_helper.cc | 5 --
13 files changed, 11 insertions(+), 113 deletions(-)
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc
--- a/chrome/browser/password_manager/chrome_password_manager_client.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -1074,10 +1074,6 @@ ChromePasswordManagerClient::GetHttpAuthManager() {
autofill::AutofillCrowdsourcingManager*
ChromePasswordManagerClient::GetAutofillCrowdsourcingManager() {
- if (auto* client =
- autofill::ContentAutofillClient::FromWebContents(web_contents())) {
- return &client->GetCrowdsourcingManager();
- }
return nullptr;
}
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
@@ -393,15 +393,6 @@ ChromeAutofillClient::GetURLLoaderFactory() {
->GetURLLoaderFactoryForBrowserProcess();
}
-AutofillCrowdsourcingManager& ChromeAutofillClient::GetCrowdsourcingManager() {
- if (!crowdsourcing_manager_) {
- // Lazy initialization to avoid virtual function calls in the constructor.
- crowdsourcing_manager_ =
- std::make_unique<AutofillCrowdsourcingManager>(this, GetChannel());
- }
- return *crowdsourcing_manager_;
-}
-
VotesUploader& ChromeAutofillClient::GetVotesUploader() {
return votes_uploader_;
}
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.h b/chrome/browser/ui/autofill/chrome_autofill_client.h
--- a/chrome/browser/ui/autofill/chrome_autofill_client.h
+++ b/chrome/browser/ui/autofill/chrome_autofill_client.h
@@ -106,7 +106,6 @@ class ChromeAutofillClient : public ContentAutofillClient,
version_info::Channel GetChannel() const final;
bool IsOffTheRecord() const final;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() final;
- AutofillCrowdsourcingManager& GetCrowdsourcingManager() final;
VotesUploader& GetVotesUploader() final;
AutofillOptimizationGuide* GetAutofillOptimizationGuide() const final;
FieldClassificationModelHandler* GetAutofillFieldClassificationModelHandler()
diff --git a/components/android_autofill/browser/android_autofill_client.cc b/components/android_autofill/browser/android_autofill_client.cc
--- a/components/android_autofill/browser/android_autofill_client.cc
+++ b/components/android_autofill/browser/android_autofill_client.cc
@@ -73,17 +73,6 @@ AndroidAutofillClient::GetURLLoaderFactory() {
->GetURLLoaderFactoryForBrowserProcess();
}
-autofill::AutofillCrowdsourcingManager&
-AndroidAutofillClient::GetCrowdsourcingManager() {
- if (!crowdsourcing_manager_) {
- // Lazy initialization to avoid virtual function calls in the constructor.
- crowdsourcing_manager_ =
- std::make_unique<autofill::AutofillCrowdsourcingManager>(this,
- GetChannel());
- }
- return *crowdsourcing_manager_;
-}
-
autofill::VotesUploader& AndroidAutofillClient::GetVotesUploader() {
return votes_uploader_;
}
diff --git a/components/android_autofill/browser/android_autofill_client.h b/components/android_autofill/browser/android_autofill_client.h
--- a/components/android_autofill/browser/android_autofill_client.h
+++ b/components/android_autofill/browser/android_autofill_client.h
@@ -87,7 +87,6 @@ class AndroidAutofillClient : public autofill::ContentAutofillClient {
const std::string& GetAppLocale() const final;
bool IsOffTheRecord() const final;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() final;
- autofill::AutofillCrowdsourcingManager& GetCrowdsourcingManager() final;
autofill::VotesUploader& GetVotesUploader() override;
autofill::PersonalDataManager& GetPersonalDataManager() final;
autofill::ValuablesDataManager* GetValuablesDataManager() override;
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
@@ -513,33 +513,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();
- }();
- 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) {
@@ -571,15 +544,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.
- return google_apis::GetAPIKey(channel);
+ return std::string();
}
std::optional<std::vector<variations::VariationID>>& GetActiveExperiments() {
@@ -899,31 +864,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(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
@@ -32,8 +32,6 @@ namespace autofill {
class AutofillClient;
-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/browser/crowdsourcing/votes_uploader.cc b/components/autofill/core/browser/crowdsourcing/votes_uploader.cc
--- a/components/autofill/core/browser/crowdsourcing/votes_uploader.cc
+++ b/components/autofill/core/browser/crowdsourcing/votes_uploader.cc
@@ -409,9 +409,6 @@ void VotesUploader::UploadVote(
client_->GetUkmRecorder(), ukm_source_id, *submitted_form,
submission_timestamp);
}
- client_->GetCrowdsourcingManager().StartUploadRequest(
- std::move(upload_contents), submitted_form->submission_source(),
- /*is_password_manager_upload=*/false);
}
} // namespace autofill
diff --git a/components/autofill/core/browser/foundations/autofill_client.h b/components/autofill/core/browser/foundations/autofill_client.h
--- a/components/autofill/core/browser/foundations/autofill_client.h
+++ b/components/autofill/core/browser/foundations/autofill_client.h
@@ -249,10 +249,6 @@ class AutofillClient {
// Returns the VotesUploader.
virtual VotesUploader& GetVotesUploader() = 0;
- // Returns the AutofillCrowdsourcingManager for communication with the
- // Autofill server.
- virtual AutofillCrowdsourcingManager& GetCrowdsourcingManager() = 0;
-
// Gets the PersonalDataManager instance associated with the original Chrome
// profile.
// To distinguish between (non-)incognito mode when deciding to persist data,
diff --git a/components/autofill/core/browser/foundations/autofill_manager.cc b/components/autofill/core/browser/foundations/autofill_manager.cc
--- a/components/autofill/core/browser/foundations/autofill_manager.cc
+++ b/components/autofill/core/browser/foundations/autofill_manager.cc
@@ -307,17 +307,6 @@ void AutofillManager::OnFormsParsed(const std::vector<FormData>& forms) {
if (base::FeatureList::IsEnabled(features::test::kShowDomNodeIDs)) {
driver().ExposeDomNodeIDs();
}
-
- // Query the server if at least one of the forms was parsed.
- if (!queryable_forms.empty()) {
- NotifyObservers(&Observer::OnBeforeLoadedServerPredictions);
- // If language detection is currently reparsing the form, wait until the
- // server response is processed, to ensure server predictions are not lost.
- client().GetCrowdsourcingManager().StartQueryRequest(
- queryable_forms, driver().GetIsolationInfo(),
- AfterParsingFinishes(base::BindOnce(
- &AutofillManager::OnLoadedServerPredictions, GetWeakPtr())));
- }
}
void AutofillManager::OnCaretMovedInFormField(const FormData& form,
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
@@ -942,6 +942,8 @@ BASE_FEATURE(kAutofillUploadThrottling,
"AutofillUploadThrottling",
base::FEATURE_ENABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_DISABLED(kAutofillServerCommunication);
+SET_CROMITE_FEATURE_ENABLED(kAutofillPopupZOrderSecuritySurface);
} // 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
@@ -29,7 +29,7 @@ constexpr char kAutofillRanQuasiDuplicateExtraDeduplication[] =
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
// Synced prefs. Used for cross-device choices, e.g., credit card Autofill.
registry->RegisterBooleanPref(
- kAutofillProfileEnabled, true,
+ kAutofillProfileEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterIntegerPref(
kAutofillLastVersionDeduped, 0,
@@ -38,10 +38,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
kAutofillHasSeenIban, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
- kAutofillCreditCardEnabled, true,
+ kAutofillCreditCardEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
- kAutofillPaymentCvcStorage, true,
+ kAutofillPaymentCvcStorage, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
kAutofillPaymentCardBenefits, true,
@@ -83,7 +83,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#endif
// Deprecated prefs registered for migration.
- registry->RegisterBooleanPref(kAutofillEnabledDeprecated, true);
+ registry->RegisterBooleanPref(kAutofillEnabledDeprecated, false);
registry->RegisterStringPref(kAutofillAblationSeedPref, "");
registry->RegisterBooleanPref(kAutofillRanQuasiDuplicateExtraDeduplication,
false);
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
@@ -101,7 +101,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;
@@ -111,10 +110,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(
--