| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/passwords/manage_passwords_ui_controller.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 passwords_data_.OnUpdatePassword(std::move(form_manager)); | 92 passwords_data_.OnUpdatePassword(std::move(form_manager)); |
| 93 bubble_status_ = SHOULD_POP_UP; | 93 bubble_status_ = SHOULD_POP_UP; |
| 94 UpdateBubbleAndIconVisibility(); | 94 UpdateBubbleAndIconVisibility(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool ManagePasswordsUIController::OnChooseCredentials( | 97 bool ManagePasswordsUIController::OnChooseCredentials( |
| 98 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 98 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 99 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, | 99 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, |
| 100 const GURL& origin, | 100 const GURL& origin, |
| 101 const ManagePasswordsState::CredentialsCallback& callback) { | 101 const ManagePasswordsState::CredentialsCallback& callback) { |
| 102 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 102 DCHECK(!local_credentials.empty()); |
| 103 if (!HasBrowserWindow()) | 103 if (!HasBrowserWindow()) |
| 104 return false; | 104 return false; |
| 105 PasswordDialogController::FormsVector locals = | 105 // If |local_credentials| contains PSL matches they shouldn't be propagated to |
| 106 CopyFormVector(local_credentials); | 106 // the state because PSL matches aren't saved for current page. This logic is |
| 107 // implemented here because Android uses ManagePasswordsState as a data source |
| 108 // for account chooser. |
| 109 PasswordDialogController::FormsVector locals; |
| 110 if (!local_credentials[0]->is_public_suffix_match) |
| 111 locals = CopyFormVector(local_credentials); |
| 107 PasswordDialogController::FormsVector federations = | 112 PasswordDialogController::FormsVector federations = |
| 108 CopyFormVector(federated_credentials); | 113 CopyFormVector(federated_credentials); |
| 109 passwords_data_.OnRequestCredentials( | 114 passwords_data_.OnRequestCredentials( |
| 110 std::move(local_credentials), std::move(federated_credentials), origin); | 115 std::move(locals), std::move(federations), origin); |
| 111 passwords_data_.set_credentials_callback(callback); | 116 passwords_data_.set_credentials_callback(callback); |
| 112 dialog_controller_.reset(new PasswordDialogControllerImpl( | 117 dialog_controller_.reset(new PasswordDialogControllerImpl( |
| 113 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), | 118 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
| 114 this)); | 119 this)); |
| 115 dialog_controller_->ShowAccountChooser( | 120 dialog_controller_->ShowAccountChooser( |
| 116 CreateAccountChooser(dialog_controller_.get()), | 121 CreateAccountChooser(dialog_controller_.get()), |
| 117 std::move(locals), std::move(federations)); | 122 std::move(local_credentials), std::move(federated_credentials)); |
| 118 UpdateBubbleAndIconVisibility(); | 123 UpdateBubbleAndIconVisibility(); |
| 119 return true; | 124 return true; |
| 120 } | 125 } |
| 121 | 126 |
| 122 void ManagePasswordsUIController::OnAutoSignin( | 127 void ManagePasswordsUIController::OnAutoSignin( |
| 123 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, | 128 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, |
| 124 const GURL& origin) { | 129 const GURL& origin) { |
| 125 DCHECK(!local_forms.empty()); | 130 DCHECK(!local_forms.empty()); |
| 126 DestroyAccountChooser(); | 131 DestroyAccountChooser(); |
| 127 passwords_data_.OnAutoSignin(std::move(local_forms), origin); | 132 passwords_data_.OnAutoSignin(std::move(local_forms), origin); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 462 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 458 } | 463 } |
| 459 } | 464 } |
| 460 | 465 |
| 461 void ManagePasswordsUIController::WebContentsDestroyed() { | 466 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 462 password_manager::PasswordStore* password_store = | 467 password_manager::PasswordStore* password_store = |
| 463 GetPasswordStore(web_contents()); | 468 GetPasswordStore(web_contents()); |
| 464 if (password_store) | 469 if (password_store) |
| 465 password_store->RemoveObserver(this); | 470 password_store->RemoveObserver(this); |
| 466 } | 471 } |
| OLD | NEW |