Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2211)

Unified Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 2641653002: Make ObservingAutofillClient a WebContentsUserData (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/password_manager_browsertest.cc
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index 65af571a8bc28fb50c722e22acd8c023ba98651f..6262e0e43ede53bfe66fdf1db8afd3e30d622b5f 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -108,10 +108,10 @@ std::unique_ptr<net::test_server::HttpResponse> HandleTestAuthRequest(
}
}
-class ObservingAutofillClient : public autofill::TestAutofillClient {
+class ObservingAutofillClient
+ : public autofill::TestAutofillClient,
+ public content::WebContentsUserData<ObservingAutofillClient> {
public:
- ObservingAutofillClient()
- : message_loop_runner_(new content::MessageLoopRunner) {}
~ObservingAutofillClient() override {}
void Wait() { message_loop_runner_->Run(); }
@@ -125,6 +125,10 @@ class ObservingAutofillClient : public autofill::TestAutofillClient {
}
private:
+ explicit ObservingAutofillClient(content::WebContents* web_contents)
+ : message_loop_runner_(new content::MessageLoopRunner) {}
+ friend class content::WebContentsUserData<ObservingAutofillClient>;
+
scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient);
@@ -164,6 +168,8 @@ void TestPromptNotShown(const char* failure_message,
} // namespace
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(ObservingAutofillClient);
+
namespace password_manager {
// Actual tests ---------------------------------------------------------------
@@ -1712,12 +1718,14 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
password_manager::ContentPasswordManagerDriverFactory* driver_factory =
password_manager::ContentPasswordManagerDriverFactory::FromWebContents(
WebContents());
- ObservingAutofillClient observing_autofill_client;
+ ObservingAutofillClient::CreateForWebContents(WebContents());
+ ObservingAutofillClient* observing_autofill_client =
+ ObservingAutofillClient::FromWebContents(WebContents());
password_manager::ContentPasswordManagerDriver* driver =
driver_factory->GetDriverForFrame(RenderViewHost()->GetMainFrame());
DCHECK(driver);
driver->GetPasswordAutofillManager()->set_autofill_client(
- &observing_autofill_client);
+ observing_autofill_client);
NavigateToFile("/password/password_form.html");
@@ -1761,7 +1769,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
WebContents(), 0, blink::WebMouseEvent::Button::Left, gfx::Point(left + 1,
top + 1));
// Make sure the popup would be shown.
- observing_autofill_client.Wait();
+ observing_autofill_client->Wait();
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698