Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 924733003: Credential Manager API pops up an auto-signin toast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "base/timer/timer.h"
7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" 14 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" 16 #include "chrome/browser/ui/views/passwords/credentials_item_view.h"
16 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" 17 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h"
(...skipping 15 matching lines...) Expand all
32 #include "ui/views/layout/fill_layout.h" 33 #include "ui/views/layout/fill_layout.h"
33 #include "ui/views/layout/grid_layout.h" 34 #include "ui/views/layout/grid_layout.h"
34 #include "ui/views/layout/layout_constants.h" 35 #include "ui/views/layout/layout_constants.h"
35 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
36 37
37 38
38 // Helpers -------------------------------------------------------------------- 39 // Helpers --------------------------------------------------------------------
39 40
40 namespace { 41 namespace {
41 42
43 const int kAutoSigninToastTimeout = 5;
42 const int kDesiredBubbleWidth = 370; 44 const int kDesiredBubbleWidth = 370;
43 45
44 enum ColumnSetType { 46 enum ColumnSetType {
45 // | | (FILL, FILL) | | 47 // | | (FILL, FILL) | |
46 // Used for the bubble's header, the credentials list, and for simple 48 // Used for the bubble's header, the credentials list, and for simple
47 // messages like "No passwords". 49 // messages like "No passwords".
48 SINGLE_VIEW_COLUMN_SET = 0, 50 SINGLE_VIEW_COLUMN_SET = 0,
49 51
50 // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | | 52 // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | |
51 // Used for buttons at the bottom of the bubble which should nest at the 53 // Used for buttons at the bottom of the bubble which should nest at the
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 241
240 void ManagePasswordsBubbleView::AccountChooserView::AddCredentialItemsWithType( 242 void ManagePasswordsBubbleView::AccountChooserView::AddCredentialItemsWithType(
241 views::GridLayout* layout, 243 views::GridLayout* layout,
242 const ScopedVector<autofill::PasswordForm>& password_forms, 244 const ScopedVector<autofill::PasswordForm>& password_forms,
243 password_manager::CredentialType type) { 245 password_manager::CredentialType type) {
244 net::URLRequestContextGetter* request_context = 246 net::URLRequestContextGetter* request_context =
245 parent_->model()->GetProfile()->GetRequestContext(); 247 parent_->model()->GetProfile()->GetRequestContext();
246 for (autofill::PasswordForm* form : password_forms) { 248 for (autofill::PasswordForm* form : password_forms) {
247 // Add the title to the layout with appropriate padding. 249 // Add the title to the layout with appropriate padding.
248 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 250 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
249 layout->AddView( 251 layout->AddView(new CredentialsItemView(
250 new CredentialsItemView(this, *form, type, request_context)); 252 this, *form, type, CredentialsItemView::ACCOUNT_CHOOSER,
253 request_context));
251 } 254 }
252 } 255 }
253 256
254 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( 257 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed(
255 views::Button* sender, const ui::Event& event) { 258 views::Button* sender, const ui::Event& event) {
256 if (sender != cancel_button_) { 259 if (sender != cancel_button_) {
257 // ManagePasswordsBubbleModel should care about calling a callback in case 260 // ManagePasswordsBubbleModel should care about calling a callback in case
258 // the bubble is dismissed by any other means. 261 // the bubble is dismissed by any other means.
259 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); 262 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender);
260 parent_->model()->OnChooseCredentials(view->form(), 263 parent_->model()->OnChooseCredentials(view->form(),
261 view->credential_type()); 264 view->credential_type());
262 } else { 265 } else {
263 parent_->model()->OnNopeClicked(); 266 parent_->model()->OnNopeClicked();
264 } 267 }
265 parent_->Close(); 268 parent_->Close();
266 } 269 }
267 270
271 // ManagePasswordsBubbleView::AccountChooserView ------------------------------
Mike West 2015/02/18 22:28:04 Nit: AccountChooserView -> AutoSignInView
vasilii 2015/02/19 09:37:34 Done.
272
273 // A view offering the user the ability to choose credentials for
274 // authentication. Contains a list of CredentialsItemView, along with a
275 // "Cancel" button.
Mike West 2015/02/18 22:28:04 Nit: Please update this comment as well.
vasilii 2015/02/19 09:37:34 Done.
276 class ManagePasswordsBubbleView::AutoSigninView
277 : public views::View,
278 public views::ButtonListener {
279 public:
280 explicit AutoSigninView(ManagePasswordsBubbleView* parent);
281
282 private:
283 // views::ButtonListener:
284 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
285
286 void OnTimer();
287
288 base::OneShotTimer<AutoSigninView> timer_;
289 ManagePasswordsBubbleView* parent_;
290 };
291
292 ManagePasswordsBubbleView::AutoSigninView::AutoSigninView(
293 ManagePasswordsBubbleView* parent)
294 : parent_(parent) {
295 SetLayoutManager(new views::FillLayout);
296 CredentialsItemView* credential = new CredentialsItemView(
297 this,
298 parent_->model()->pending_password(),
299 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL,
300 CredentialsItemView::AUTO_SIGNIN,
301 parent_->model()->GetProfile()->GetRequestContext());
302 AddChildView(credential);
303 credential->SetEnabled(false);
Mike West 2015/02/18 22:28:04 // TODO?
vasilii 2015/02/19 09:37:34 Done.
304 parent_->set_initially_focused_view(credential);
305
306 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kAutoSigninToastTimeout),
307 this, &AutoSigninView::OnTimer);
308 }
309
310 void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed(
311 views::Button* sender, const ui::Event& event) {
312 }
Mike West 2015/02/18 22:28:04 // TODO?
vasilii 2015/02/19 09:37:34 Done.
313
314 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
315 parent_->model()->OnAutoSignInToastTimeout();
316 parent_->Close();
317 }
318
268 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- 319 // ManagePasswordsBubbleView::AskUserToSubmitURLView -------------------------
269 320
270 // Asks users if they want to report the URL when the password manager failed 321 // Asks users if they want to report the URL when the password manager failed
271 // to detect the form. View has following structure: 322 // to detect the form. View has following structure:
272 // We detected that Chrome password manager failed to handle this URL. 323 // We detected that Chrome password manager failed to handle this URL.
273 // Do you want to send this URL to Google to improve Chrome? 324 // Do you want to send this URL to Google to improve Chrome?
274 // ------------------------------------------------------------- 325 // -------------------------------------------------------------
275 // https://strangesite.com/ 326 // https://strangesite.com/
276 // ------------------------------------------------------------- 327 // -------------------------------------------------------------
277 // [Send URL] [Nope] 328 // [Send URL] [Nope]
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 AddChildView(new PendingView(this)); 1018 AddChildView(new PendingView(this));
968 } else if (IsAskSubmitURLState(model()->state())) { 1019 } else if (IsAskSubmitURLState(model()->state())) {
969 AddChildView(new AskUserToSubmitURLView(this)); 1020 AddChildView(new AskUserToSubmitURLView(this));
970 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { 1021 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) {
971 AddChildView(new BlacklistedView(this)); 1022 AddChildView(new BlacklistedView(this));
972 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { 1023 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) {
973 AddChildView(new SaveConfirmationView(this)); 1024 AddChildView(new SaveConfirmationView(this));
974 } else if (model()->state() == 1025 } else if (model()->state() ==
975 password_manager::ui::CREDENTIAL_REQUEST_STATE) { 1026 password_manager::ui::CREDENTIAL_REQUEST_STATE) {
976 AddChildView(new AccountChooserView(this)); 1027 AddChildView(new AccountChooserView(this));
1028 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) {
Mike West 2015/02/18 22:28:04 Did the previous CL change the state back to MANAG
vasilii 2015/02/19 09:37:34 Just talk. In the previous CL I saved all the form
1029 AddChildView(new AutoSigninView(this));
977 } else { 1030 } else {
978 AddChildView(new ManageView(this)); 1031 AddChildView(new ManageView(this));
979 } 1032 }
980 GetLayoutManager()->Layout(this); 1033 GetLayoutManager()->Layout(this);
981 } 1034 }
982 1035
983 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { 1036 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() {
984 model()->OnNeverForThisSiteClicked(); 1037 model()->OnNeverForThisSiteClicked();
985 Close(); 1038 Close();
986 } 1039 }
987 1040
988 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { 1041 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() {
989 model()->OnUndoNeverForThisSite(); 1042 model()->OnUndoNeverForThisSite();
990 Refresh(); 1043 Refresh();
991 } 1044 }
992 1045
993 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { 1046 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
994 if (model()->best_matches().empty()) { 1047 if (model()->best_matches().empty()) {
995 // Skip confirmation if there are no existing passwords for this site. 1048 // Skip confirmation if there are no existing passwords for this site.
996 NotifyConfirmedNeverForThisSite(); 1049 NotifyConfirmedNeverForThisSite();
997 } else { 1050 } else {
998 model()->OnConfirmationForNeverForThisSite(); 1051 model()->OnConfirmationForNeverForThisSite();
999 Refresh(); 1052 Refresh();
1000 } 1053 }
1001 } 1054 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698