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

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

Issue 1151373006: Update Confirmation UI for saved password change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed reviewer comments Created 5 years, 6 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 "base/timer/timer.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void StyledLabelLinkClicked(const gfx::Range& range, 368 void StyledLabelLinkClicked(const gfx::Range& range,
369 int event_flags) override; 369 int event_flags) override;
370 370
371 // Handles the event when the user changes an index of a combobox. 371 // Handles the event when the user changes an index of a combobox.
372 void OnPerformAction(views::Combobox* source) override; 372 void OnPerformAction(views::Combobox* source) override;
373 373
374 ManagePasswordsBubbleView* parent_; 374 ManagePasswordsBubbleView* parent_;
375 375
376 views::BlueButton* save_button_; 376 views::BlueButton* save_button_;
377 377
378 views::LabelButton* nope_button_;
379
378 // The combobox doesn't take ownership of its model. If we created a 380 // The combobox doesn't take ownership of its model. If we created a
379 // combobox we need to ensure that we delete the model here, and because the 381 // combobox we need to ensure that we delete the model here, and because the
380 // combobox uses the model in it's destructor, we need to make sure we 382 // combobox uses the model in it's destructor, we need to make sure we
381 // delete the model _after_ the combobox itself is deleted. 383 // delete the model _after_ the combobox itself is deleted.
382 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_; 384 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
383 scoped_ptr<views::Combobox> refuse_combobox_; 385 scoped_ptr<views::Combobox> refuse_combobox_;
384 386
385 DISALLOW_COPY_AND_ASSIGN(PendingView); 387 DISALLOW_COPY_AND_ASSIGN(PendingView);
386 }; 388 };
387 389
388 ManagePasswordsBubbleView::PendingView::PendingView( 390 ManagePasswordsBubbleView::PendingView::PendingView(
389 ManagePasswordsBubbleView* parent) 391 ManagePasswordsBubbleView* parent)
390 : parent_(parent) { 392 : parent_(parent), save_button_(nullptr), nope_button_(nullptr) {
391 views::GridLayout* layout = new views::GridLayout(this); 393 views::GridLayout* layout = new views::GridLayout(this);
392 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); 394 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
393 SetLayoutManager(layout); 395 SetLayoutManager(layout);
394 396
395 std::vector<const autofill::PasswordForm*> credentials( 397 std::vector<const autofill::PasswordForm*> credentials;
396 1, &parent->model()->pending_password()); 398 if (parent->model()->account_for_update_selection()) {
vabr (Chromium) 2015/06/19 18:03:16 Should you actually create a separate view rather
dvadym 2015/06/22 14:43:33 Yeah, this is a good question that constantly appe
399 for (auto local_credential : parent->model()->local_credentials())
400 credentials.push_back(local_credential);
401 } else {
402 credentials.push_back(&parent->model()->pending_password());
403 }
397 // Create the pending credential item, save button and refusal combobox. 404 // Create the pending credential item, save button and refusal combobox.
398 ManagePasswordItemsView* item = 405 ManagePasswordItemsView* item =
399 new ManagePasswordItemsView(parent_->model(), credentials); 406 new ManagePasswordItemsView(parent_->model(), credentials);
400 save_button_ = new views::BlueButton( 407 if (parent->model()->is_password_change_form_without_username()) {
401 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); 408 nope_button_ = new views::LabelButton(
402 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 409 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON));
403 ui::ResourceBundle::SmallFont)); 410 nope_button_->SetStyle(views::Button::STYLE_BUTTON);
404 411 nope_button_->SetFontList(
405 combobox_model_.reset(new SavePasswordRefusalComboboxModel); 412 ui::ResourceBundle::GetSharedInstance().GetFontList(
406 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); 413 ui::ResourceBundle::SmallFont));
407 refuse_combobox_->set_listener(this); 414 } else {
408 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); 415 combobox_model_.reset(new SavePasswordRefusalComboboxModel);
409 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. 416 refuse_combobox_.reset(new views::Combobox(combobox_model_.get()));
417 refuse_combobox_->set_listener(this);
418 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION);
419 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox.
420 }
421 if (!parent->model()->account_for_update_selection()) {
422 save_button_ =
423 new views::BlueButton(this, parent_->model()->save_button_text());
424 save_button_->SetFontList(
425 ui::ResourceBundle::GetSharedInstance().GetFontList(
426 ui::ResourceBundle::SmallFont));
427 }
410 428
411 // Title row. 429 // Title row.
412 views::StyledLabel* title_label = 430 views::StyledLabel* title_label =
413 new views::StyledLabel(parent_->model()->title(), this); 431 new views::StyledLabel(parent_->model()->title(), this);
414 title_label->SetBaseFontList( 432 title_label->SetBaseFontList(
415 ui::ResourceBundle::GetSharedInstance().GetFontList( 433 ui::ResourceBundle::GetSharedInstance().GetFontList(
416 ui::ResourceBundle::MediumFont)); 434 ui::ResourceBundle::MediumFont));
417 if (!parent_->model()->title_brand_link_range().is_empty()) { 435 if (!parent_->model()->title_brand_link_range().is_empty()) {
418 title_label->AddStyleRange( 436 title_label->AddStyleRange(
419 parent_->model()->title_brand_link_range(), 437 parent_->model()->title_brand_link_range(),
420 views::StyledLabel::RangeStyleInfo::CreateForLink()); 438 views::StyledLabel::RangeStyleInfo::CreateForLink());
421 } 439 }
422 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); 440 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
423 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 441 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
424 layout->AddView(title_label); 442 layout->AddView(title_label);
425 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 443 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
426 444
427 // Credential row. 445 // Credential row.
428 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 446 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
429 layout->AddView(item); 447 layout->AddView(item);
430 448
431 // Button row. 449 // Button row.
432 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); 450 ColumnSetType button_column_type =
433 layout->StartRowWithPadding( 451 parent->model()->account_for_update_selection()
434 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); 452 ? SINGLE_BUTTON_COLUMN_SET
435 layout->AddView(save_button_); 453 : DOUBLE_BUTTON_COLUMN_SET;
436 layout->AddView(refuse_combobox_.get()); 454 BuildColumnSet(layout, button_column_type);
455 layout->StartRowWithPadding(0, button_column_type, 0,
456 views::kRelatedControlVerticalSpacing);
457 if (parent->model()->account_for_update_selection()) {
458 layout->AddView(nope_button_);
459 } else {
460 layout->AddView(save_button_);
461 if (parent->model()->is_password_change_form_without_username())
462 layout->AddView(nope_button_);
463 else
464 layout->AddView(refuse_combobox_.get());
465 }
437 466
438 // Extra padding for visual awesomeness. 467 // Extra padding for visual awesomeness.
439 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 468 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
440 469
441 parent_->set_initially_focused_view(save_button_); 470 parent_->set_initially_focused_view(save_button_);
442 } 471 }
443 472
444 ManagePasswordsBubbleView::PendingView::~PendingView() { 473 ManagePasswordsBubbleView::PendingView::~PendingView() {
445 } 474 }
446 475
447 void ManagePasswordsBubbleView::PendingView::ButtonPressed( 476 void ManagePasswordsBubbleView::PendingView::ButtonPressed(
448 views::Button* sender, 477 views::Button* sender,
449 const ui::Event& event) { 478 const ui::Event& event) {
450 DCHECK(sender == save_button_); 479 DCHECK(sender == save_button_ || sender == nope_button_);
451 parent_->model()->OnSaveClicked(); 480 if (sender == save_button_)
481 parent_->model()->OnSaveClicked();
452 parent_->Close(); 482 parent_->Close();
453 } 483 }
454 484
455 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked( 485 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked(
456 const gfx::Range& range, 486 const gfx::Range& range,
457 int event_flags) { 487 int event_flags) {
458 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); 488 DCHECK_EQ(range, parent_->model()->title_brand_link_range());
459 parent_->model()->OnBrandLinkClicked(); 489 parent_->model()->OnBrandLinkClicked();
460 } 490 }
461 491
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { 1247 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
1218 if (model()->local_credentials().empty()) { 1248 if (model()->local_credentials().empty()) {
1219 // Skip confirmation if there are no existing passwords for this site. 1249 // Skip confirmation if there are no existing passwords for this site.
1220 NotifyConfirmedNeverForThisSite(); 1250 NotifyConfirmedNeverForThisSite();
1221 } else { 1251 } else {
1222 model()->OnConfirmationForNeverForThisSite(); 1252 model()->OnConfirmationForNeverForThisSite();
1223 Refresh(); 1253 Refresh();
1224 SizeToContents(); 1254 SizeToContents();
1225 } 1255 }
1226 } 1256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698