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

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

Issue 2900983002: Ignore form action URL when determine if a credential should be autofilled. (Closed)
Patch Set: Created 3 years, 7 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 #include "chrome/browser/password_manager/password_manager_test_base.h" 5 #include "chrome/browser/password_manager/password_manager_test_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // ManagePasswordsUIController subclass to capture the UI events. 58 // ManagePasswordsUIController subclass to capture the UI events.
59 class CustomManagePasswordsUIController : public ManagePasswordsUIController { 59 class CustomManagePasswordsUIController : public ManagePasswordsUIController {
60 public: 60 public:
61 explicit CustomManagePasswordsUIController( 61 explicit CustomManagePasswordsUIController(
62 content::WebContents* web_contents); 62 content::WebContents* web_contents);
63 63
64 void WaitForState(password_manager::ui::State target_state); 64 void WaitForState(password_manager::ui::State target_state);
65 65
66 private: 66 private:
67 // PasswordsClientUIDelegate: 67 // PasswordsClientUIDelegate:
68 void OnPasswordSubmitted(
dvadym 2017/05/23 14:59:52 Why do we need this, it looks that this method is
vasilii 2017/05/24 12:48:36 It's how WaitForSavePrompt() is implemented. This
69 std::unique_ptr<password_manager::PasswordFormManager> form_manager)
70 override;
68 bool OnChooseCredentials( 71 bool OnChooseCredentials(
69 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, 72 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
70 const GURL& origin, 73 const GURL& origin,
71 const ManagePasswordsState::CredentialsCallback& callback) override; 74 const ManagePasswordsState::CredentialsCallback& callback) override;
72 void OnPasswordAutofilled( 75 void OnPasswordAutofilled(
73 const std::map<base::string16, const autofill::PasswordForm*>& 76 const std::map<base::string16, const autofill::PasswordForm*>&
74 password_form_map, 77 password_form_map,
75 const GURL& origin, 78 const GURL& origin,
76 const std::vector<const autofill::PasswordForm*>* federated_matches) 79 const std::vector<const autofill::PasswordForm*>* federated_matches)
77 override; 80 override;
(...skipping 21 matching lines...) Expand all
99 } 102 }
100 103
101 void CustomManagePasswordsUIController::WaitForState( 104 void CustomManagePasswordsUIController::WaitForState(
102 password_manager::ui::State target_state) { 105 password_manager::ui::State target_state) {
103 base::RunLoop run_loop; 106 base::RunLoop run_loop;
104 target_state_ = target_state; 107 target_state_ = target_state;
105 run_loop_ = &run_loop; 108 run_loop_ = &run_loop;
106 run_loop_->Run(); 109 run_loop_->Run();
107 } 110 }
108 111
112 void CustomManagePasswordsUIController::OnPasswordSubmitted(
113 std::unique_ptr<password_manager::PasswordFormManager> form_manager) {
114 if (target_state_ == password_manager::ui::PENDING_PASSWORD_STATE) {
115 run_loop_->Quit();
116 run_loop_ = nullptr;
117 target_state_ = password_manager::ui::INACTIVE_STATE;
118 }
119 return ManagePasswordsUIController::OnPasswordSubmitted(
120 std::move(form_manager));
121 }
122
109 bool CustomManagePasswordsUIController::OnChooseCredentials( 123 bool CustomManagePasswordsUIController::OnChooseCredentials(
110 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, 124 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
111 const GURL& origin, 125 const GURL& origin,
112 const ManagePasswordsState::CredentialsCallback& callback) { 126 const ManagePasswordsState::CredentialsCallback& callback) {
113 if (target_state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { 127 if (target_state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) {
114 run_loop_->Quit(); 128 run_loop_->Quit();
115 run_loop_ = nullptr; 129 run_loop_ = nullptr;
116 target_state_ = password_manager::ui::INACTIVE_STATE; 130 target_state_ = password_manager::ui::INACTIVE_STATE;
117 } 131 }
118 return ManagePasswordsUIController::OnChooseCredentials( 132 return ManagePasswordsUIController::OnChooseCredentials(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 241
228 void BubbleObserver::WaitForManagementState() const { 242 void BubbleObserver::WaitForManagementState() const {
229 if (passwords_ui_controller_->GetState() == 243 if (passwords_ui_controller_->GetState() ==
230 password_manager::ui::MANAGE_STATE) 244 password_manager::ui::MANAGE_STATE)
231 return; 245 return;
232 CustomManagePasswordsUIController* controller = 246 CustomManagePasswordsUIController* controller =
233 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); 247 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_);
234 controller->WaitForState(password_manager::ui::MANAGE_STATE); 248 controller->WaitForState(password_manager::ui::MANAGE_STATE);
235 } 249 }
236 250
251 void BubbleObserver::WaitForSavePrompt() const {
252 if (passwords_ui_controller_->GetState() ==
253 password_manager::ui::PENDING_PASSWORD_STATE)
254 return;
255 CustomManagePasswordsUIController* controller =
256 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_);
257 controller->WaitForState(password_manager::ui::PENDING_PASSWORD_STATE);
258 }
259
237 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() 260 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase()
238 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS), 261 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS),
239 web_contents_(nullptr) {} 262 web_contents_(nullptr) {}
240 263
241 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default; 264 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default;
242 265
243 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { 266 void PasswordManagerBrowserTestBase::SetUpOnMainThread() {
244 // Use TestPasswordStore to remove a possible race. Normally the 267 // Use TestPasswordStore to remove a possible race. Normally the
245 // PasswordStore does its database manipulation on the DB thread, which 268 // PasswordStore does its database manipulation on the DB thread, which
246 // creates a possible race during navigation. Specifically the 269 // creates a possible race during navigation. Specifically the
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 488
466 content::BrowserThread::PostTaskAndReply( 489 content::BrowserThread::PostTaskAndReply(
467 content::BrowserThread::IO, FROM_HERE, 490 content::BrowserThread::IO, FROM_HERE,
468 base::BindOnce( 491 base::BindOnce(
469 &AddHSTSHostImpl, 492 &AddHSTSHostImpl,
470 make_scoped_refptr(browser()->profile()->GetRequestContext()), host), 493 make_scoped_refptr(browser()->profile()->GetRequestContext()), host),
471 run_loop.QuitClosure()); 494 run_loop.QuitClosure());
472 495
473 run_loop.Run(); 496 run_loop.Run();
474 } 497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698