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(); |
125 origin_ = local_credentials[0]->origin; | 124 // TODO(melandory): fix the crash when |local_credentials| is empty. |
126 new_password_forms_.swap(local_credentials); | 125 // By providing origin explicitly. |
126 if (!local_credentials.empty()) | |
127 origin_ = local_credentials[0]->origin; | |
128 else | |
129 origin_ = federated_credentials[0]->origin; | |
vasilii
2015/01/23 17:04:37
Well, the origin of a federated login isn't what w
melandory
2015/01/23 18:16:04
Yes, I see now. I'll set empty value for it right
melandory
2015/01/26 08:52:47
https://codereview.chromium.org/877613004
| |
130 local_credentials_forms_.swap(local_credentials); | |
131 federated_credentials_forms_.swap(federated_credentials); | |
127 // The map is useless because usernames may overlap. | 132 // The map is useless because usernames may overlap. |
128 password_form_map_.clear(); | 133 password_form_map_.clear(); |
129 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); | 134 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); |
130 UpdateBubbleAndIconVisibility(); | 135 UpdateBubbleAndIconVisibility(); |
131 if (bubble_shown_) | 136 if (bubble_shown_) |
132 credentials_callback_ = callback; | 137 credentials_callback_ = callback; |
133 return bubble_shown_; | 138 return bubble_shown_; |
134 } | 139 } |
135 | 140 |
136 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 141 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 } | 209 } |
205 | 210 |
206 void ManagePasswordsUIController::SavePassword() { | 211 void ManagePasswordsUIController::SavePassword() { |
207 DCHECK(PasswordPendingUserDecision()); | 212 DCHECK(PasswordPendingUserDecision()); |
208 SavePasswordInternal(); | 213 SavePasswordInternal(); |
209 SetState(password_manager::ui::MANAGE_STATE); | 214 SetState(password_manager::ui::MANAGE_STATE); |
210 UpdateBubbleAndIconVisibility(); | 215 UpdateBubbleAndIconVisibility(); |
211 } | 216 } |
212 | 217 |
213 void ManagePasswordsUIController::ChooseCredential( | 218 void ManagePasswordsUIController::ChooseCredential( |
214 bool was_chosen, | 219 const autofill::PasswordForm& form, |
215 const autofill::PasswordForm& form) { | 220 password_manager::CredentialType credential_type) { |
216 DCHECK(password_manager::ui::IsCredentialsState(state_)); | 221 DCHECK(password_manager::ui::IsCredentialsState(state_)); |
217 DCHECK(!credentials_callback_.is_null()); | 222 DCHECK(!credentials_callback_.is_null()); |
218 password_manager::CredentialInfo info = was_chosen ? | 223 password_manager::CredentialInfo info = |
219 password_manager::CredentialInfo(form) : | 224 password_manager::CredentialInfo(form, credential_type); |
220 password_manager::CredentialInfo(); | |
221 credentials_callback_.Run(info); | 225 credentials_callback_.Run(info); |
222 SetState(password_manager::ui::INACTIVE_STATE); | 226 SetState(password_manager::ui::INACTIVE_STATE); |
223 UpdateBubbleAndIconVisibility(); | 227 UpdateBubbleAndIconVisibility(); |
224 } | 228 } |
225 | 229 |
226 void ManagePasswordsUIController::SavePasswordInternal() { | 230 void ManagePasswordsUIController::SavePasswordInternal() { |
227 DCHECK(form_manager_.get()); | 231 DCHECK(form_manager_.get()); |
228 form_manager_->Save(); | 232 form_manager_->Save(); |
229 } | 233 } |
230 | 234 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 356 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
353 return password_manager::ui::IsPendingState(state_); | 357 return password_manager::ui::IsPendingState(state_); |
354 } | 358 } |
355 | 359 |
356 void ManagePasswordsUIController::WebContentsDestroyed() { | 360 void ManagePasswordsUIController::WebContentsDestroyed() { |
357 password_manager::PasswordStore* password_store = | 361 password_manager::PasswordStore* password_store = |
358 GetPasswordStore(web_contents()); | 362 GetPasswordStore(web_contents()); |
359 if (password_store) | 363 if (password_store) |
360 password_store->RemoveObserver(this); | 364 password_store->RemoveObserver(this); |
361 } | 365 } |
OLD | NEW |