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 "chrome/browser/android/chrome_application.h" | 29 #include "chrome/browser/android/chrome_application.h" |
| 30 #include "chrome/browser/android/tab_android.h" |
30 #include "chrome/browser/infobars/infobar_service.h" | 31 #include "chrome/browser/infobars/infobar_service.h" |
31 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" | 32 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" |
| 33 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" |
32 #endif | 34 #endif |
33 | 35 |
34 using autofill::PasswordFormMap; | 36 using autofill::PasswordFormMap; |
35 using password_manager::PasswordFormManager; | 37 using password_manager::PasswordFormManager; |
36 | 38 |
37 namespace { | 39 namespace { |
38 | 40 |
39 // Minimal time span the bubble should survive implicit navigations. | 41 // Minimal time span the bubble should survive implicit navigations. |
40 const int kBubbleMinTime = 5; | 42 const int kBubbleMinTime = 5; |
41 | 43 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 86 |
85 void ManagePasswordsUIController:: | 87 void ManagePasswordsUIController:: |
86 UpdateAndroidAccountChooserInfoBarVisibility() { | 88 UpdateAndroidAccountChooserInfoBarVisibility() { |
87 #if defined(OS_ANDROID) | 89 #if defined(OS_ANDROID) |
88 AccountChooserInfoBarDelegateAndroid::Create( | 90 AccountChooserInfoBarDelegateAndroid::Create( |
89 InfoBarService::FromWebContents(web_contents()), this); | 91 InfoBarService::FromWebContents(web_contents()), this); |
90 should_pop_up_bubble_ = false; | 92 should_pop_up_bubble_ = false; |
91 #endif | 93 #endif |
92 } | 94 } |
93 | 95 |
| 96 void ManagePasswordsUIController::UpdateAutoSigninSnackbarVisibility() { |
| 97 #if defined(OS_ANDROID) |
| 98 base::android::ScopedJavaLocalRef<jobject> credential; |
| 99 const autofill::PasswordForm *password_form = nullptr; |
| 100 if (GetFederatedForms().size() == 1) { |
| 101 password_form = GetFederatedForms()[0]; |
| 102 } else if (GetCurrentForms().size() == 1) { |
| 103 password_form = GetCurrentForms()[0]; |
| 104 } |
| 105 if (password_form) { |
| 106 // Deletes itself after snackbar was dismissed. |
| 107 AutoSigninSnackbarController* controller = new AutoSigninSnackbarController( |
| 108 TabAndroid::FromWebContents(web_contents())); |
| 109 controller->onShow(password_form->username_value); |
| 110 } |
| 111 should_pop_up_bubble_ = false; |
| 112 #endif |
| 113 } |
| 114 |
94 base::TimeDelta ManagePasswordsUIController::Elapsed() const { | 115 base::TimeDelta ManagePasswordsUIController::Elapsed() const { |
95 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); | 116 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); |
96 } | 117 } |
97 | 118 |
98 void ManagePasswordsUIController::OnPasswordSubmitted( | 119 void ManagePasswordsUIController::OnPasswordSubmitted( |
99 scoped_ptr<PasswordFormManager> form_manager) { | 120 scoped_ptr<PasswordFormManager> form_manager) { |
100 bool blacklisted = form_manager->IsBlacklisted(); | 121 bool blacklisted = form_manager->IsBlacklisted(); |
101 passwords_data_.OnPendingPassword(form_manager.Pass()); | 122 passwords_data_.OnPendingPassword(form_manager.Pass()); |
102 timer_.reset(new base::ElapsedTimer); | 123 timer_.reset(new base::ElapsedTimer); |
103 base::AutoReset<bool> resetter(&should_pop_up_bubble_, !blacklisted); | 124 base::AutoReset<bool> resetter(&should_pop_up_bubble_, !blacklisted); |
(...skipping 30 matching lines...) Expand all Loading... |
134 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 155 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
135 return false; | 156 return false; |
136 } | 157 } |
137 | 158 |
138 void ManagePasswordsUIController::OnAutoSignin( | 159 void ManagePasswordsUIController::OnAutoSignin( |
139 ScopedVector<autofill::PasswordForm> local_forms) { | 160 ScopedVector<autofill::PasswordForm> local_forms) { |
140 DCHECK(!local_forms.empty()); | 161 DCHECK(!local_forms.empty()); |
141 passwords_data_.OnAutoSignin(local_forms.Pass()); | 162 passwords_data_.OnAutoSignin(local_forms.Pass()); |
142 timer_.reset(new base::ElapsedTimer); | 163 timer_.reset(new base::ElapsedTimer); |
143 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 164 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
| 165 #if defined(OS_ANDROID) |
| 166 UpdateAutoSigninSnackbarVisibility(); |
| 167 #else |
144 UpdateBubbleAndIconVisibility(); | 168 UpdateBubbleAndIconVisibility(); |
| 169 #endif |
145 } | 170 } |
146 | 171 |
147 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 172 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
148 scoped_ptr<PasswordFormManager> form_manager) { | 173 scoped_ptr<PasswordFormManager> form_manager) { |
149 passwords_data_.OnAutomaticPasswordSave(form_manager.Pass()); | 174 passwords_data_.OnAutomaticPasswordSave(form_manager.Pass()); |
150 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); | 175 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); |
151 UpdateBubbleAndIconVisibility(); | 176 UpdateBubbleAndIconVisibility(); |
152 } | 177 } |
153 | 178 |
154 void ManagePasswordsUIController::OnPasswordAutofilled( | 179 void ManagePasswordsUIController::OnPasswordAutofilled( |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 407 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
383 #endif | 408 #endif |
384 } | 409 } |
385 | 410 |
386 void ManagePasswordsUIController::WebContentsDestroyed() { | 411 void ManagePasswordsUIController::WebContentsDestroyed() { |
387 password_manager::PasswordStore* password_store = | 412 password_manager::PasswordStore* password_store = |
388 GetPasswordStore(web_contents()); | 413 GetPasswordStore(web_contents()); |
389 if (password_store) | 414 if (password_store) |
390 password_store->RemoveObserver(this); | 415 password_store->RemoveObserver(this); |
391 } | 416 } |
OLD | NEW |