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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 #endif | 198 #endif |
| 199 } | 199 } |
| 200 | 200 |
| 201 void ManagePasswordsUIController::SavePassword() { | 201 void ManagePasswordsUIController::SavePassword() { |
| 202 DCHECK(PasswordPendingUserDecision()); | 202 DCHECK(PasswordPendingUserDecision()); |
| 203 SavePasswordInternal(); | 203 SavePasswordInternal(); |
| 204 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 204 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 205 UpdateBubbleAndIconVisibility(); | 205 UpdateBubbleAndIconVisibility(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void ManagePasswordsUIController::UpdatePassword( | |
| 209 const autofill::PasswordForm& password_form) { | |
| 210 DCHECK(PasswordPendingUserDecision() || | |
|
vabr (Chromium)
2015/07/24 08:24:28
Cant this method be called when state() == passwor
dvadym
2015/07/24 16:42:39
Thanks, no, it can't, it was left from the previou
| |
| 211 state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); | |
| 212 UpdatePasswordInternal(password_form); | |
| 213 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | |
| 214 UpdateBubbleAndIconVisibility(); | |
| 215 } | |
| 216 | |
| 208 void ManagePasswordsUIController::ChooseCredential( | 217 void ManagePasswordsUIController::ChooseCredential( |
| 209 const autofill::PasswordForm& form, | 218 const autofill::PasswordForm& form, |
| 210 password_manager::CredentialType credential_type) { | 219 password_manager::CredentialType credential_type) { |
| 211 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); | 220 DCHECK_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, state()); |
| 212 DCHECK(!passwords_data_.credentials_callback().is_null()); | 221 DCHECK(!passwords_data_.credentials_callback().is_null()); |
| 213 | 222 |
| 214 // Here, |credential_type| refers to whether the credential was originally | 223 // Here, |credential_type| refers to whether the credential was originally |
| 215 // passed into ::OnChooseCredentials as part of the |local_credentials| or | 224 // passed into ::OnChooseCredentials as part of the |local_credentials| or |
| 216 // |federated_credentials| lists (e.g. whether it is an existing credential | 225 // |federated_credentials| lists (e.g. whether it is an existing credential |
| 217 // saved for this origin, or whether we should synthesize a new | 226 // saved for this origin, or whether we should synthesize a new |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 241 password_manager::CredentialInfo info = | 250 password_manager::CredentialInfo info = |
| 242 password_manager::CredentialInfo(form, type_to_return); | 251 password_manager::CredentialInfo(form, type_to_return); |
| 243 passwords_data_.credentials_callback().Run(info); | 252 passwords_data_.credentials_callback().Run(info); |
| 244 passwords_data_.set_credentials_callback( | 253 passwords_data_.set_credentials_callback( |
| 245 ManagePasswordsState::CredentialsCallback()); | 254 ManagePasswordsState::CredentialsCallback()); |
| 246 } | 255 } |
| 247 | 256 |
| 248 void ManagePasswordsUIController::SavePasswordInternal() { | 257 void ManagePasswordsUIController::SavePasswordInternal() { |
| 249 password_manager::PasswordFormManager* form_manager = | 258 password_manager::PasswordFormManager* form_manager = |
| 250 passwords_data_.form_manager(); | 259 passwords_data_.form_manager(); |
| 251 DCHECK(form_manager); | |
| 252 form_manager->Save(); | 260 form_manager->Save(); |
| 253 } | 261 } |
| 254 | 262 |
| 263 void ManagePasswordsUIController::UpdatePasswordInternal( | |
| 264 const autofill::PasswordForm& password_form) { | |
| 265 password_manager::PasswordFormManager* form_manager = | |
| 266 passwords_data_.form_manager(); | |
| 267 form_manager->Update(password_form); | |
| 268 } | |
| 269 | |
| 255 void ManagePasswordsUIController::NeverSavePassword() { | 270 void ManagePasswordsUIController::NeverSavePassword() { |
| 256 DCHECK(PasswordPendingUserDecision()); | 271 DCHECK(PasswordPendingUserDecision()); |
|
vabr (Chromium)
2015/07/24 08:24:28
Here it can also happen that state() == password_m
dvadym
2015/07/24 16:42:39
No it can't, I haven't added "Never for this site"
| |
| 257 NeverSavePasswordInternal(); | 272 NeverSavePasswordInternal(); |
| 258 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); | 273 passwords_data_.TransitionToState(password_manager::ui::BLACKLIST_STATE); |
| 259 UpdateBubbleAndIconVisibility(); | 274 UpdateBubbleAndIconVisibility(); |
| 260 } | 275 } |
| 261 | 276 |
| 262 void ManagePasswordsUIController::NeverSavePasswordInternal() { | 277 void ManagePasswordsUIController::NeverSavePasswordInternal() { |
| 263 password_manager::PasswordFormManager* form_manager = | 278 password_manager::PasswordFormManager* form_manager = |
| 264 passwords_data_.form_manager(); | 279 passwords_data_.form_manager(); |
| 265 DCHECK(form_manager); | 280 DCHECK(form_manager); |
| 266 form_manager->PermanentlyBlacklist(); | 281 form_manager->PermanentlyBlacklist(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 | 329 |
| 315 void ManagePasswordsUIController::WasHidden() { | 330 void ManagePasswordsUIController::WasHidden() { |
| 316 #if !defined(OS_ANDROID) | 331 #if !defined(OS_ANDROID) |
| 317 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); | 332 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); |
| 318 #endif | 333 #endif |
| 319 } | 334 } |
| 320 | 335 |
| 321 const autofill::PasswordForm& ManagePasswordsUIController:: | 336 const autofill::PasswordForm& ManagePasswordsUIController:: |
| 322 PendingPassword() const { | 337 PendingPassword() const { |
| 323 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE || | 338 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE || |
| 324 state() == password_manager::ui::CONFIRMATION_STATE) << state(); | 339 state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE || |
| 340 state() == password_manager::ui::CONFIRMATION_STATE) | |
| 341 << state(); | |
| 325 password_manager::PasswordFormManager* form_manager = | 342 password_manager::PasswordFormManager* form_manager = |
| 326 passwords_data_.form_manager(); | 343 passwords_data_.form_manager(); |
| 327 DCHECK(form_manager); | 344 DCHECK(form_manager); |
| 328 return form_manager->pending_credentials(); | 345 return form_manager->pending_credentials(); |
| 329 } | 346 } |
| 330 | 347 |
| 331 void ManagePasswordsUIController::UpdateIconAndBubbleState( | 348 void ManagePasswordsUIController::UpdateIconAndBubbleState( |
| 332 ManagePasswordsIcon* icon) { | 349 ManagePasswordsIcon* icon) { |
| 333 if (should_pop_up_bubble_) { | 350 if (should_pop_up_bubble_) { |
| 334 // We must display the icon before showing the bubble, as the bubble would | 351 // 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); | 381 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
| 365 #endif | 382 #endif |
| 366 } | 383 } |
| 367 | 384 |
| 368 void ManagePasswordsUIController::WebContentsDestroyed() { | 385 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 369 password_manager::PasswordStore* password_store = | 386 password_manager::PasswordStore* password_store = |
| 370 GetPasswordStore(web_contents()); | 387 GetPasswordStore(web_contents()); |
| 371 if (password_store) | 388 if (password_store) |
| 372 password_store->RemoveObserver(this); | 389 password_store->RemoveObserver(this); |
| 373 } | 390 } |
| OLD | NEW |