Commit 2d6c15d8 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Delete "local-heuristics-only-for-password-generation" flag.

The flag was used only in the tests and had a dedicated production code.

Bug: 845458
Change-Id: I27265ad5a69eecb31663b5fb1526c696f1b35d3d
Reviewed-on: https://chromium-review.googlesource.com/c/1322831Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606027}
parent 76e240cc
......@@ -2076,7 +2076,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
static const char* const kSwitchNames[] = {
autofill::switches::kEnableSuggestionsWithSubstringMatch,
autofill::switches::kIgnoreAutocompleteOffForAutofill,
autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration,
autofill::switches::kShowAutofillSignatures,
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::switches::kAllowHTTPBackgroundPage,
......
......@@ -19,7 +19,6 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/password_manager/core/browser/password_generation_manager.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/test_password_store.h"
......@@ -97,10 +96,6 @@ class PasswordGenerationInteractiveTest
// Make sure the feature is enabled.
scoped_feature_list_.InitAndEnableFeature(
autofill::features::kAutomaticPasswordGeneration);
// Don't require ping from autofill or blacklist checking.
command_line->AppendSwitch(
autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration);
}
void SetUpOnMainThread() override {
......@@ -113,8 +108,10 @@ class PasswordGenerationInteractiveTest
ChromePasswordManagerClient* client =
ChromePasswordManagerClient::FromWebContents(WebContents());
client->SetTestObserver(&observer_);
// The base class should enable password generation.
ASSERT_NE(password_manager::NOT_SYNCING, client->GetPasswordSyncState());
NavigateToFile("/password/signup_form.html");
NavigateToFile("/password/signup_form_new_password.html");
}
void TearDownOnMainThread() override {
......@@ -253,11 +250,8 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
PopupShownManuallyAndPasswordErased) {
NavigateToFile("/password/password_form.html");
// Focus the field that is not the first password field. The first one is
// considered "automatic" generation field.
ASSERT_TRUE(content::ExecuteScript(
WebContents(), "document.getElementById('password_redirect').focus()"));
FocusPasswordField();
EXPECT_FALSE(GenerationPopupShowing());
// The same flow happens when user generates a password from the context menu.
password_manager_util::UserTriggeredManualGenerationFromContextMenu(
ChromePasswordManagerClient::FromWebContents(WebContents()));
......@@ -267,15 +261,14 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
SendKeyToPopup(ui::VKEY_RETURN);
// Wait until the password is filled.
WaitForNonEmptyFieldValue("password_redirect");
WaitForNonEmptyFieldValue("password_field");
// Re-focusing the password field should show the editing popup.
ASSERT_TRUE(content::ExecuteScript(
WebContents(), "document.getElementById('password_redirect').focus()"));
FocusPasswordField();
EXPECT_TRUE(EditingPopupShowing());
// Delete the password. The generation prompt should not be visible.
SimulateUserDeletingFieldContent("password_redirect");
SimulateUserDeletingFieldContent("password_field");
WaitForPopupStatusChange();
EXPECT_FALSE(EditingPopupShowing());
EXPECT_FALSE(GenerationPopupShowing());
......
......@@ -63,6 +63,26 @@ class PasswordStoreResultsObserver
DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver);
};
// Custom class is required to enable password generation.
class CustomPasswordManagerClient : public ChromePasswordManagerClient {
public:
using ChromePasswordManagerClient::ChromePasswordManagerClient;
static void CreateForWebContentsWithAutofillClient(
content::WebContents* contents,
autofill::AutofillClient* autofill_client) {
ASSERT_FALSE(FromWebContents(contents));
contents->SetUserData(UserDataKey(),
base::WrapUnique(new CustomPasswordManagerClient(
contents, autofill_client)));
}
// PasswordManagerClient:
password_manager::SyncState GetPasswordSyncState() const override {
return password_manager::SYNCING_NORMAL_ENCRYPTION;
}
};
// ManagePasswordsUIController subclass to capture the UI events.
class CustomManagePasswordsUIController : public ManagePasswordsUIController {
public:
......@@ -439,7 +459,7 @@ void PasswordManagerBrowserTestBase::SetUpOnMainThreadAndGetNewTab(
// ManagePasswordsUIController needs ChromePasswordManagerClient for logging.
autofill::ChromeAutofillClient::CreateForWebContents(*web_contents);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
CustomPasswordManagerClient::CreateForWebContentsWithAutofillClient(
*web_contents,
autofill::ChromeAutofillClient::FromWebContents(*web_contents));
ASSERT_TRUE(ChromePasswordManagerClient::FromWebContents(*web_contents));
......
<html>
<body>
<iframe src="signup_form.html" id="signup_iframe" name="signup_iframe">
<iframe src="signup_form_new_password.html" id="signup_iframe" name="signup_iframe">
</iframe>
</body>
......
<!--
A mock signup form that uses autocomplete attributes.
-->
<html>
<body>
<form method="POST" action="done.html" onsubmit="return true;" id="testform">
<input type="text" id="other_info" name="other_info">
<input type="text" id="username_field" name="username_field"i autocomplete="username">
<input type="password" id="password_field" name="password_field" autocomplete="new-password">
<input type="submit" id="input_submit_button" name="input_submit_button">
</form>
<!--
Extremly wide <div> to allow scrolling to be tested.
-->
<div style="border:1px solid black;background-color:lightblue;height:75px;width:5000px;">
</div>
</body>
</html>
......@@ -511,20 +511,15 @@ void PasswordGenerationAgent::DetermineGenerationElement() {
// (e.g. password saving is disabled).
for (auto& possible_form_data : possible_account_creation_forms_) {
PasswordForm* possible_password_form = &possible_form_data.form;
const PasswordFormGenerationData* generation_data = nullptr;
std::vector<WebInputElement> password_elements;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kLocalHeuristicsOnlyForPasswordGeneration)) {
password_elements = possible_form_data.password_elements;
VLOG(2) << "Bypassing additional checks.";
} else if (!ContainsURL(not_blacklisted_password_form_origins_,
possible_password_form->origin)) {
if (!ContainsURL(not_blacklisted_password_form_origins_,
possible_password_form->origin)) {
LogMessage(Logger::STRING_GENERATION_RENDERER_NOT_BLACKLISTED);
continue;
} else {
generation_data = FindFormGenerationData(generation_enabled_forms_,
*possible_password_form);
const PasswordFormGenerationData* generation_data =
FindFormGenerationData(generation_enabled_forms_,
*possible_password_form);
if (generation_data) {
password_elements = FindPasswordElementsForGeneration(
possible_form_data.password_elements, *generation_data);
......
......@@ -30,11 +30,6 @@ const char kEnableSuggestionsWithSubstringMatch[] =
const char kIgnoreAutocompleteOffForAutofill[] =
"ignore-autocomplete-off-autofill";
// Removes the requirement that we recieved a ping from the autofill servers
// and that the user doesn't have the given form blacklisted. Used in testing.
const char kLocalHeuristicsOnlyForPasswordGeneration[] =
"local-heuristics-only-for-password-generation";
// Annotates forms with Autofill field type predictions.
const char kShowAutofillTypePredictions[] = "show-autofill-type-predictions";
......
......@@ -17,7 +17,6 @@ extern const char kDisableOfferStoreUnmaskedWalletCards[];
extern const char kEnableOfferStoreUnmaskedWalletCards[];
extern const char kEnableSuggestionsWithSubstringMatch[];
extern const char kIgnoreAutocompleteOffForAutofill[];
extern const char kLocalHeuristicsOnlyForPasswordGeneration[];
extern const char kShowAutofillTypePredictions[];
extern const char kShowAutofillSignatures[];
extern const char kWalletServiceUseSandbox[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment