| 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 "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 10 #include "chrome/browser/password_manager/password_store_factory.h" | 10 #include "chrome/browser/password_manager/password_store_factory.h" |
| 11 #include "chrome/browser/ui/browser_command_controller.h" | 11 #include "chrome/browser/ui/browser_command_controller.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/chrome_pages.h" | 14 #include "chrome/browser/ui/chrome_pages.h" |
| 15 #include "chrome/browser/ui/location_bar/location_bar.h" | 15 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 16 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 16 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
| 17 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" | 17 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" |
| 18 #include "chrome/browser/ui/tab_dialogs.h" | 18 #include "chrome/browser/ui/tab_dialogs.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "components/password_manager/content/common/credential_manager_types.h" | 20 #include "components/password_manager/content/common/credential_manager_types.h" |
| 21 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 21 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 22 #include "components/password_manager/core/browser/password_form_manager.h" | 22 #include "components/password_manager/core/browser/password_form_manager.h" |
| 23 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 24 | 24 |
| 25 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
| 26 #include "chrome/browser/android/chromium_application.h" | 26 #include "chrome/browser/android/chromium_application.h" |
| 27 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 using autofill::PasswordFormMap; | 30 using autofill::PasswordFormMap; |
| 30 using password_manager::PasswordFormManager; | 31 using password_manager::PasswordFormManager; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 password_manager::PasswordStore* GetPasswordStore( | 35 password_manager::PasswordStore* GetPasswordStore( |
| 35 content::WebContents* web_contents) { | 36 content::WebContents* web_contents) { |
| 36 return PasswordStoreFactory::GetForProfile( | 37 return PasswordStoreFactory::GetForProfile( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const GURL& origin, | 122 const GURL& origin, |
| 122 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 123 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
| 123 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 124 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
| 124 form_manager_.reset(); | 125 form_manager_.reset(); |
| 125 origin_ = origin; | 126 origin_ = origin; |
| 126 local_credentials_forms_.swap(local_credentials); | 127 local_credentials_forms_.swap(local_credentials); |
| 127 federated_credentials_forms_.swap(federated_credentials); | 128 federated_credentials_forms_.swap(federated_credentials); |
| 128 // The map is useless because usernames may overlap. | 129 // The map is useless because usernames may overlap. |
| 129 password_form_map_.clear(); | 130 password_form_map_.clear(); |
| 130 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); | 131 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); |
| 132 #if defined(OS_ANDROID) |
| 133 AccountChooserInfoBarDelegateAndroid::Create(web_contents(), this); |
| 134 credentials_callback_ = callback; |
| 135 return true; |
| 136 #else |
| 131 UpdateBubbleAndIconVisibility(); | 137 UpdateBubbleAndIconVisibility(); |
| 138 #endif |
| 132 if (bubble_shown_) | 139 if (bubble_shown_) |
| 133 credentials_callback_ = callback; | 140 credentials_callback_ = callback; |
| 134 return bubble_shown_; | 141 return bubble_shown_; |
| 135 } | 142 } |
| 136 | 143 |
| 137 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 144 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
| 138 scoped_ptr<PasswordFormManager> form_manager) { | 145 scoped_ptr<PasswordFormManager> form_manager) { |
| 139 form_manager_ = form_manager.Pass(); | 146 form_manager_ = form_manager.Pass(); |
| 140 password_form_map_ = ConstifyMap(form_manager_->best_matches()); | 147 password_form_map_ = ConstifyMap(form_manager_->best_matches()); |
| 141 password_form_map_[form_manager_->associated_username()] = | 148 password_form_map_[form_manager_->associated_username()] = |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 359 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
| 353 return password_manager::ui::IsPendingState(state_); | 360 return password_manager::ui::IsPendingState(state_); |
| 354 } | 361 } |
| 355 | 362 |
| 356 void ManagePasswordsUIController::WebContentsDestroyed() { | 363 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 357 password_manager::PasswordStore* password_store = | 364 password_manager::PasswordStore* password_store = |
| 358 GetPasswordStore(web_contents()); | 365 GetPasswordStore(web_contents()); |
| 359 if (password_store) | 366 if (password_store) |
| 360 password_store->RemoveObserver(this); | 367 password_store->RemoveObserver(this); |
| 361 } | 368 } |
| OLD | NEW |