| 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 27 matching lines...) Expand all Loading... |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 password_manager::PasswordStore* GetPasswordStore( | 40 password_manager::PasswordStore* GetPasswordStore( |
| 41 content::WebContents* web_contents) { | 41 content::WebContents* web_contents) { |
| 42 return PasswordStoreFactory::GetForProfile( | 42 return PasswordStoreFactory::GetForProfile( |
| 43 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 43 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| 44 ServiceAccessType::EXPLICIT_ACCESS).get(); | 44 ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 std::vector<std::unique_ptr<autofill::PasswordForm>> CopyFormVector( | 47 std::vector<std::unique_ptr<autofill::PasswordForm>> CopyFormVector( |
| 48 const ScopedVector<autofill::PasswordForm>& forms) { | 48 const std::vector<std::unique_ptr<autofill::PasswordForm>>& forms) { |
| 49 std::vector<std::unique_ptr<autofill::PasswordForm>> result(forms.size()); | 49 std::vector<std::unique_ptr<autofill::PasswordForm>> result(forms.size()); |
| 50 for (size_t i = 0; i < forms.size(); ++i) | 50 for (size_t i = 0; i < forms.size(); ++i) |
| 51 result[i].reset(new autofill::PasswordForm(*forms[i])); | 51 result[i].reset(new autofill::PasswordForm(*forms[i])); |
| 52 return result; | 52 return result; |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsUIController); | 57 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsUIController); |
| 58 | 58 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 void ManagePasswordsUIController::OnUpdatePasswordSubmitted( | 91 void ManagePasswordsUIController::OnUpdatePasswordSubmitted( |
| 92 std::unique_ptr<PasswordFormManager> form_manager) { | 92 std::unique_ptr<PasswordFormManager> form_manager) { |
| 93 DestroyAccountChooser(); | 93 DestroyAccountChooser(); |
| 94 passwords_data_.OnUpdatePassword(std::move(form_manager)); | 94 passwords_data_.OnUpdatePassword(std::move(form_manager)); |
| 95 bubble_status_ = SHOULD_POP_UP; | 95 bubble_status_ = SHOULD_POP_UP; |
| 96 UpdateBubbleAndIconVisibility(); | 96 UpdateBubbleAndIconVisibility(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool ManagePasswordsUIController::OnChooseCredentials( | 99 bool ManagePasswordsUIController::OnChooseCredentials( |
| 100 ScopedVector<autofill::PasswordForm> local_credentials, | 100 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 101 ScopedVector<autofill::PasswordForm> federated_credentials, | 101 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, |
| 102 const GURL& origin, | 102 const GURL& origin, |
| 103 const ManagePasswordsState::CredentialsCallback& callback) { | 103 const ManagePasswordsState::CredentialsCallback& callback) { |
| 104 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 104 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
| 105 PasswordDialogController::FormsVector locals = | 105 PasswordDialogController::FormsVector locals = |
| 106 CopyFormVector(local_credentials); | 106 CopyFormVector(local_credentials); |
| 107 PasswordDialogController::FormsVector federations = | 107 PasswordDialogController::FormsVector federations = |
| 108 CopyFormVector(federated_credentials); | 108 CopyFormVector(federated_credentials); |
| 109 passwords_data_.OnRequestCredentials( | 109 passwords_data_.OnRequestCredentials( |
| 110 std::move(local_credentials), std::move(federated_credentials), origin); | 110 std::move(local_credentials), std::move(federated_credentials), origin); |
| 111 passwords_data_.set_credentials_callback(callback); | 111 passwords_data_.set_credentials_callback(callback); |
| 112 dialog_controller_.reset(new PasswordDialogControllerImpl( | 112 dialog_controller_.reset(new PasswordDialogControllerImpl( |
| 113 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), | 113 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
| 114 this)); | 114 this)); |
| 115 dialog_controller_->ShowAccountChooser( | 115 dialog_controller_->ShowAccountChooser( |
| 116 CreateAccountChooser(dialog_controller_.get()), | 116 CreateAccountChooser(dialog_controller_.get()), |
| 117 std::move(locals), std::move(federations)); | 117 std::move(locals), std::move(federations)); |
| 118 UpdateBubbleAndIconVisibility(); | 118 UpdateBubbleAndIconVisibility(); |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ManagePasswordsUIController::OnAutoSignin( | 122 void ManagePasswordsUIController::OnAutoSignin( |
| 123 ScopedVector<autofill::PasswordForm> local_forms, | 123 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, |
| 124 const GURL& origin) { | 124 const GURL& origin) { |
| 125 DCHECK(!local_forms.empty()); | 125 DCHECK(!local_forms.empty()); |
| 126 DestroyAccountChooser(); | 126 DestroyAccountChooser(); |
| 127 passwords_data_.OnAutoSignin(std::move(local_forms), origin); | 127 passwords_data_.OnAutoSignin(std::move(local_forms), origin); |
| 128 bubble_status_ = SHOULD_POP_UP; | 128 bubble_status_ = SHOULD_POP_UP; |
| 129 UpdateBubbleAndIconVisibility(); | 129 UpdateBubbleAndIconVisibility(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ManagePasswordsUIController::OnPromptEnableAutoSignin() { | 132 void ManagePasswordsUIController::OnPromptEnableAutoSignin() { |
| 133 // Both the account chooser and the previous prompt shouldn't be closed. | 133 // Both the account chooser and the previous prompt shouldn't be closed. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 passwords_data_.form_manager(); | 224 passwords_data_.form_manager(); |
| 225 return form_manager->pending_credentials(); | 225 return form_manager->pending_credentials(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool ManagePasswordsUIController::IsPasswordOverridden() const { | 228 bool ManagePasswordsUIController::IsPasswordOverridden() const { |
| 229 const password_manager::PasswordFormManager* form_manager = | 229 const password_manager::PasswordFormManager* form_manager = |
| 230 passwords_data_.form_manager(); | 230 passwords_data_.form_manager(); |
| 231 return form_manager ? form_manager->password_overridden() : false; | 231 return form_manager ? form_manager->password_overridden() : false; |
| 232 } | 232 } |
| 233 | 233 |
| 234 const std::vector<const autofill::PasswordForm*>& | 234 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
| 235 ManagePasswordsUIController::GetCurrentForms() const { | 235 ManagePasswordsUIController::GetCurrentForms() const { |
| 236 return passwords_data_.GetCurrentForms(); | 236 return passwords_data_.GetCurrentForms(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 const std::vector<const autofill::PasswordForm*>& | 239 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
| 240 ManagePasswordsUIController::GetFederatedForms() const { | 240 ManagePasswordsUIController::GetFederatedForms() const { |
| 241 return passwords_data_.federated_credentials_forms(); | 241 return passwords_data_.federation_providers_forms(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 password_manager::InteractionsStats* | 244 password_manager::InteractionsStats* |
| 245 ManagePasswordsUIController::GetCurrentInteractionStats() const { | 245 ManagePasswordsUIController::GetCurrentInteractionStats() const { |
| 246 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); | 246 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); |
| 247 password_manager::PasswordFormManager* form_manager = | 247 password_manager::PasswordFormManager* form_manager = |
| 248 passwords_data_.form_manager(); | 248 passwords_data_.form_manager(); |
| 249 return password_manager::FindStatsByUsername( | 249 return password_manager::FindStatsByUsername( |
| 250 form_manager->interactions_stats(), | 250 form_manager->interactions_stats(), |
| 251 form_manager->pending_credentials().username_value); | 251 form_manager->pending_credentials().username_value); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 453 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 | 456 |
| 457 void ManagePasswordsUIController::WebContentsDestroyed() { | 457 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 458 password_manager::PasswordStore* password_store = | 458 password_manager::PasswordStore* password_store = |
| 459 GetPasswordStore(web_contents()); | 459 GetPasswordStore(web_contents()); |
| 460 if (password_store) | 460 if (password_store) |
| 461 password_store->RemoveObserver(this); | 461 password_store->RemoveObserver(this); |
| 462 } | 462 } |
| OLD | NEW |