| 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 "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 10 #include "chrome/browser/password_manager/password_store_factory.h" | 10 #include "chrome/browser/password_manager/password_store_factory.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 origin_ = PendingPassword().origin; | 112 origin_ = PendingPassword().origin; |
| 113 SetState(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); | 113 SetState(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); |
| 114 timer_.reset(new base::ElapsedTimer()); | 114 timer_.reset(new base::ElapsedTimer()); |
| 115 UpdateBubbleAndIconVisibility(); | 115 UpdateBubbleAndIconVisibility(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool ManagePasswordsUIController::OnChooseCredentials( | 118 bool ManagePasswordsUIController::OnChooseCredentials( |
| 119 ScopedVector<autofill::PasswordForm> local_credentials, | 119 ScopedVector<autofill::PasswordForm> local_credentials, |
| 120 ScopedVector<autofill::PasswordForm> federated_credentials, | 120 ScopedVector<autofill::PasswordForm> federated_credentials, |
| 121 base::Callback<void(const password_manager::CredentialInfo&)> callback){ | 121 base::Callback<void(const password_manager::CredentialInfo&)> callback){ |
| 122 // TODO(vasilii): Do something clever with |federated_credentials|. | |
| 123 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 122 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
| 124 form_manager_.reset(); | 123 form_manager_.reset(); |
| 124 // TODO(melandory): fix the crash when |local_credentials| is empty. |
| 125 // By providing origin explicitly. |
| 125 origin_ = local_credentials[0]->origin; | 126 origin_ = local_credentials[0]->origin; |
| 126 new_password_forms_.swap(local_credentials); | 127 local_credentials_forms_.swap(local_credentials); |
| 128 federated_credentials_forms_.swap(federated_credentials); |
| 127 // The map is useless because usernames may overlap. | 129 // The map is useless because usernames may overlap. |
| 128 password_form_map_.clear(); | 130 password_form_map_.clear(); |
| 129 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); | 131 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); |
| 130 UpdateBubbleAndIconVisibility(); | 132 UpdateBubbleAndIconVisibility(); |
| 131 if (bubble_shown_) | 133 if (bubble_shown_) |
| 132 credentials_callback_ = callback; | 134 credentials_callback_ = callback; |
| 133 return bubble_shown_; | 135 return bubble_shown_; |
| 134 } | 136 } |
| 135 | 137 |
| 136 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 138 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 206 } |
| 205 | 207 |
| 206 void ManagePasswordsUIController::SavePassword() { | 208 void ManagePasswordsUIController::SavePassword() { |
| 207 DCHECK(PasswordPendingUserDecision()); | 209 DCHECK(PasswordPendingUserDecision()); |
| 208 SavePasswordInternal(); | 210 SavePasswordInternal(); |
| 209 SetState(password_manager::ui::MANAGE_STATE); | 211 SetState(password_manager::ui::MANAGE_STATE); |
| 210 UpdateBubbleAndIconVisibility(); | 212 UpdateBubbleAndIconVisibility(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 void ManagePasswordsUIController::ChooseCredential( | 215 void ManagePasswordsUIController::ChooseCredential( |
| 214 bool was_chosen, | 216 const autofill::PasswordForm& form, |
| 215 const autofill::PasswordForm& form) { | 217 password_manager::CredentialType credential_type) { |
| 216 DCHECK(password_manager::ui::IsCredentialsState(state_)); | 218 DCHECK(password_manager::ui::IsCredentialsState(state_)); |
| 217 DCHECK(!credentials_callback_.is_null()); | 219 DCHECK(!credentials_callback_.is_null()); |
| 218 password_manager::CredentialInfo info = was_chosen ? | 220 password_manager::CredentialInfo info = |
| 219 password_manager::CredentialInfo(form) : | 221 password_manager::CredentialInfo(form, credential_type); |
| 220 password_manager::CredentialInfo(); | |
| 221 credentials_callback_.Run(info); | 222 credentials_callback_.Run(info); |
| 222 SetState(password_manager::ui::INACTIVE_STATE); | 223 SetState(password_manager::ui::INACTIVE_STATE); |
| 223 UpdateBubbleAndIconVisibility(); | 224 UpdateBubbleAndIconVisibility(); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void ManagePasswordsUIController::SavePasswordInternal() { | 227 void ManagePasswordsUIController::SavePasswordInternal() { |
| 227 DCHECK(form_manager_.get()); | 228 DCHECK(form_manager_.get()); |
| 228 form_manager_->Save(); | 229 form_manager_->Save(); |
| 229 } | 230 } |
| 230 | 231 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 353 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
| 353 return password_manager::ui::IsPendingState(state_); | 354 return password_manager::ui::IsPendingState(state_); |
| 354 } | 355 } |
| 355 | 356 |
| 356 void ManagePasswordsUIController::WebContentsDestroyed() { | 357 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 357 password_manager::PasswordStore* password_store = | 358 password_manager::PasswordStore* password_store = |
| 358 GetPasswordStore(web_contents()); | 359 GetPasswordStore(web_contents()); |
| 359 if (password_store) | 360 if (password_store) |
| 360 password_store->RemoveObserver(this); | 361 password_store->RemoveObserver(this); |
| 361 } | 362 } |
| OLD | NEW |