| OLD | NEW |
| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ManagePasswordsBubbleView::PendingView::PendingView( | 294 ManagePasswordsBubbleView::PendingView::PendingView( |
| 295 ManagePasswordsBubbleView* parent) | 295 ManagePasswordsBubbleView* parent) |
| 296 : parent_(parent) { | 296 : parent_(parent) { |
| 297 views::GridLayout* layout = new views::GridLayout(this); | 297 views::GridLayout* layout = new views::GridLayout(this); |
| 298 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 298 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 299 SetLayoutManager(layout); | 299 SetLayoutManager(layout); |
| 300 | 300 |
| 301 // Create the pending credential item, save button and refusal combobox. | 301 // Create the pending credential item, save button and refusal combobox. |
| 302 ManagePasswordItemsView* item = nullptr; | 302 ManagePasswordItemsView* item = nullptr; |
| 303 if (!parent->model()->pending_password().username_value.empty()) { | 303 if (!parent->model()->pending_password().username_value.empty()) { |
| 304 std::vector<const autofill::PasswordForm*> credentials( | 304 item = new ManagePasswordItemsView(parent_->model(), |
| 305 1, &parent->model()->pending_password()); | 305 &parent->model()->pending_password()); |
| 306 item = new ManagePasswordItemsView(parent_->model(), credentials); | |
| 307 } | 306 } |
| 308 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 307 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
| 309 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 308 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
| 310 never_button_ = views::MdTextButton::CreateSecondaryUiButton( | 309 never_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 311 this, | 310 this, |
| 312 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); | 311 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); |
| 313 | 312 |
| 314 // Title row. | 313 // Title row. |
| 315 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 314 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 316 AddTitleRowWithLink(layout, parent_->model(), this); | 315 AddTitleRowWithLink(layout, parent_->model(), this); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ManagePasswordsBubbleView::ManageView::ManageView( | 404 ManagePasswordsBubbleView::ManageView::ManageView( |
| 406 ManagePasswordsBubbleView* parent) | 405 ManagePasswordsBubbleView* parent) |
| 407 : parent_(parent) { | 406 : parent_(parent) { |
| 408 views::GridLayout* layout = new views::GridLayout(this); | 407 views::GridLayout* layout = new views::GridLayout(this); |
| 409 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 408 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 410 SetLayoutManager(layout); | 409 SetLayoutManager(layout); |
| 411 | 410 |
| 412 // If we have a list of passwords to store for the current site, display | 411 // If we have a list of passwords to store for the current site, display |
| 413 // them to the user for management. Otherwise, render a "No passwords for | 412 // them to the user for management. Otherwise, render a "No passwords for |
| 414 // this site" message. | 413 // this site" message. |
| 415 | |
| 416 bool only_PSL_matches = | |
| 417 find_if(parent_->model()->local_credentials().begin(), | |
| 418 parent_->model()->local_credentials().end(), | |
| 419 [](const autofill::PasswordForm* form) { | |
| 420 return !form->is_public_suffix_match; | |
| 421 }) == parent_->model()->local_credentials().end(); | |
| 422 | |
| 423 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 414 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 424 if (!only_PSL_matches) { | 415 if (!parent_->model()->local_credentials().empty()) { |
| 425 ManagePasswordItemsView* item = new ManagePasswordItemsView( | 416 ManagePasswordItemsView* item = new ManagePasswordItemsView( |
| 426 parent_->model(), parent_->model()->local_credentials().get()); | 417 parent_->model(), &parent_->model()->local_credentials()); |
| 427 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, | 418 layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, |
| 428 views::kUnrelatedControlVerticalSpacing); | 419 views::kUnrelatedControlVerticalSpacing); |
| 429 layout->AddView(item); | 420 layout->AddView(item); |
| 430 } else { | 421 } else { |
| 431 views::Label* empty_label = new views::Label( | 422 views::Label* empty_label = new views::Label( |
| 432 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); | 423 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); |
| 433 empty_label->SetMultiLine(true); | 424 empty_label->SetMultiLine(true); |
| 434 empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 425 empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 435 empty_label->SetFontList( | 426 empty_label->SetFontList( |
| 436 ui::ResourceBundle::GetSharedInstance().GetFontList( | 427 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( | 639 ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( |
| 649 ManagePasswordsBubbleView* parent) | 640 ManagePasswordsBubbleView* parent) |
| 650 : parent_(parent), selection_view_(nullptr) { | 641 : parent_(parent), selection_view_(nullptr) { |
| 651 views::GridLayout* layout = new views::GridLayout(this); | 642 views::GridLayout* layout = new views::GridLayout(this); |
| 652 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 643 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 653 SetLayoutManager(layout); | 644 SetLayoutManager(layout); |
| 654 | 645 |
| 655 // Create the pending credential item, update button. | 646 // Create the pending credential item, update button. |
| 656 View* item = nullptr; | 647 View* item = nullptr; |
| 657 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { | 648 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { |
| 658 selection_view_ = new CredentialsSelectionView( | 649 selection_view_ = new CredentialsSelectionView(parent->model()); |
| 659 parent->model(), parent->model()->local_credentials().get(), | |
| 660 parent->model()->pending_password().username_value); | |
| 661 item = selection_view_; | 650 item = selection_view_; |
| 662 } else { | 651 } else { |
| 663 std::vector<const autofill::PasswordForm*> forms; | 652 item = new ManagePasswordItemsView(parent_->model(), |
| 664 forms.push_back(&parent->model()->pending_password()); | 653 &parent->model()->pending_password()); |
| 665 item = new ManagePasswordItemsView(parent_->model(), forms); | |
| 666 } | 654 } |
| 667 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( | 655 nope_button_ = views::MdTextButton::CreateSecondaryUiButton( |
| 668 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); | 656 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
| 669 | 657 |
| 670 update_button_ = new views::BlueButton( | 658 update_button_ = new views::BlueButton( |
| 671 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); | 659 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); |
| 672 | 660 |
| 673 // Title row. | 661 // Title row. |
| 674 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 662 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 675 AddTitleRowWithLink(layout, parent_->model(), this); | 663 AddTitleRowWithLink(layout, parent_->model(), this); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 AddChildView(new SaveConfirmationView(this)); | 832 AddChildView(new SaveConfirmationView(this)); |
| 845 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 833 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 846 AddChildView(new AutoSigninView(this)); | 834 AddChildView(new AutoSigninView(this)); |
| 847 } else if (model_.state() == | 835 } else if (model_.state() == |
| 848 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { | 836 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { |
| 849 AddChildView(new SignInPromoView(this)); | 837 AddChildView(new SignInPromoView(this)); |
| 850 } else { | 838 } else { |
| 851 AddChildView(new ManageView(this)); | 839 AddChildView(new ManageView(this)); |
| 852 } | 840 } |
| 853 } | 841 } |
| OLD | NEW |