autofill-disable-autofill-download-manager.patch

This commit is contained in:
none 2021-03-01 12:07:10 +01:00
parent a1e517c91c
commit a28005974f

View file

@ -4,113 +4,57 @@ Subject: autofill: disable autofill download manager
Disables the autofill download manager (trk:158).
---
.../core/browser/autofill_download_manager.cc | 61 +++----------------
.../autofill/core/browser/autofill_manager.cc | 18 ------
2 files changed, 7 insertions(+), 72 deletions(-)
.../core/browser/autofill_download_manager.h | 25 ++++++++++---------
.../autofill/core/browser/autofill_handler.cc | 17 -------------
2 files changed, 13 insertions(+), 29 deletions(-)
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
@@ -65,7 +65,6 @@ constexpr std::pair<int, int> kAutofillExperimentRanges[] = {
{3314445, 3314448}, {3314854, 3314883},
};
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
@@ -77,18 +77,6 @@ class AutofillDownloadManager {
virtual ~Observer() {}
};
-const size_t kMaxQueryGetSize = 1400; // 1.25 KiB
const size_t kAutofillDownloadManagerMaxFormCacheSize = 16;
const size_t kMaxFieldsPerQueryRequest = 100;
- // |driver| must outlive this instance.
- // |observer| - observer to notify on successful completion or error.
- // Uses an API callback function that gives an empty string.
- AutofillDownloadManager(AutofillDriver* driver, Observer* observer);
- // |driver| must outlive this instance.
- // |observer| - observer to notify on successful completion or error.
- // |api_key| - API key to add to API request query parameters. Will only take
- // effect if using API.
- AutofillDownloadManager(AutofillDriver* driver,
- Observer* observer,
- const std::string& api_key,
- LogManager* log_manager);
virtual ~AutofillDownloadManager();
@@ -511,35 +510,6 @@ bool GetUploadPayloadForApi(const AutofillUploadContents& upload,
return upload_request.SerializeToString(payload);
}
// Starts a query request to Autofill servers. The observer is called with the
@@ -130,6 +118,19 @@ class AutofillDownloadManager {
virtual size_t GetPayloadLength(base::StringPiece payload) const;
-// 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;
- if (type == AutofillDownloadManager::REQUEST_QUERY) {
- if (method == "POST") {
- api_method_url = "/v1/pages:get";
- } else {
- api_method_url = "/v1/pages";
- }
- } else if (type == AutofillDownloadManager::REQUEST_UPLOAD) {
- api_method_url = "/v1/forms:vote";
- } else {
- // This should not be reached, but we never know.
- NOTREACHED() << "Request of type " << type << " is invalid";
- return "";
- }
- 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.
bool GetAPIBodyPayload(const std::string& payload,
AutofillDownloadManager::RequestType type,
@@ -769,6 +739,7 @@ size_t AutofillDownloadManager::GetPayloadLength(
std::tuple<GURL, std::string> AutofillDownloadManager::GetRequestURLAndMethod(
const FormRequestData& request_data) const {
+#if 0
std::string method("POST");
std::string query_str;
@@ -791,36 +762,18 @@ std::tuple<GURL, std::string> AutofillDownloadManager::GetRequestURLAndMethod(
GURL url = autofill_server_url_
.Resolve(RequestTypeToString(request_data.request_type))
.ReplaceComponents(replacements);
+#else
+ std::string method("GET");
+ GURL url = GURL("about:blank");
+#endif
return std::make_tuple(std::move(url), std::move(method));
}
std::tuple<GURL, std::string>
AutofillDownloadManager::GetRequestURLAndMethodForApi(
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 == AutofillDownloadManager::REQUEST_QUERY) {
- if (GetPayloadLength(request_data.payload) <= kMaxAPIQueryGetSize &&
- base::FeatureList::IsEnabled(features::kAutofillCacheQueryResponses)) {
- resource_id = request_data.payload;
- method = "GET";
- UMA_HISTOGRAM_BOOLEAN("Autofill.Query.ApiUrlIsTooLong", false);
- } else {
- UMA_HISTOGRAM_BOOLEAN("Autofill.Query.ApiUrlIsTooLong", true);
- }
- UMA_HISTOGRAM_BOOLEAN("Autofill.Query.Method", (method == "GET") ? 0 : 1);
- }
-
- // 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");
+ std::string method("GET");
+ GURL url = GURL("about:blank");
return std::make_tuple(std::move(url), std::move(method));
}
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -187,19 +187,6 @@ void LogDeveloperEngagementUkm(ukm::UkmRecorder* ukm_recorder,
}
private:
+ // |driver| must outlive this instance.
+ // |observer| - observer to notify on successful completion or error.
+ // Uses an API callback function that gives an empty string.
+ AutofillDownloadManager(AutofillDriver* driver, Observer* observer);
+ // |driver| must outlive this instance.
+ // |observer| - observer to notify on successful completion or error.
+ // |api_key| - API key to add to API request query parameters. Will only take
+ // effect if using API.
+ AutofillDownloadManager(AutofillDriver* driver,
+ Observer* observer,
+ const std::string& api_key,
+ LogManager* log_manager);
+
friend class AutofillDownloadManagerTest;
friend struct ScopedActiveAutofillExperiments;
FRIEND_TEST_ALL_PREFIXES(AutofillDownloadManagerTest, QueryAndUploadTest);
diff --git a/components/autofill/core/browser/autofill_handler.cc b/components/autofill/core/browser/autofill_handler.cc
--- a/components/autofill/core/browser/autofill_handler.cc
+++ b/components/autofill/core/browser/autofill_handler.cc
@@ -57,19 +57,6 @@ bool CachedFormNeedsUpdate(const FormData& live_form,
return false;
}
-std::string GetAPIKeyForUrl(version_info::Channel channel) {
@ -126,21 +70,20 @@ diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/a
- return google_apis::GetNonStableAPIKey();
-}
-
ValuePatternsMetric GetValuePattern(const base::string16& value) {
if (IsUPIVirtualPaymentAddress(value))
return ValuePatternsMetric::kUpiVpa;
@@ -1653,11 +1640,6 @@ AutofillManager::AutofillManager(
: std::make_unique<CreditCardAccessManager>(
driver, client_, personal_data_,
credit_card_form_event_logger_.get());
} // namespace
using base::TimeTicks;
@@ -110,10 +97,6 @@ AutofillHandler::AutofillHandler(
: driver_(driver),
log_manager_(log_manager),
is_rich_query_enabled_(IsRichQueryEnabled(channel)) {
- if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
- version_info::Channel channel = client_->GetChannel();
- download_manager_.reset(new AutofillDownloadManager(
- driver, this, GetAPIKeyForUrl(channel), client_->GetLogManager()));
- download_manager_ = std::make_unique<AutofillDownloadManager>(
- driver, this, GetAPIKeyForUrl(channel), log_manager);
- }
CountryNames::SetLocaleString(app_locale_);
offer_manager_ = client_->GetAutofillOfferManager();
}
AutofillHandler::~AutofillHandler() = default;
--
2.17.1