Chromium Code Reviews| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ManagePasswordsUIController::OnPasswordSubmitted( | 98 void ManagePasswordsUIController::OnPasswordSubmitted( |
| 99 scoped_ptr<PasswordFormManager> form_manager) { | 99 scoped_ptr<PasswordFormManager> form_manager) { |
| 100 passwords_data_.OnPendingPassword(form_manager.Pass()); | 100 passwords_data_.OnPendingPassword(form_manager.Pass()); |
| 101 timer_.reset(new base::ElapsedTimer); | 101 timer_.reset(new base::ElapsedTimer); |
| 102 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 102 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| 103 UpdateBubbleAndIconVisibility(); | 103 UpdateBubbleAndIconVisibility(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ManagePasswordsUIController::OnUpdatePasswordSubmitted( | |
| 107 scoped_ptr<PasswordFormManager> form_manager) { | |
| 108 passwords_data_.OnUpdatePassword(form_manager.Pass()); | |
| 109 timer_.reset(new base::ElapsedTimer); | |
| 110 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | |
| 111 UpdateBubbleAndIconVisibility(); | |
| 112 } | |
| 113 | |
| 106 bool ManagePasswordsUIController::OnChooseCredentials( | 114 bool ManagePasswordsUIController::OnChooseCredentials( |
| 107 ScopedVector<autofill::PasswordForm> local_credentials, | 115 ScopedVector<autofill::PasswordForm> local_credentials, |
| 108 ScopedVector<autofill::PasswordForm> federated_credentials, | 116 ScopedVector<autofill::PasswordForm> federated_credentials, |
| 109 const GURL& origin, | 117 const GURL& origin, |
| 110 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 118 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
| 111 DCHECK_IMPLIES(local_credentials.empty(), !federated_credentials.empty()); | 119 DCHECK_IMPLIES(local_credentials.empty(), !federated_credentials.empty()); |
| 112 passwords_data_.OnRequestCredentials(local_credentials.Pass(), | 120 passwords_data_.OnRequestCredentials(local_credentials.Pass(), |
| 113 federated_credentials.Pass(), | 121 federated_credentials.Pass(), |
| 114 origin); | 122 origin); |
| 115 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 123 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 #endif | 206 #endif |
| 199 } | 207 } |
| 200 | 208 |
| 201 void ManagePasswordsUIController::SavePassword() { | 209 void ManagePasswordsUIController::SavePassword() { |
| 202 DCHECK(PasswordPendingUserDecision()); | 210 DCHECK(PasswordPendingUserDecision()); |
| 203 SavePasswordInternal(); | 211 SavePasswordInternal(); |
| 204 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 212 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 205 UpdateBubbleAndIconVisibility(); | 213 UpdateBubbleAndIconVisibility(); |
| 206 } | 214 } |
| 207 | 215 |
| 216 void ManagePasswordsUIController::UpdatePassword( | |
| 217 const autofill::PasswordForm& password_form) { | |
| 218 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); | |
|
vabr (Chromium)
2015/07/29 15:29:19
nit: DCHECK_EQ(password_manager::ui::PENDING_PASSW
dvadym
2015/07/30 11:22:44
Done.
| |
| 219 UpdatePasswordInternal(password_form); | |
| 220 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | |
| 221 UpdateBubbleAndIconVisibility(); | |
| 222 } | |
| 223 | |
| 208 void ManagePasswordsUIController::ChooseCredential( | 224 void ManagePasswordsUIController::ChooseCredential( |
| 209 const autofill::PasswordForm& form, | 225 const autofill::PasswordForm& form, |
| 210 password_manager::CredentialType credential_type) { | 226 password_manager::CredentialType credential_type) { |
| 211 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); | 227 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); |
| 212 DCHECK(!passwords_data_.credentials_callback().is_null()); | 228 DCHECK(!passwords_data_.credentials_callback().is_null()); |
| 213 | 229 |
| 214 // Here, |credential_type| refers to whether the credential was originally | 230 // Here, |credential_type| refers to whether the credential was originally |
| 215 // passed into ::OnChooseCredentials as part of the |local_credentials| or | 231 // passed into ::OnChooseCredentials as part of the |local_credentials| or |
| 216 // |federated_credentials| lists (e.g. whether it is an existing credential | 232 // |federated_credentials| lists (e.g. whether it is an existing credential |
| 217 // saved for this origin, or whether we should synthesize a new | 233 // saved for this origin, or whether we should synthesize a new |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 241 password_manager::CredentialInfo info = | 257 password_manager::CredentialInfo info = |
| 242 password_manager::CredentialInfo(form, type_to_return); | 258 password_manager::CredentialInfo(form, type_to_return); |
| 243 passwords_data_.credentials_callback().Run(info); | 259 passwords_data_.credentials_callback().Run(info); |
| 244 passwords_data_.set_credentials_callback( | 260 passwords_data_.set_credentials_callback( |
| 245 ManagePasswordsState::CredentialsCallback()); | 261 ManagePasswordsState::CredentialsCallback()); |
| 246 } | 262 } |
| 247 | 263 |
| 248 void ManagePasswordsUIController::SavePasswordInternal() { | 264 void ManagePasswordsUIController::SavePasswordInternal() { |
| 249 password_manager::PasswordFormManager* form_manager = | 265 password_manager::PasswordFormManager* form_manager = |
| 250 passwords_data_.form_manager(); | 266 passwords_data_.form_manager(); |
| 251 DCHECK(form_manager); | |
| 252 form_manager->Save(); | 267 form_manager->Save(); |
| 253 } | 268 } |
| 254 | 269 |
| 270 void ManagePasswordsUIController::UpdatePasswordInternal( | |
| 271 const autofill::PasswordForm& password_form) { | |
| 272 password_manager::PasswordFormManager* form_manager = | |
| 273 passwords_data_.form_manager(); | |
| 274 form_manager->Update(password_form); | |
| 275 } | |
| 276 | |
| 255 void ManagePasswordsUIController::NeverSavePassword() { | 277 void ManagePasswordsUIController::NeverSavePassword() { |
| 256 DCHECK(PasswordPendingUserDecision()); | 278 DCHECK(PasswordPendingUserDecision()); |
| 257 NeverSavePasswordInternal(); | 279 NeverSavePasswordInternal(); |
| 258 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); | 280 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); |
| 259 UpdateBubbleAndIconVisibility(); | 281 UpdateBubbleAndIconVisibility(); |
| 260 } | 282 } |
| 261 | 283 |
| 262 void ManagePasswordsUIController::NeverSavePasswordInternal() { | 284 void ManagePasswordsUIController::NeverSavePasswordInternal() { |
| 263 password_manager::PasswordFormManager* form_manager = | 285 password_manager::PasswordFormManager* form_manager = |
| 264 passwords_data_.form_manager(); | 286 passwords_data_.form_manager(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 | 336 |
| 315 void ManagePasswordsUIController::WasHidden() { | 337 void ManagePasswordsUIController::WasHidden() { |
| 316 #if !defined(OS_ANDROID) | 338 #if !defined(OS_ANDROID) |
| 317 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); | 339 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); |
| 318 #endif | 340 #endif |
| 319 } | 341 } |
| 320 | 342 |
| 321 const autofill::PasswordForm& ManagePasswordsUIController:: | 343 const autofill::PasswordForm& ManagePasswordsUIController:: |
| 322 PendingPassword() const { | 344 PendingPassword() const { |
| 323 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE || | 345 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE || |
| 324 state() == password_manager::ui::CONFIRMATION_STATE) << state(); | 346 state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE || |
| 347 state() == password_manager::ui::CONFIRMATION_STATE) | |
| 348 << state(); | |
| 325 password_manager::PasswordFormManager* form_manager = | 349 password_manager::PasswordFormManager* form_manager = |
| 326 passwords_data_.form_manager(); | 350 passwords_data_.form_manager(); |
| 327 DCHECK(form_manager); | 351 DCHECK(form_manager); |
| 328 return form_manager->pending_credentials(); | 352 return form_manager->pending_credentials(); |
| 329 } | 353 } |
| 330 | 354 |
| 331 void ManagePasswordsUIController::UpdateIconAndBubbleState( | 355 void ManagePasswordsUIController::UpdateIconAndBubbleState( |
| 332 ManagePasswordsIcon* icon) { | 356 ManagePasswordsIcon* icon) { |
| 333 if (should_pop_up_bubble_) { | 357 if (should_pop_up_bubble_) { |
| 334 // We must display the icon before showing the bubble, as the bubble would | 358 // We must display the icon before showing the bubble, as the bubble would |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 364 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 388 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
| 365 #endif | 389 #endif |
| 366 } | 390 } |
| 367 | 391 |
| 368 void ManagePasswordsUIController::WebContentsDestroyed() { | 392 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 369 password_manager::PasswordStore* password_store = | 393 password_manager::PasswordStore* password_store = |
| 370 GetPasswordStore(web_contents()); | 394 GetPasswordStore(web_contents()); |
| 371 if (password_store) | 395 if (password_store) |
| 372 password_store->RemoveObserver(this); | 396 password_store->RemoveObserver(this); |
| 373 } | 397 } |
| OLD | NEW |