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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ScopedVector<autofill::PasswordForm> federated_credentials, | 97 ScopedVector<autofill::PasswordForm> federated_credentials, |
98 const GURL& origin, | 98 const GURL& origin, |
99 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 99 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
100 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 100 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
101 PasswordDialogController::FormsVector locals = | 101 PasswordDialogController::FormsVector locals = |
102 CopyFormVector(local_credentials); | 102 CopyFormVector(local_credentials); |
103 PasswordDialogController::FormsVector federations = | 103 PasswordDialogController::FormsVector federations = |
104 CopyFormVector(federated_credentials); | 104 CopyFormVector(federated_credentials); |
105 passwords_data_.OnRequestCredentials( | 105 passwords_data_.OnRequestCredentials( |
106 std::move(local_credentials), std::move(federated_credentials), origin); | 106 std::move(local_credentials), std::move(federated_credentials), origin); |
107 #if defined(OS_MACOSX) | |
108 // TODO(vasilii): remove once Mac supports the dialog. | |
109 // http://crbug.com/550922 | |
110 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | |
111 #else | |
112 dialog_controller_.reset(new PasswordDialogControllerImpl( | 107 dialog_controller_.reset(new PasswordDialogControllerImpl( |
113 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), | 108 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
114 this)); | 109 this)); |
115 dialog_controller_->ShowAccountChooser( | 110 dialog_controller_->ShowAccountChooser( |
116 CreateAccountChooser(dialog_controller_.get()), | 111 CreateAccountChooser(dialog_controller_.get()), |
117 std::move(locals), std::move(federations)); | 112 std::move(locals), std::move(federations)); |
118 #endif | |
119 UpdateBubbleAndIconVisibility(); | 113 UpdateBubbleAndIconVisibility(); |
120 if (!should_pop_up_bubble_) { | 114 if (!should_pop_up_bubble_) { |
121 passwords_data_.set_credentials_callback(callback); | 115 passwords_data_.set_credentials_callback(callback); |
122 return true; | 116 return true; |
123 } | 117 } |
124 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 118 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
125 return false; | 119 return false; |
126 } | 120 } |
127 | 121 |
128 void ManagePasswordsUIController::OnAutoSignin( | 122 void ManagePasswordsUIController::OnAutoSignin( |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 348 } |
355 | 349 |
356 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 350 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
357 if (!browser) | 351 if (!browser) |
358 return; | 352 return; |
359 LocationBar* location_bar = browser->window()->GetLocationBar(); | 353 LocationBar* location_bar = browser->window()->GetLocationBar(); |
360 DCHECK(location_bar); | 354 DCHECK(location_bar); |
361 location_bar->UpdateManagePasswordsIconAndBubble(); | 355 location_bar->UpdateManagePasswordsIconAndBubble(); |
362 } | 356 } |
363 | 357 |
364 #if defined(OS_MACOSX) | |
365 // TODO(vasilii): remove once Mac supports the dialog. | |
366 AccountChooserPrompt* ManagePasswordsUIController::CreateAccountChooser( | |
367 PasswordDialogController* controller) { | |
368 return nullptr; | |
369 } | |
370 #else | |
371 AccountChooserPrompt* ManagePasswordsUIController::CreateAccountChooser( | 358 AccountChooserPrompt* ManagePasswordsUIController::CreateAccountChooser( |
372 PasswordDialogController* controller) { | 359 PasswordDialogController* controller) { |
373 return CreateAccountChooserPromptView(controller, web_contents()); | 360 return CreateAccountChooserPromptView(controller, web_contents()); |
374 } | 361 } |
375 #endif | |
376 | 362 |
377 void ManagePasswordsUIController::DidNavigateMainFrame( | 363 void ManagePasswordsUIController::DidNavigateMainFrame( |
378 const content::LoadCommittedDetails& details, | 364 const content::LoadCommittedDetails& details, |
379 const content::FrameNavigateParams& params) { | 365 const content::FrameNavigateParams& params) { |
380 // Don't react to in-page (fragment) navigations. | 366 // Don't react to in-page (fragment) navigations. |
381 if (details.is_in_page) | 367 if (details.is_in_page) |
382 return; | 368 return; |
383 | 369 |
384 // Don't do anything if a redirect occurs. It is possible that the user was | 370 // Don't do anything if a redirect occurs. It is possible that the user was |
385 // not able to interact with the password bubble. | 371 // not able to interact with the password bubble. |
(...skipping 18 matching lines...) Expand all Loading... |
404 CommandUpdater* updater = browser->command_controller()->command_updater(); | 390 CommandUpdater* updater = browser->command_controller()->command_updater(); |
405 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 391 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
406 } | 392 } |
407 | 393 |
408 void ManagePasswordsUIController::WebContentsDestroyed() { | 394 void ManagePasswordsUIController::WebContentsDestroyed() { |
409 password_manager::PasswordStore* password_store = | 395 password_manager::PasswordStore* password_store = |
410 GetPasswordStore(web_contents()); | 396 GetPasswordStore(web_contents()); |
411 if (password_store) | 397 if (password_store) |
412 password_store->RemoveObserver(this); | 398 password_store->RemoveObserver(this); |
413 } | 399 } |
OLD | NEW |