| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 bubble_status_ = SHOULD_POP_UP; | 93 bubble_status_ = SHOULD_POP_UP; |
| 94 UpdateBubbleAndIconVisibility(); | 94 UpdateBubbleAndIconVisibility(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool ManagePasswordsUIController::OnChooseCredentials( | 97 bool ManagePasswordsUIController::OnChooseCredentials( |
| 98 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 98 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 99 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, | 99 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, |
| 100 const GURL& origin, | 100 const GURL& origin, |
| 101 const ManagePasswordsState::CredentialsCallback& callback) { | 101 const ManagePasswordsState::CredentialsCallback& callback) { |
| 102 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 102 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
| 103 if (!HasBrowserWindow()) |
| 104 return false; |
| 103 PasswordDialogController::FormsVector locals = | 105 PasswordDialogController::FormsVector locals = |
| 104 CopyFormVector(local_credentials); | 106 CopyFormVector(local_credentials); |
| 105 PasswordDialogController::FormsVector federations = | 107 PasswordDialogController::FormsVector federations = |
| 106 CopyFormVector(federated_credentials); | 108 CopyFormVector(federated_credentials); |
| 107 passwords_data_.OnRequestCredentials( | 109 passwords_data_.OnRequestCredentials( |
| 108 std::move(local_credentials), std::move(federated_credentials), origin); | 110 std::move(local_credentials), std::move(federated_credentials), origin); |
| 109 passwords_data_.set_credentials_callback(callback); | 111 passwords_data_.set_credentials_callback(callback); |
| 110 dialog_controller_.reset(new PasswordDialogControllerImpl( | 112 dialog_controller_.reset(new PasswordDialogControllerImpl( |
| 111 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), | 113 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
| 112 this)); | 114 this)); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 AccountChooserPrompt* ManagePasswordsUIController::CreateAccountChooser( | 408 AccountChooserPrompt* ManagePasswordsUIController::CreateAccountChooser( |
| 407 PasswordDialogController* controller) { | 409 PasswordDialogController* controller) { |
| 408 return CreateAccountChooserPromptView(controller, web_contents()); | 410 return CreateAccountChooserPromptView(controller, web_contents()); |
| 409 } | 411 } |
| 410 | 412 |
| 411 AutoSigninFirstRunPrompt* ManagePasswordsUIController::CreateAutoSigninPrompt( | 413 AutoSigninFirstRunPrompt* ManagePasswordsUIController::CreateAutoSigninPrompt( |
| 412 PasswordDialogController* controller) { | 414 PasswordDialogController* controller) { |
| 413 return CreateAutoSigninPromptView(controller, web_contents()); | 415 return CreateAutoSigninPromptView(controller, web_contents()); |
| 414 } | 416 } |
| 415 | 417 |
| 418 bool ManagePasswordsUIController::HasBrowserWindow() const { |
| 419 return chrome::FindBrowserWithWebContents(web_contents()) != nullptr; |
| 420 } |
| 421 |
| 416 void ManagePasswordsUIController::DidNavigateMainFrame( | 422 void ManagePasswordsUIController::DidNavigateMainFrame( |
| 417 const content::LoadCommittedDetails& details, | 423 const content::LoadCommittedDetails& details, |
| 418 const content::FrameNavigateParams& params) { | 424 const content::FrameNavigateParams& params) { |
| 419 // Don't react to in-page (fragment) navigations. | 425 // Don't react to in-page (fragment) navigations. |
| 420 if (details.is_in_page) | 426 if (details.is_in_page) |
| 421 return; | 427 return; |
| 422 | 428 |
| 423 // It is possible that the user was not able to interact with the password | 429 // It is possible that the user was not able to interact with the password |
| 424 // bubble. | 430 // bubble. |
| 425 if (bubble_status_ == SHOWN || bubble_status_ == SHOWN_PENDING_ICON_UPDATE) | 431 if (bubble_status_ == SHOWN || bubble_status_ == SHOWN_PENDING_ICON_UPDATE) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 451 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 457 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 452 } | 458 } |
| 453 } | 459 } |
| 454 | 460 |
| 455 void ManagePasswordsUIController::WebContentsDestroyed() { | 461 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 456 password_manager::PasswordStore* password_store = | 462 password_manager::PasswordStore* password_store = |
| 457 GetPasswordStore(web_contents()); | 463 GetPasswordStore(web_contents()); |
| 458 if (password_store) | 464 if (password_store) |
| 459 password_store->RemoveObserver(this); | 465 password_store->RemoveObserver(this); |
| 460 } | 466 } |
| OLD | NEW |