| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 #endif | 195 #endif |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ManagePasswordsUIController::SavePassword() { | 198 void ManagePasswordsUIController::SavePassword() { |
| 199 DCHECK(PasswordPendingUserDecision()); | 199 DCHECK(PasswordPendingUserDecision()); |
| 200 SavePasswordInternal(); | 200 SavePasswordInternal(); |
| 201 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 201 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 202 UpdateBubbleAndIconVisibility(); | 202 UpdateBubbleAndIconVisibility(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void ManagePasswordsUIController::UpdatePassword( |
| 206 const autofill::PasswordForm& password_form) { |
| 207 DCHECK(PasswordPendingUserDecision()); |
| 208 UpdatePasswordInternal(password_form); |
| 209 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 210 UpdateBubbleAndIconVisibility(); |
| 211 } |
| 212 |
| 205 void ManagePasswordsUIController::ChooseCredential( | 213 void ManagePasswordsUIController::ChooseCredential( |
| 206 const autofill::PasswordForm& form, | 214 const autofill::PasswordForm& form, |
| 207 password_manager::CredentialType credential_type) { | 215 password_manager::CredentialType credential_type) { |
| 208 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); | 216 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); |
| 209 DCHECK(!passwords_data_.credentials_callback().is_null()); | 217 DCHECK(!passwords_data_.credentials_callback().is_null()); |
| 210 | 218 |
| 211 // Here, |credential_type| refers to whether the credential was originally | 219 // Here, |credential_type| refers to whether the credential was originally |
| 212 // passed into ::OnChooseCredentials as part of the |local_credentials| or | 220 // passed into ::OnChooseCredentials as part of the |local_credentials| or |
| 213 // |federated_credentials| lists (e.g. whether it is an existing credential | 221 // |federated_credentials| lists (e.g. whether it is an existing credential |
| 214 // saved for this origin, or whether we should synthesize a new | 222 // saved for this origin, or whether we should synthesize a new |
| (...skipping 27 matching lines...) Expand all Loading... |
| 242 ManagePasswordsState::CredentialsCallback()); | 250 ManagePasswordsState::CredentialsCallback()); |
| 243 } | 251 } |
| 244 | 252 |
| 245 void ManagePasswordsUIController::SavePasswordInternal() { | 253 void ManagePasswordsUIController::SavePasswordInternal() { |
| 246 password_manager::PasswordFormManager* form_manager = | 254 password_manager::PasswordFormManager* form_manager = |
| 247 passwords_data_.form_manager(); | 255 passwords_data_.form_manager(); |
| 248 DCHECK(form_manager); | 256 DCHECK(form_manager); |
| 249 form_manager->Save(); | 257 form_manager->Save(); |
| 250 } | 258 } |
| 251 | 259 |
| 260 void ManagePasswordsUIController::UpdatePasswordInternal( |
| 261 const autofill::PasswordForm& password_form) { |
| 262 password_manager::PasswordFormManager* form_manager = |
| 263 passwords_data_.form_manager(); |
| 264 DCHECK(form_manager); |
| 265 form_manager->Update(password_form); |
| 266 } |
| 267 |
| 252 void ManagePasswordsUIController::NeverSavePassword() { | 268 void ManagePasswordsUIController::NeverSavePassword() { |
| 253 DCHECK(PasswordPendingUserDecision()); | 269 DCHECK(PasswordPendingUserDecision()); |
| 254 NeverSavePasswordInternal(); | 270 NeverSavePasswordInternal(); |
| 255 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); | 271 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); |
| 256 UpdateBubbleAndIconVisibility(); | 272 UpdateBubbleAndIconVisibility(); |
| 257 } | 273 } |
| 258 | 274 |
| 259 void ManagePasswordsUIController::NeverSavePasswordInternal() { | 275 void ManagePasswordsUIController::NeverSavePasswordInternal() { |
| 260 password_manager::PasswordFormManager* form_manager = | 276 password_manager::PasswordFormManager* form_manager = |
| 261 passwords_data_.form_manager(); | 277 passwords_data_.form_manager(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 377 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
| 362 #endif | 378 #endif |
| 363 } | 379 } |
| 364 | 380 |
| 365 void ManagePasswordsUIController::WebContentsDestroyed() { | 381 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 366 password_manager::PasswordStore* password_store = | 382 password_manager::PasswordStore* password_store = |
| 367 GetPasswordStore(web_contents()); | 383 GetPasswordStore(web_contents()); |
| 368 if (password_store) | 384 if (password_store) |
| 369 password_store->RemoveObserver(this); | 385 password_store->RemoveObserver(this); |
| 370 } | 386 } |
| OLD | NEW |