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

Side by Side Diff: chrome/browser/password_manager/password_manager_test_base.h

Issue 2915763003: [Password Manager] Show omnibox icon and anchored prompt once user start typing password (Closed)
Patch Set: '|web_contents|' comment is back Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); 58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
59 }; 59 };
60 60
61 // Observes the save password prompt for a specified WebContents, keeps track of 61 // Observes the save password prompt for a specified WebContents, keeps track of
62 // whether or not it is currently shown, and allows accepting saving passwords 62 // whether or not it is currently shown, and allows accepting saving passwords
63 // through it. 63 // through it.
64 class BubbleObserver { 64 class BubbleObserver {
65 public: 65 public:
66 explicit BubbleObserver(content::WebContents* web_contents); 66 explicit BubbleObserver(content::WebContents* web_contents);
67 67
68 // Checks if the save prompt is being currently shown. 68 // Checks if the save prompt is being currently available due to both manual
69 bool IsShowingSavePrompt() const; 69 // fallback or successful login.
70 bool IsSavePromptAvailable() const;
70 71
71 // Checks if the update prompt is being currently shown. 72 // Checks if the update prompt is being currently available due to both manual
72 bool IsShowingUpdatePrompt() const; 73 // fallback or successful login.
74 bool IsUpdatePromptAvailable() const;
75
76 // Checks if the save prompt was shown automatically.
vasilii 2017/08/09 09:32:15 This can only be called on the custom tab.
kolos1 2017/08/09 09:55:06 Done.
77 bool IsSavePromptShownAutomatically() const;
78
79 // Checks if the update prompt was shown automatically.
80 bool IsUpdatePromptShownAutomatically() const;
73 81
74 // Dismisses the prompt currently open and moves the controller to the 82 // Dismisses the prompt currently open and moves the controller to the
75 // inactive state. 83 // inactive state.
76 void Dismiss() const; 84 void Dismiss() const;
77 85
78 // Expecting that the prompt is shown, saves the password. Checks that the 86 // Expecting that the prompt is available, saves the password. At the end,
79 // prompt is no longer visible afterwards. 87 // checks that the prompt is no longer available afterwards.
80 void AcceptSavePrompt() const; 88 void AcceptSavePrompt() const;
81 89
82 // Expecting that the prompt is shown, update |form| with the password from 90 // Expecting that the prompt is shown, update |form| with the password from
83 // observed form. Checks that the prompt is no longer visible afterwards. 91 // observed form. Checks that the prompt is no longer visible afterwards.
84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; 92 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const;
85 93
86 // Returns once the account chooser pops up or it's already shown. 94 // Returns once the account chooser pops up or it's already shown.
87 // |web_contents| must be the custom one returned by 95 // |web_contents| must be the custom one returned by
88 // PasswordManagerBrowserTestBase. 96 // PasswordManagerBrowserTestBase.
89 void WaitForAccountChooser() const; 97 void WaitForAccountChooser() const;
90 98
91 // Returns once the UI controller is in the management state due to matching 99 // Returns once the UI controller is in the management state due to matching
92 // credentials autofilled. 100 // credentials autofilled.
93 // |web_contents| must be the custom one returned by 101 // |web_contents| must be the custom one returned by
94 // PasswordManagerBrowserTestBase. 102 // PasswordManagerBrowserTestBase.
95 void WaitForManagementState() const; 103 void WaitForManagementState() const;
96 104
97 // Returns once the save prompt pops up or it's already shown. 105 // Returns once the save prompt pops up or it's already shown.
98 // |web_contents| must be the custom one returned by 106 // |web_contents| must be the custom one returned by
99 // PasswordManagerBrowserTestBase. 107 // PasswordManagerBrowserTestBase.
100 void WaitForSavePrompt() const; 108 void WaitForAutomaticSavePrompt() const;
109
110 // Returns once the fallback for saving becomes available.
111 // |web_contents| must be the custom one returned by
112 // PasswordManagerBrowserTestBase.
113 void WaitForFallbackForSaving() const;
101 114
102 private: 115 private:
103 ManagePasswordsUIController* const passwords_ui_controller_; 116 ManagePasswordsUIController* const passwords_ui_controller_;
104 117
105 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); 118 DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
106 }; 119 };
107 120
108 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { 121 class PasswordManagerBrowserTestBase : public InProcessBrowserTest {
109 public: 122 public:
110 PasswordManagerBrowserTestBase(); 123 PasswordManagerBrowserTestBase();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void CheckElementValue(const std::string& element_id, 168 void CheckElementValue(const std::string& element_id,
156 const std::string& expected_value); 169 const std::string& expected_value);
157 // Same as above except the element |element_id| is in iframe |iframe_id| 170 // Same as above except the element |element_id| is in iframe |iframe_id|
158 void CheckElementValue(const std::string& iframe_id, 171 void CheckElementValue(const std::string& iframe_id,
159 const std::string& element_id, 172 const std::string& element_id,
160 const std::string& expected_value); 173 const std::string& expected_value);
161 174
162 // Synchronoulsy adds the given host to the list of valid HSTS hosts. 175 // Synchronoulsy adds the given host to the list of valid HSTS hosts.
163 void AddHSTSHost(const std::string& host); 176 void AddHSTSHost(const std::string& host);
164 177
178 // Checks that |password_store| stores only one credential with |username| and
179 // |password|.
180 void CheckThatCredentialsStored(const base::string16& username,
181 const base::string16& password);
182
165 // Accessors 183 // Accessors
166 // Return the first created tab with a custom ManagePasswordsUIController. 184 // Return the first created tab with a custom ManagePasswordsUIController.
167 content::WebContents* WebContents(); 185 content::WebContents* WebContents();
168 content::RenderViewHost* RenderViewHost(); 186 content::RenderViewHost* RenderViewHost();
169 content::RenderFrameHost* RenderFrameHost(); 187 content::RenderFrameHost* RenderFrameHost();
170 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } 188 net::EmbeddedTestServer& https_test_server() { return https_test_server_; }
171 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } 189 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; }
172 190
173 private: 191 private:
174 net::EmbeddedTestServer https_test_server_; 192 net::EmbeddedTestServer https_test_server_;
175 net::MockCertVerifier mock_cert_verifier_; 193 net::MockCertVerifier mock_cert_verifier_;
176 // A tab with some hooks injected. 194 // A tab with some hooks injected.
177 content::WebContents* web_contents_; 195 content::WebContents* web_contents_;
178 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); 196 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase);
179 }; 197 };
180 198
181 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ 199 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698