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" |
| 11 #include "chrome/browser/password_manager/password_store_factory.h" | 11 #include "chrome/browser/password_manager/password_store_factory.h" |
| 12 #include "chrome/browser/ui/browser_command_controller.h" | 12 #include "chrome/browser/ui/browser_command_controller.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/chrome_pages.h" | 15 #include "chrome/browser/ui/chrome_pages.h" |
| 16 #include "chrome/browser/ui/location_bar/location_bar.h" | 16 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 17 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 17 #include "chrome/browser/ui/passwords/manage_passwords_icon.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 "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.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_bubble_experiment.h" | 22 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 23 #include "components/password_manager/core/browser/password_form_manager.h" | 23 #include "components/password_manager/core/browser/password_form_manager.h" |
| 24 #include "components/password_manager/core/common/credential_manager_types.h" | 24 #include "components/password_manager/core/common/credential_manager_types.h" |
| 25 #include "content/public/browser/navigation_details.h" | 25 #include "content/public/browser/navigation_details.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 | 27 |
| 28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| 29 #include "base/android/jni_android.h" | |
| 29 #include "chrome/browser/android/chrome_application.h" | 30 #include "chrome/browser/android/chrome_application.h" |
| 31 #include "chrome/browser/android/tab_android.h" | |
| 30 #include "chrome/browser/infobars/infobar_service.h" | 32 #include "chrome/browser/infobars/infobar_service.h" |
| 31 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h" | 33 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h" |
| 34 #include "chrome/browser/password_manager/credential_android.h" | |
| 32 #endif | 35 #endif |
| 33 | 36 |
| 34 using autofill::PasswordFormMap; | 37 using autofill::PasswordFormMap; |
| 35 using password_manager::PasswordFormManager; | 38 using password_manager::PasswordFormManager; |
| 36 | 39 |
| 37 namespace { | 40 namespace { |
| 38 | 41 |
| 39 // Minimal time span the bubble should survive implicit navigations. | 42 // Minimal time span the bubble should survive implicit navigations. |
| 40 const int kBubbleMinTime = 5; | 43 const int kBubbleMinTime = 5; |
| 41 | 44 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 87 |
| 85 void ManagePasswordsUIController:: | 88 void ManagePasswordsUIController:: |
| 86 UpdateAndroidAccountChooserInfoBarVisibility() { | 89 UpdateAndroidAccountChooserInfoBarVisibility() { |
| 87 #if defined(OS_ANDROID) | 90 #if defined(OS_ANDROID) |
| 88 AccountChooserInfoBarDelegateAndroid::Create( | 91 AccountChooserInfoBarDelegateAndroid::Create( |
| 89 InfoBarService::FromWebContents(web_contents()), this); | 92 InfoBarService::FromWebContents(web_contents()), this); |
| 90 should_pop_up_bubble_ = false; | 93 should_pop_up_bubble_ = false; |
| 91 #endif | 94 #endif |
| 92 } | 95 } |
| 93 | 96 |
| 97 void ManagePasswordsUIController::UpdateAutoSigninToastVisibility() { | |
| 98 #if defined(OS_ANDROID) | |
| 99 base::android::ScopedJavaLocalRef<jobject> credential; | |
| 100 JNIEnv *env = base::android::AttachCurrentThread(); | |
| 101 if (GetFederatedForms().size() == 1) { | |
| 102 credential = CreateNativeCredential( | |
|
newt (away)
2015/08/13 16:48:04
Instead of passing the Credential object to Java (
melandory
2015/08/20 15:11:00
Done.
| |
| 103 env, *GetFederatedForms()[0], 0, | |
| 104 static_cast<int>( | |
| 105 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED)); | |
| 106 } else if (GetCurrentForms().size() == 1) { | |
| 107 credential = CreateNativeCredential( | |
| 108 env, *GetCurrentForms()[0], 0, | |
| 109 static_cast<int>( | |
| 110 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); | |
| 111 } | |
| 112 TabAndroid::FromWebContents(web_contents()) | |
| 113 ->ShowAutoSigninSnackbar(credential.obj()); | |
| 114 should_pop_up_bubble_ = false; | |
| 115 #endif | |
| 116 } | |
| 117 | |
| 94 base::TimeDelta ManagePasswordsUIController::Elapsed() const { | 118 base::TimeDelta ManagePasswordsUIController::Elapsed() const { |
| 95 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); | 119 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); |
| 96 } | 120 } |
| 97 | 121 |
| 98 void ManagePasswordsUIController::OnPasswordSubmitted( | 122 void ManagePasswordsUIController::OnPasswordSubmitted( |
| 99 scoped_ptr<PasswordFormManager> form_manager) { | 123 scoped_ptr<PasswordFormManager> form_manager) { |
| 100 passwords_data_.OnPendingPassword(form_manager.Pass()); | 124 passwords_data_.OnPendingPassword(form_manager.Pass()); |
| 101 timer_.reset(new base::ElapsedTimer); | 125 timer_.reset(new base::ElapsedTimer); |
| 102 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 126 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| 103 UpdateBubbleAndIconVisibility(); | 127 UpdateBubbleAndIconVisibility(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 133 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 157 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
| 134 return false; | 158 return false; |
| 135 } | 159 } |
| 136 | 160 |
| 137 void ManagePasswordsUIController::OnAutoSignin( | 161 void ManagePasswordsUIController::OnAutoSignin( |
| 138 ScopedVector<autofill::PasswordForm> local_forms) { | 162 ScopedVector<autofill::PasswordForm> local_forms) { |
| 139 DCHECK(!local_forms.empty()); | 163 DCHECK(!local_forms.empty()); |
| 140 passwords_data_.OnAutoSignin(local_forms.Pass()); | 164 passwords_data_.OnAutoSignin(local_forms.Pass()); |
| 141 timer_.reset(new base::ElapsedTimer); | 165 timer_.reset(new base::ElapsedTimer); |
| 142 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 166 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| 167 #if defined(OS_ANDROID) | |
| 168 UpdateAutoSigninToastVisibility(); | |
| 169 #else | |
| 143 UpdateBubbleAndIconVisibility(); | 170 UpdateBubbleAndIconVisibility(); |
| 171 #endif | |
| 144 } | 172 } |
| 145 | 173 |
| 146 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 174 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
| 147 scoped_ptr<PasswordFormManager> form_manager) { | 175 scoped_ptr<PasswordFormManager> form_manager) { |
| 148 passwords_data_.OnAutomaticPasswordSave(form_manager.Pass()); | 176 passwords_data_.OnAutomaticPasswordSave(form_manager.Pass()); |
| 149 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 177 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| 150 UpdateBubbleAndIconVisibility(); | 178 UpdateBubbleAndIconVisibility(); |
| 151 } | 179 } |
| 152 | 180 |
| 153 void ManagePasswordsUIController::OnPasswordAutofilled( | 181 void ManagePasswordsUIController::OnPasswordAutofilled( |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 416 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
| 389 #endif | 417 #endif |
| 390 } | 418 } |
| 391 | 419 |
| 392 void ManagePasswordsUIController::WebContentsDestroyed() { | 420 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 393 password_manager::PasswordStore* password_store = | 421 password_manager::PasswordStore* password_store = |
| 394 GetPasswordStore(web_contents()); | 422 GetPasswordStore(web_contents()); |
| 395 if (password_store) | 423 if (password_store) |
| 396 password_store->RemoveObserver(this); | 424 password_store->RemoveObserver(this); |
| 397 } | 425 } |
| OLD | NEW |