Skip to content

Commit

Permalink
Eliminate parameter in ChromePasswordManagerClient constructor.
Browse files Browse the repository at this point in the history
The parameter is no longer used anywhere - this CL therefore performs
no functionality change.

Bug: 1473235
Change-Id: I1fe44c64e997b2c6a0af2a50c2acc7ec6fd2166b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4789247
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1184711}
  • Loading branch information
Jan Keitel authored and Chromium LUCI CQ committed Aug 17, 2023
1 parent 8f85044 commit 75d60aa
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 131 deletions.
4 changes: 1 addition & 3 deletions chrome/browser/android/tab_web_contents_delegate_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ void TabWebContentsDelegateAndroid::PortalWebContentsCreated(
// helpers that are unprepared for portal activation to transition them.
// See https://crbug.com/1042323
autofill::ChromeAutofillClient::CreateForWebContents(portal_contents);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
portal_contents,
autofill::ContentAutofillClient::FromWebContents(portal_contents));
ChromePasswordManagerClient::CreateForWebContents(portal_contents);
HistoryTabHelper::CreateForWebContents(portal_contents);
ChromePasswordReuseDetectionManagerClient::CreateForWebContents(
portal_contents);
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ash/login/ui/simple_web_view_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ void SimpleWebViewDialog::StartLoad(const GURL& url) {
DCHECK(web_contents);

// Create the password manager that is needed for the proxy.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents,
autofill::ContentAutofillClient::FromWebContents(web_contents));
ChromePasswordManagerClient::CreateForWebContents(web_contents);

// Create the password reuse detection manager for simple web view dialog.
ChromePasswordReuseDetectionManagerClient::CreateForWebContents(web_contents);
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ash/login/ui/webui_login_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ void WebUILoginView::InitializeWebView(views::WebView* web_view,
CreateSessionServiceTabHelper(web_contents);

// Create the password manager that is needed for the proxy.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents,
autofill::ContentAutofillClient::FromWebContents(web_contents));
ChromePasswordManagerClient::CreateForWebContents(web_contents);

