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

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: Clean up 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 void StyledLabelLinkClicked(const gfx::Range& range, 369 void StyledLabelLinkClicked(const gfx::Range& range,
370 int event_flags) override; 370 int event_flags) override;
371 371
372 // Handles the event when the user changes an index of a combobox. 372 // Handles the event when the user changes an index of a combobox.
373 void OnPerformAction(views::Combobox* source) override; 373 void OnPerformAction(views::Combobox* source) override;
374 374
375 ManagePasswordsBubbleView* parent_; 375 ManagePasswordsBubbleView* parent_;
376 376
377 views::BlueButton* save_button_; 377 views::BlueButton* save_button_;
378 378
379 views::LabelButton* nope_button_;
vasilii 2015/06/03 18:32:02 I suggest that you go with a new UpdateView implem
dvadym 2015/07/23 09:45:43 It's implemented UpdatePendingView class that hand
380
379 // The combobox doesn't take ownership of its model. If we created a 381 // The combobox doesn't take ownership of its model. If we created a
380 // combobox we need to ensure that we delete the model here, and because the 382 // combobox we need to ensure that we delete the model here, and because the
381 // combobox uses the model in it's destructor, we need to make sure we 383 // combobox uses the model in it's destructor, we need to make sure we
382 // delete the model _after_ the combobox itself is deleted. 384 // delete the model _after_ the combobox itself is deleted.
383 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_; 385 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
384 scoped_ptr<views::Combobox> refuse_combobox_; 386 scoped_ptr<views::Combobox> refuse_combobox_;
385 387
386 DISALLOW_COPY_AND_ASSIGN(PendingView); 388 DISALLOW_COPY_AND_ASSIGN(PendingView);
387 }; 389 };
388 390
389 ManagePasswordsBubbleView::PendingView::PendingView( 391 ManagePasswordsBubbleView::PendingView::PendingView(
390 ManagePasswordsBubbleView* parent) 392 ManagePasswordsBubbleView* parent)
391 : parent_(parent) { 393 : parent_(parent), save_button_(nullptr), nope_button_(nullptr) {
392 views::GridLayout* layout = new views::GridLayout(this); 394 views::GridLayout* layout = new views::GridLayout(this);
393 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); 395 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
394 SetLayoutManager(layout); 396 SetLayoutManager(layout);
395 397
396 std::vector<const autofill::PasswordForm*> credentials( 398 std::vector<const autofill::PasswordForm*> credentials;
397 1, &parent->model()->pending_password()); 399 if (parent->model()->account_for_update_selection()) {
400 for (auto local_credential : parent->model()->local_credentials())
401 credentials.push_back(local_credential);
402 } else {
403 credentials.push_back(&parent->model()->pending_password());
404 }
398 // Create the pending credential item, save button and refusal combobox. 405 // Create the pending credential item, save button and refusal combobox.
399 ManagePasswordItemsView* item = 406 ManagePasswordItemsView* item =
400 new ManagePasswordItemsView(parent_->model(), credentials); 407 new ManagePasswordItemsView(parent_->model(), credentials);
401 save_button_ = new views::BlueButton( 408 if (parent->model()->is_password_change_form_without_username()) {
402 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); 409 nope_button_ = new views::LabelButton(
403 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 410 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON));
404 ui::ResourceBundle::SmallFont)); 411 nope_button_->SetStyle(views::Button::STYLE_BUTTON);
405 412 nope_button_->SetFontList(
406 combobox_model_.reset(new SavePasswordRefusalComboboxModel); 413 ui::ResourceBundle::GetSharedInstance().GetFontList(
407 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); 414 ui::ResourceBundle::SmallFont));
408 refuse_combobox_->set_listener(this); 415 } else {
409 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); 416 combobox_model_.reset(new SavePasswordRefusalComboboxModel);
410 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. 417 refuse_combobox_.reset(new views::Combobox(combobox_model_.get()));
418 refuse_combobox_->set_listener(this);
419 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION);
420 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox.
421 }
422 if (!parent->model()->account_for_update_selection()) {
423 save_button_ =
424 new views::BlueButton(this, parent_->model()->save_button_text());
425 save_button_->SetFontList(
426 ui::ResourceBundle::GetSharedInstance().GetFontList(
427 ui::ResourceBundle::SmallFont));
428 }
411 429
412 // Title row. 430 // Title row.
413 views::StyledLabel* title_label = 431 views::StyledLabel* title_label =
414 new views::StyledLabel(parent_->model()->title(), this); 432 new views::StyledLabel(parent_->model()->title(), this);
415 title_label->SetBaseFontList( 433 title_label->SetBaseFontList(
416 ui::ResourceBundle::GetSharedInstance().GetFontList( 434 ui::ResourceBundle::GetSharedInstance().GetFontList(
417 ui::ResourceBundle::MediumFont)); 435 ui::ResourceBundle::MediumFont));
418 if (!parent_->model()->title_brand_link_range().is_empty()) { 436 if (!parent_->model()->title_brand_link_range().is_empty()) {
419 title_label->AddStyleRange( 437 title_label->AddStyleRange(
420 parent_->model()->title_brand_link_range(), 438 parent_->model()->title_brand_link_range(),
421 views::StyledLabel::RangeStyleInfo::CreateForLink()); 439 views::StyledLabel::RangeStyleInfo::CreateForLink());
422 } 440 }
423 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); 441 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
424 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 442 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
425 layout->AddView(title_label); 443 layout->AddView(title_label);
426 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 444 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
427 445
428 // Credential row. 446 // Credential row.
429 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 447 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
430 layout->AddView(item); 448 layout->AddView(item);
431 449
432 // Button row. 450 // Button row.
433 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); 451 ColumnSetType button_column_type =
434 layout->StartRowWithPadding( 452 parent->model()->account_for_update_selection()
435 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); 453 ? SINGLE_BUTTON_COLUMN_SET
436 layout->AddView(save_button_); 454 : DOUBLE_BUTTON_COLUMN_SET;
437 layout->AddView(refuse_combobox_.get()); 455 BuildColumnSet(layout, button_column_type);
456 layout->StartRowWithPadding(0, button_column_type, 0,
457 views::kRelatedControlVerticalSpacing);
458 if (parent->model()->account_for_update_selection()) {
459 layout->AddView(nope_button_);
460 } else {
461 layout->AddView(save_button_);
462 if (parent->model()->is_password_change_form_without_username())
463 layout->AddView(nope_button_);
464 else
465 layout->AddView(refuse_combobox_.get());
466 }
438 467
439 // Extra padding for visual awesomeness. 468 // Extra padding for visual awesomeness.
440 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 469 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
441 470
442 parent_->set_initially_focused_view(save_button_); 471 parent_->set_initially_focused_view(save_button_);
443 } 472 }
444 473
445 ManagePasswordsBubbleView::PendingView::~PendingView() { 474 ManagePasswordsBubbleView::PendingView::~PendingView() {
446 } 475 }
447 476
448 void ManagePasswordsBubbleView::PendingView::ButtonPressed( 477 void ManagePasswordsBubbleView::PendingView::ButtonPressed(
449 views::Button* sender, 478 views::Button* sender,
450 const ui::Event& event) { 479 const ui::Event& event) {
451 DCHECK(sender == save_button_); 480 DCHECK(sender == save_button_ || sender == nope_button_);
452 parent_->model()->OnSaveClicked(); 481 if (sender == save_button_)
482 parent_->model()->OnSaveClicked();
453 parent_->Close(); 483 parent_->Close();
454 } 484 }
455 485
456 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked( 486 void ManagePasswordsBubbleView::PendingView::StyledLabelLinkClicked(
457 const gfx::Range& range, 487 const gfx::Range& range,
458 int event_flags) { 488 int event_flags) {
459 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); 489 DCHECK_EQ(range, parent_->model()->title_brand_link_range());
460 parent_->model()->OnBrandLinkClicked(); 490 parent_->model()->OnBrandLinkClicked();
461 } 491 }
462 492
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { 1241 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
1212 if (model()->local_credentials().empty()) { 1242 if (model()->local_credentials().empty()) {
1213 // Skip confirmation if there are no existing passwords for this site. 1243 // Skip confirmation if there are no existing passwords for this site.
1214 NotifyConfirmedNeverForThisSite(); 1244 NotifyConfirmedNeverForThisSite();
1215 } else { 1245 } else {
1216 model()->OnConfirmationForNeverForThisSite(); 1246 model()->OnConfirmationForNeverForThisSite();
1217 Refresh(); 1247 Refresh();
1218 SizeToContents(); 1248 SizeToContents();
1219 } 1249 }
1220 } 1250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698