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

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: comments 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::AutoSigninView ----------------------------------
272
273 // A view containing just one credential that was used for for automatic signing
274 // in.
275 class ManagePasswordsBubbleView::AutoSigninView
276 : public views::View,
277 public views::ButtonListener {
278 public:
279 explicit AutoSigninView(ManagePasswordsBubbleView* parent);
280
281 private:
282 // views::ButtonListener:
283 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
284
285 void OnTimer();
286
287 base::OneShotTimer<AutoSigninView> timer_;
288 ManagePasswordsBubbleView* parent_;
289 };
290
291 ManagePasswordsBubbleView::AutoSigninView::AutoSigninView(
292 ManagePasswordsBubbleView* parent)
293 : parent_(parent) {
294 SetLayoutManager(new views::FillLayout);
295 CredentialsItemView* credential = new CredentialsItemView(
296 this,
297 parent_->model()->pending_password(),
298 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL,
299 CredentialsItemView::AUTO_SIGNIN,
300 parent_->model()->GetProfile()->GetRequestContext());
301 AddChildView(credential);
302 // TODO(vasilii): enable the button to switch to the "Managed" state.
303 credential->SetEnabled(false);
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 // TODO(vasilii): close the toast and switch to the "Managed" state.
313 }
314
315 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
316 parent_->model()->OnAutoSignInToastTimeout();
317 parent_->Close();
318 }
319
268 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- 320 // ManagePasswordsBubbleView::AskUserToSubmitURLView -------------------------
269 321
270 // Asks users if they want to report the URL when the password manager failed 322 // Asks users if they want to report the URL when the password manager failed
271 // to detect the form. View has following structure: 323 // to detect the form. View has following structure:
272 // We detected that Chrome password manager failed to handle this URL. 324 // We detected that Chrome password manager failed to handle this URL.
273 // Do you want to send this URL to Google to improve Chrome? 325 // Do you want to send this URL to Google to improve Chrome?
274 // ------------------------------------------------------------- 326 // -------------------------------------------------------------
275 // https://strangesite.com/ 327 // https://strangesite.com/
276 // ------------------------------------------------------------- 328 // -------------------------------------------------------------
277 // [Send URL] [Nope] 329 // [Send URL] [Nope]
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 AddChildView(new PendingView(this)); 1019 AddChildView(new PendingView(this));
968 } else if (IsAskSubmitURLState(model()->state())) { 1020 } else if (IsAskSubmitURLState(model()->state())) {
969 AddChildView(new AskUserToSubmitURLView(this)); 1021 AddChildView(new AskUserToSubmitURLView(this));
970 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { 1022 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) {
971 AddChildView(new BlacklistedView(this)); 1023 AddChildView(new BlacklistedView(this));
972 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { 1024 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) {
973 AddChildView(new SaveConfirmationView(this)); 1025 AddChildView(new SaveConfirmationView(this));
974 } else if (model()->state() == 1026 } else if (model()->state() ==
975 password_manager::ui::CREDENTIAL_REQUEST_STATE) { 1027 password_manager::ui::CREDENTIAL_REQUEST_STATE) {
976 AddChildView(new AccountChooserView(this)); 1028 AddChildView(new AccountChooserView(this));
1029 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) {
1030 AddChildView(new AutoSigninView(this));
977 } else { 1031 } else {
978 AddChildView(new ManageView(this)); 1032 AddChildView(new ManageView(this));
979 } 1033 }
980 GetLayoutManager()->Layout(this); 1034 GetLayoutManager()->Layout(this);
981 } 1035 }
982 1036
983 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { 1037 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() {
984 model()->OnNeverForThisSiteClicked(); 1038 model()->OnNeverForThisSiteClicked();
985 Close(); 1039 Close();
986 } 1040 }
987 1041
988 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { 1042 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() {
989 model()->OnUndoNeverForThisSite(); 1043 model()->OnUndoNeverForThisSite();
990 Refresh(); 1044 Refresh();
991 } 1045 }
992 1046
993 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { 1047 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
994 if (model()->best_matches().empty()) { 1048 if (model()->best_matches().empty()) {
995 // Skip confirmation if there are no existing passwords for this site. 1049 // Skip confirmation if there are no existing passwords for this site.
996 NotifyConfirmedNeverForThisSite(); 1050 NotifyConfirmedNeverForThisSite();
997 } else { 1051 } else {
998 model()->OnConfirmationForNeverForThisSite(); 1052 model()->OnConfirmationForNeverForThisSite();
999 Refresh(); 1053 Refresh();
1000 } 1054 }
1001 } 1055 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698