| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return password_manager::FindStatsByUsername( | 237 return password_manager::FindStatsByUsername( |
| 238 form_manager->interactions_stats(), | 238 form_manager->interactions_stats(), |
| 239 form_manager->pending_credentials().username_value); | 239 form_manager->pending_credentials().username_value); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void ManagePasswordsUIController::OnBubbleShown() { | 242 void ManagePasswordsUIController::OnBubbleShown() { |
| 243 bubble_status_ = SHOWN; | 243 bubble_status_ = SHOWN; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void ManagePasswordsUIController::OnBubbleHidden() { | 246 void ManagePasswordsUIController::OnBubbleHidden() { |
| 247 bool update_icon = (bubble_status_ == SHOWN_PENDING_ICON_UPDATE); |
| 247 bubble_status_ = NOT_SHOWN; | 248 bubble_status_ = NOT_SHOWN; |
| 248 if (GetState() == password_manager::ui::CONFIRMATION_STATE || | 249 if (GetState() == password_manager::ui::CONFIRMATION_STATE || |
| 249 GetState() == password_manager::ui::AUTO_SIGNIN_STATE) { | 250 GetState() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 250 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 251 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 252 update_icon = true; |
| 253 } |
| 254 if (update_icon) |
| 251 UpdateBubbleAndIconVisibility(); | 255 UpdateBubbleAndIconVisibility(); |
| 252 } | |
| 253 } | 256 } |
| 254 | 257 |
| 255 void ManagePasswordsUIController::OnNoInteractionOnUpdate() { | 258 void ManagePasswordsUIController::OnNoInteractionOnUpdate() { |
| 256 if (GetState() != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | 259 if (GetState() != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { |
| 257 // Do nothing if the state was changed. It can happen for example when the | 260 // Do nothing if the state was changed. It can happen for example when the |
| 258 // update bubble is active and a page navigation happens. | 261 // update bubble is active and a page navigation happens. |
| 259 return; | 262 return; |
| 260 } | 263 } |
| 261 password_manager::PasswordFormManager* form_manager = | 264 password_manager::PasswordFormManager* form_manager = |
| 262 passwords_data_.form_manager(); | 265 passwords_data_.form_manager(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 274 void ManagePasswordsUIController::NeverSavePassword() { | 277 void ManagePasswordsUIController::NeverSavePassword() { |
| 275 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); | 278 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); |
| 276 NeverSavePasswordInternal(); | 279 NeverSavePasswordInternal(); |
| 277 // The state stays the same. | 280 // The state stays the same. |
| 278 } | 281 } |
| 279 | 282 |
| 280 void ManagePasswordsUIController::SavePassword() { | 283 void ManagePasswordsUIController::SavePassword() { |
| 281 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); | 284 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); |
| 282 SavePasswordInternal(); | 285 SavePasswordInternal(); |
| 283 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 286 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 284 UpdateBubbleAndIconVisibility(); | 287 // The icon is to be updated after the bubble (either "Save password" or "Sign |
| 288 // in to Chrome") is closed. |
| 289 bubble_status_ = SHOWN_PENDING_ICON_UPDATE; |
| 285 } | 290 } |
| 286 | 291 |
| 287 void ManagePasswordsUIController::UpdatePassword( | 292 void ManagePasswordsUIController::UpdatePassword( |
| 288 const autofill::PasswordForm& password_form) { | 293 const autofill::PasswordForm& password_form) { |
| 289 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, GetState()); | 294 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, GetState()); |
| 290 UpdatePasswordInternal(password_form); | 295 UpdatePasswordInternal(password_form); |
| 291 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 296 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 292 UpdateBubbleAndIconVisibility(); | 297 UpdateBubbleAndIconVisibility(); |
| 293 } | 298 } |
| 294 | 299 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 320 params.disposition = NEW_FOREGROUND_TAB; | 325 params.disposition = NEW_FOREGROUND_TAB; |
| 321 chrome::Navigate(¶ms); | 326 chrome::Navigate(¶ms); |
| 322 } | 327 } |
| 323 | 328 |
| 324 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() { | 329 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() { |
| 325 chrome::ShowSettingsSubPage( | 330 chrome::ShowSettingsSubPage( |
| 326 chrome::FindBrowserWithWebContents(web_contents()), | 331 chrome::FindBrowserWithWebContents(web_contents()), |
| 327 chrome::kPasswordManagerSubPage); | 332 chrome::kPasswordManagerSubPage); |
| 328 } | 333 } |
| 329 | 334 |
| 335 void ManagePasswordsUIController::NavigateToChromeSignIn() { |
| 336 // TODO(http://crbug.com/615825): do the job. |
| 337 } |
| 338 |
| 330 void ManagePasswordsUIController::OnDialogHidden() { | 339 void ManagePasswordsUIController::OnDialogHidden() { |
| 331 dialog_controller_.reset(); | 340 dialog_controller_.reset(); |
| 332 if (GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 341 if (GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE) { |
| 333 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 342 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 334 UpdateBubbleAndIconVisibility(); | 343 UpdateBubbleAndIconVisibility(); |
| 335 } | 344 } |
| 336 } | 345 } |
| 337 | 346 |
| 338 void ManagePasswordsUIController::SavePasswordInternal() { | 347 void ManagePasswordsUIController::SavePasswordInternal() { |
| 339 password_manager::PasswordStore* password_store = | 348 password_manager::PasswordStore* password_store = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 399 |
| 391 void ManagePasswordsUIController::DidNavigateMainFrame( | 400 void ManagePasswordsUIController::DidNavigateMainFrame( |
| 392 const content::LoadCommittedDetails& details, | 401 const content::LoadCommittedDetails& details, |
| 393 const content::FrameNavigateParams& params) { | 402 const content::FrameNavigateParams& params) { |
| 394 // Don't react to in-page (fragment) navigations. | 403 // Don't react to in-page (fragment) navigations. |
| 395 if (details.is_in_page) | 404 if (details.is_in_page) |
| 396 return; | 405 return; |
| 397 | 406 |
| 398 // It is possible that the user was not able to interact with the password | 407 // It is possible that the user was not able to interact with the password |
| 399 // bubble. | 408 // bubble. |
| 400 if (bubble_status_ == SHOWN) | 409 if (bubble_status_ == SHOWN || bubble_status_ == SHOWN_PENDING_ICON_UPDATE) |
| 401 return; | 410 return; |
| 402 | 411 |
| 403 // Otherwise, reset the password manager. | 412 // Otherwise, reset the password manager. |
| 404 DestroyAccountChooser(); | 413 DestroyAccountChooser(); |
| 405 passwords_data_.OnInactive(); | 414 passwords_data_.OnInactive(); |
| 406 UpdateBubbleAndIconVisibility(); | 415 UpdateBubbleAndIconVisibility(); |
| 407 } | 416 } |
| 408 | 417 |
| 409 void ManagePasswordsUIController::WasHidden() { | 418 void ManagePasswordsUIController::WasHidden() { |
| 410 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); | 419 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 426 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 435 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 427 } | 436 } |
| 428 } | 437 } |
| 429 | 438 |
| 430 void ManagePasswordsUIController::WebContentsDestroyed() { | 439 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 431 password_manager::PasswordStore* password_store = | 440 password_manager::PasswordStore* password_store = |
| 432 GetPasswordStore(web_contents()); | 441 GetPasswordStore(web_contents()); |
| 433 if (password_store) | 442 if (password_store) |
| 434 password_store->RemoveObserver(this); | 443 password_store->RemoveObserver(this); |
| 435 } | 444 } |
| OLD | NEW |