// Create the password reuse detection manager.
ChromePasswordReuseDetectionManagerClient::CreateForWebContents(web_contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class MockPasswordManagerClient : public ChromePasswordManagerClient {

private:
explicit MockPasswordManagerClient(content::WebContents* web_contents)
: ChromePasswordManagerClient(web_contents, nullptr) {}
: ChromePasswordManagerClient(web_contents) {}

password_manager::MockPasswordFeatureManager mock_password_feature_manager_;
scoped_refptr<device_reauth::MockDeviceAuthenticator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ SaveUpdatePasswordMessageDelegateTest::SaveUpdatePasswordMessageDelegateTest() =

void SaveUpdatePasswordMessageDelegateTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents(), nullptr);
ChromePasswordManagerClient::CreateForWebContents(web_contents());
ukm_source_id_ = ukm::UkmRecorder::GetNewSourceID();
metrics_recorder_ = base::MakeRefCounted<PasswordFormMetricsRecorder>(
true /*is_main_frame_secure*/, ukm_source_id_, nullptr /*pref_service*/);
Expand Down
20 changes: 9 additions & 11 deletions chrome/browser/password_manager/chrome_password_manager_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ const syncer::SyncService* GetSyncServiceForProfile(Profile* profile) {
} // namespace

// static
void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
content::WebContents* contents,
autofill::AutofillClient* autofill_client) {
if (FromWebContents(contents))
void ChromePasswordManagerClient::CreateForWebContents(
content::WebContents* contents) {
if (FromWebContents(contents)) {
return;
}

contents->SetUserData(UserDataKey(),
base::WrapUnique(new ChromePasswordManagerClient(
contents, autofill_client)));
contents->SetUserData(
UserDataKey(),
base::WrapUnique(new ChromePasswordManagerClient(contents)));
}

// static
Expand Down Expand Up @@ -1304,8 +1304,7 @@ ChromePasswordManagerClient::
#endif // BUILDFLAG(IS_ANDROID)

ChromePasswordManagerClient::ChromePasswordManagerClient(
content::WebContents* web_contents,
autofill::AutofillClient* autofill_client)
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
content::WebContentsUserData<ChromePasswordManagerClient>(*web_contents),
profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
Expand Down Expand Up @@ -1340,8 +1339,7 @@ ChromePasswordManagerClient::ChromePasswordManagerClient(
web_contents)),
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
helper_(this) {
ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this,
autofill_client);
ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this);
ContentPasswordManagerDriverFactory* driver_factory = GetDriverFactory();
log_manager_ = autofill::LogManager::Create(
password_manager::PasswordManagerLogRouterFactory::GetForBrowserContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/autofill/content/common/mojom/autofill_driver.mojom-forward.h"
#include "components/autofill/core/common/password_generation_util.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/password_manager/content/browser/content_credential_manager.h"
Expand Down Expand Up @@ -102,9 +101,7 @@ class ChromePasswordManagerClient
public content::WebContentsUserData<ChromePasswordManagerClient>,
public autofill::mojom::PasswordGenerationDriver {
public:
static void CreateForWebContentsWithAutofillClient(
content::WebContents* contents,
autofill::AutofillClient* autofill_client);
static void CreateForWebContents(content::WebContents* contents);
static void BindPasswordGenerationDriver(
mojo::PendingAssociatedReceiver<autofill::mojom::PasswordGenerationDriver>
receiver,
Expand Down Expand Up @@ -335,8 +332,7 @@ class ChromePasswordManagerClient

protected:
// Callable for tests.
ChromePasswordManagerClient(content::WebContents* web_contents,
autofill::AutofillClient* autofill_client);
explicit ChromePasswordManagerClient(content::WebContents* web_contents);

private:
friend class content::WebContentsUserData<ChromePasswordManagerClient>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class MockChromePasswordManagerClient : public ChromePasswordManagerClient {

private:
explicit MockChromePasswordManagerClient(content::WebContents* web_contents)
: ChromePasswordManagerClient(web_contents, nullptr) {
: ChromePasswordManagerClient(web_contents) {
#if BUILDFLAG(FULL_SAFE_BROWSING)
password_protection_service_ =
std::make_unique<safe_browsing::MockPasswordProtectionService>();
Expand Down Expand Up @@ -361,8 +361,7 @@ void ChromePasswordManagerClientTest::SetUp() {
// In order for the |PasswordFeatureManager| to be initialized correctly
// the testing sync service must be set up before the client.
SetupBasicTestSync();
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents(), nullptr);
ChromePasswordManagerClient::CreateForWebContents(web_contents());

SetupSettingsServiceFactory();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3975,8 +3975,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
ASSERT_FALSE(chrome::FindBrowserWithWebContents(new_web_contents.get()));

// Create ChromePasswordManagerClient for newly created web_contents.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
new_web_contents.get(), /*autofill_client=*/nullptr);
ChromePasswordManagerClient::CreateForWebContents(new_web_contents.get());

ChromePasswordManagerClient* client =
ChromePasswordManagerClient::FromWebContents(new_web_contents.get());
Expand Down Expand Up @@ -4460,10 +4459,7 @@ class PasswordManagerPrerenderBrowserTest : public PasswordManagerBrowserTest {
// logging.
autofill::ChromeAutofillClient::CreateForWebContents(
owned_web_contents.get());
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
owned_web_contents.get(),
autofill::ContentAutofillClient::FromWebContents(
owned_web_contents.get()));
ChromePasswordManagerClient::CreateForWebContents(owned_web_contents.get());
ASSERT_TRUE(
ChromePasswordManagerClient::FromWebContents(owned_web_contents.get()));
ManagePasswordsUIController::CreateForWebContents(owned_web_contents.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,7 @@ void PasswordManagerBrowserTestBase::GetNewTab(

// ManagePasswordsUIController needs ChromePasswordManagerClient for logging.
autofill::ChromeAutofillClient::CreateForWebContents(*web_contents);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
*web_contents,
autofill::ContentAutofillClient::FromWebContents(*web_contents));
ChromePasswordManagerClient::CreateForWebContents(*web_contents);
ASSERT_TRUE(ChromePasswordManagerClient::FromWebContents(*web_contents));
CustomManagePasswordsUIController* controller =
new CustomManagePasswordsUIController(*web_contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,7 @@ TEST_F(RenderViewContextMenuPrefsTest, OpenLinkNavigationInitiatorSet) {
// Verify that "Show all passwords" is displayed on a password field.
TEST_F(RenderViewContextMenuPrefsTest, ShowAllPasswords) {
// Set up password manager stuff.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents(), nullptr);
ChromePasswordManagerClient::CreateForWebContents(web_contents());

NavigateAndCommit(GURL("http://www.foo.com/"));
content::ContextMenuParams params = CreateParams(MenuItem::EDITABLE);
Expand All @@ -1022,8 +1021,8 @@ TEST_F(RenderViewContextMenuPrefsTest, ShowAllPasswordsIncognito) {
profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true), nullptr));

// Set up password manager stuff.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
incognito_web_contents.get(), nullptr);
ChromePasswordManagerClient::CreateForWebContents(
incognito_web_contents.get());

content::WebContentsTester::For(incognito_web_contents.get())
->NavigateAndCommit(GURL("http://www.foo.com/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/guest_view/browser/guest_view_base.h"
#include "components/guest_view/browser/guest_view_manager_delegate.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
Expand Down Expand Up @@ -1629,44 +1627,7 @@ class SitePerProcessAutofillTest : public SitePerProcessInteractiveBrowserTest {
SitePerProcessAutofillTest& operator=(const SitePerProcessAutofillTest&) =
delete;

~SitePerProcessAutofillTest() override {}

protected:
class TestAutofillClient : public autofill::TestAutofillClient {
public:
TestAutofillClient() : popup_shown_(false) {}

TestAutofillClient(const TestAutofillClient&) = delete;
TestAutofillClient& operator=(const TestAutofillClient&) = delete;

~TestAutofillClient() override {}

void WaitForNextPopup() {
if (popup_shown_)
return;
loop_runner_ = new content::MessageLoopRunner();
loop_runner_->Run();
}

void ShowAutofillPopup(
const autofill::AutofillClient::PopupOpenArgs& open_args,
base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override {
element_bounds_ = open_args.element_bounds;
popup_shown_ = true;
if (loop_runner_)
loop_runner_->Quit();
}

const gfx::RectF& last_element_bounds() const { return element_bounds_; }

private:
gfx::RectF element_bounds_;
bool popup_shown_;
scoped_refptr<content::MessageLoopRunner> loop_runner_;
};

const int kIframeTopDisplacement = 150;
const int kIframeLeftDisplacement = 200;
~SitePerProcessAutofillTest() override = default;

void SetupMainTab() {
// Add a fresh new WebContents for which we add our own version of the
Expand All @@ -1683,20 +1644,16 @@ class SitePerProcessAutofillTest : public SitePerProcessInteractiveBrowserTest {

// Create ChromePasswordManagerClient and verify it exists for the new
// WebContents.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
new_contents.get(), &test_autofill_client_);
ChromePasswordManagerClient::CreateForWebContents(new_contents.get());
ASSERT_TRUE(
ChromePasswordManagerClient::FromWebContents(new_contents.get()));

browser()->tab_strip_model()->AppendWebContents(std::move(new_contents),
true);
}

TestAutofillClient& autofill_client() { return test_autofill_client_; }

private:
base::test::ScopedFeatureList scoped_feature_list_;
TestAutofillClient test_autofill_client_;
};

// Waits until transforming |sample_point| from |render_frame_host| coordinates
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ui/tab_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
BreadcrumbManagerTabHelper::CreateForWebContents(web_contents);
chrome::ChainedBackNavigationTracker::CreateForWebContents(web_contents);
chrome_browser_net::NetErrorTabHelper::CreateForWebContents(web_contents);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents,
autofill::ContentAutofillClient::FromWebContents(web_contents));
ChromePasswordManagerClient::CreateForWebContents(web_contents);
ChromePasswordReuseDetectionManagerClient::CreateForWebContents(web_contents);
CreateSubresourceFilterWebContentsHelper(web_contents);
ChromeTranslateClient::CreateForWebContents(web_contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ void PresentationReceiverWindowView::Init() {
SecurityStateTabHelper::CreateForWebContents(web_contents);
ChromeTranslateClient::CreateForWebContents(web_contents);
autofill::ChromeAutofillClient::CreateForWebContents(web_contents);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_contents,
autofill::ContentAutofillClient::FromWebContents(web_contents));
ChromePasswordManagerClient::CreateForWebContents(web_contents);
ChromePasswordReuseDetectionManagerClient::CreateForWebContents(web_contents);
ManagePasswordsUIController::CreateForWebContents(web_contents);
SearchTabHelper::CreateForWebContents(web_contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ content::WebContents* PasswordDialogViewTest::SetupTabWithTestController(
EXPECT_TRUE(raw_new_tab);

// ManagePasswordsUIController needs ChromePasswordManagerClient for logging.
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
raw_new_tab, nullptr);
ChromePasswordManagerClient::CreateForWebContents(raw_new_tab);
EXPECT_TRUE(ChromePasswordManagerClient::FromWebContents(raw_new_tab));
controller_ = new TestManagePasswordsUIController(raw_new_tab);
browser->tab_strip_model()->AppendWebContents(std::move(new_tab), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ ProfilePickerForceSigninDialogDelegate::ProfilePickerForceSigninDialogDelegate(

web_view_->GetWebContents()->SetDelegate(this);

ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
web_view_->GetWebContents(),
autofill::ContentAutofillClient::FromWebContents(
web_view_->GetWebContents()));
ChromePasswordManagerClient::CreateForWebContents(
web_view_->GetWebContents());

ChromePasswordReuseDetectionManagerClient::CreateForWebContents(
web_view_->GetWebContents());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace password_manager {

ContentPasswordManagerDriverFactory::ContentPasswordManagerDriverFactory(
content::WebContents* web_contents,
PasswordManagerClient* password_client,
autofill::AutofillClient* autofill_client)
PasswordManagerClient* password_client)
: content::WebContentsObserver(web_contents),
content::WebContentsUserData<ContentPasswordManagerDriverFactory>(
*web_contents),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#include "content/public/browser/web_contents_user_data.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"

namespace autofill {
class AutofillClient;
}
namespace content {
class WebContents;
}
Expand Down Expand Up @@ -58,10 +55,8 @@ class ContentPasswordManagerDriverFactory
ContentPasswordManagerDriverFactory>;
friend class ContentPasswordManagerDriverFactoryTestApi;

ContentPasswordManagerDriverFactory(
content::WebContents* web_contents,
PasswordManagerClient* client,
autofill::AutofillClient* autofill_client);
ContentPasswordManagerDriverFactory(content::WebContents* web_contents,
PasswordManagerClient* client);

// content::WebContentsObserver:
void DidFinishNavigation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@

#include "components/password_manager/content/browser/content_password_manager_driver_factory_test_api.h"

#include "components/password_manager/content/browser/content_password_manager_driver.h"

namespace password_manager {

// static
std::unique_ptr<ContentPasswordManagerDriverFactory>
ContentPasswordManagerDriverFactoryTestApi::Create(
content::WebContents* web_contents,
PasswordManagerClient* password_manager_client,
autofill::AutofillClient* autofill_client) {
PasswordManagerClient* password_manager_client) {
return base::WrapUnique(new ContentPasswordManagerDriverFactory(
web_contents, password_manager_client, autofill_client));
web_contents, password_manager_client));
}

ContentPasswordManagerDriverFactoryTestApi::
ContentPasswordManagerDriverFactoryTestApi(
ContentPasswordManagerDriverFactory* factory)
: factory_(factory) {}

} // namespace password_manager
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ class ContentPasswordManagerDriverFactoryTestApi {
public:
static std::unique_ptr<ContentPasswordManagerDriverFactory> Create(
content::WebContents* web_contents,
PasswordManagerClient* password_manager_client,
autofill::AutofillClient* autofill_client);

explicit ContentPasswordManagerDriverFactoryTestApi(
ContentPasswordManagerDriverFactory* factory);

private:
raw_ptr<ContentPasswordManagerDriverFactory> factory_;
PasswordManagerClient* password_manager_client);
};

} // namespace password_manager
Expand Down

0 comments on commit 75d60aa

Please sign in to comment.