| Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
|
| diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
|
| index 6bfece7f18862c5704c1ee453701bb69516d6d1c..bec3ef73b4139156e9f479cf937ddc5dc668ce63 100644
|
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
|
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
|
| @@ -17,6 +17,7 @@
|
| #include "chrome/browser/ui/views/passwords/manage_credential_item_view.h"
|
| #include "chrome/browser/ui/views/passwords/manage_password_items_view.h"
|
| #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
|
| +#include "chrome/browser/ui/views/passwords/save_account_more_combobox_model.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -48,22 +49,26 @@ enum ColumnSetType {
|
| // | | (FILL, FILL) | |
|
| // Used for the bubble's header, the credentials list, and for simple
|
| // messages like "No passwords".
|
| - SINGLE_VIEW_COLUMN_SET = 0,
|
| + SINGLE_VIEW_COLUMN_SET,
|
|
|
| // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | |
|
| // Used for buttons at the bottom of the bubble which should nest at the
|
| // bottom-right corner.
|
| - DOUBLE_BUTTON_COLUMN_SET = 1,
|
| + DOUBLE_BUTTON_COLUMN_SET,
|
|
|
| // | | (LEADING, CENTER) | | (TRAILING, CENTER) | |
|
| // Used for buttons at the bottom of the bubble which should occupy
|
| // the corners.
|
| - LINK_BUTTON_COLUMN_SET = 2,
|
| + LINK_BUTTON_COLUMN_SET,
|
|
|
| // | | (TRAILING, CENTER) | |
|
| // Used when there is only one button which should next at the bottom-right
|
| // corner.
|
| - SINGLE_BUTTON_COLUMN_SET = 3,
|
| + SINGLE_BUTTON_COLUMN_SET,
|
| +
|
| + // | | (LEADING, CENTER) | | (TRAILING, CENTER) | | (TRAILING, CENTER) | |
|
| + // Used when there are three buttons.
|
| + TRIPLE_BUTTON_COLUMN_SET,
|
| };
|
|
|
| enum TextRowType { ROW_SINGLE, ROW_MULTILINE };
|
| @@ -121,6 +126,28 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) {
|
| views::GridLayout::USE_PREF,
|
| 0,
|
| 0);
|
| + case TRIPLE_BUTTON_COLUMN_SET:
|
| + column_set->AddColumn(views::GridLayout::LEADING,
|
| + views::GridLayout::CENTER,
|
| + 1,
|
| + views::GridLayout::USE_PREF,
|
| + 0,
|
| + 0);
|
| + column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
|
| + column_set->AddColumn(views::GridLayout::TRAILING,
|
| + views::GridLayout::CENTER,
|
| + 0,
|
| + views::GridLayout::USE_PREF,
|
| + 0,
|
| + 0);
|
| + column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
|
| + column_set->AddColumn(views::GridLayout::TRAILING,
|
| + views::GridLayout::CENTER,
|
| + 0,
|
| + views::GridLayout::USE_PREF,
|
| + 0,
|
| + 0);
|
| + break;
|
| }
|
| column_set->AddPaddingColumn(0, views::kPanelHorizMargin);
|
| }
|
| @@ -387,7 +414,108 @@ void ManagePasswordsBubbleView::PendingView::OnPerformAction(
|
| }
|
| }
|
|
|
| -// ManagePasswordsBubbleView::ConfirmNeverView ---------------------------------
|
| +// ManagePasswordsBubbleView::SaveAccountView ---------------------------------
|
| +
|
| +// A view offering the user the ability to save credentials. Contains 2 buttons
|
| +// and a "More" combobox.
|
| +class ManagePasswordsBubbleView::SaveAccountView
|
| + : public views::View,
|
| + public views::ButtonListener,
|
| + public views::ComboboxListener {
|
| + public:
|
| + explicit SaveAccountView(ManagePasswordsBubbleView* parent);
|
| +
|
| + private:
|
| + // views::ButtonListener:
|
| + void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
| +
|
| + // Handles the event when the user changes an index of a combobox.
|
| + void OnPerformAction(views::Combobox* source) override;
|
| +
|
| + ManagePasswordsBubbleView* parent_;
|
| +
|
| + views::BlueButton* save_button_;
|
| + views::LabelButton* no_button_;
|
| +
|
| + // The combobox doesn't take ownership of its model. If we created a
|
| + // combobox we need to ensure that we delete the model here, and because the
|
| + // combobox uses the model in it's destructor, we need to make sure we
|
| + // delete the model _after_ the combobox itself is deleted.
|
| + SaveAccountMoreComboboxModel combobox_model_;
|
| + scoped_ptr<views::Combobox> more_combobox_;
|
| +};
|
| +
|
| +ManagePasswordsBubbleView::SaveAccountView::SaveAccountView(
|
| + ManagePasswordsBubbleView* parent)
|
| + : parent_(parent) {
|
| + DCHECK(parent_->model()->IsNewUIActive());
|
| + views::GridLayout* layout = new views::GridLayout(this);
|
| + layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
|
| + SetLayoutManager(layout);
|
| +
|
| + save_button_ = new views::BlueButton(
|
| + this,
|
| + l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_ACCOUNT_BUTTON));
|
| + save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
|
| + ui::ResourceBundle::SmallFont));
|
| +
|
| + no_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16(
|
| + IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SMART_LOCK_NO_THANKS_BUTTON));
|
| + no_button_->SetStyle(views::Button::STYLE_BUTTON);
|
| + no_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
|
| + ui::ResourceBundle::SmallFont));
|
| +
|
| + more_combobox_.reset(new views::Combobox(&combobox_model_));
|
| + more_combobox_->set_owned_by_client();
|
| + more_combobox_->set_listener(this);
|
| + more_combobox_->SetStyle(views::Combobox::STYLE_ACTION);
|
| +
|
| + // Title row.
|
| + BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
|
| + AddTitleRow(layout, parent_->model());
|
| +
|
| + // Button row.
|
| + BuildColumnSet(layout, TRIPLE_BUTTON_COLUMN_SET);
|
| + layout->StartRow(0, TRIPLE_BUTTON_COLUMN_SET);
|
| + layout->AddView(more_combobox_.get());
|
| + layout->AddView(save_button_);
|
| + layout->AddView(no_button_);
|
| + // Extra padding for visual awesomeness.
|
| + layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| +
|
| + parent_->set_initially_focused_view(save_button_);
|
| +}
|
| +
|
| +void ManagePasswordsBubbleView::SaveAccountView::ButtonPressed(
|
| + views::Button* sender,
|
| + const ui::Event& event) {
|
| + if (sender == save_button_)
|
| + parent_->model()->OnSaveClicked();
|
| + else if (sender == no_button_)
|
| + parent_->model()->OnNopeClicked();
|
| + else
|
| + NOTREACHED();
|
| +
|
| + parent_->Close();
|
| +}
|
| +
|
| +void ManagePasswordsBubbleView::SaveAccountView::OnPerformAction(
|
| + views::Combobox* source) {
|
| + DCHECK_EQ(source, more_combobox_);
|
| + switch (more_combobox_->selected_index()) {
|
| + case SaveAccountMoreComboboxModel::INDEX_MORE:
|
| + break;
|
| + case SaveAccountMoreComboboxModel::INDEX_NEVER_FOR_THIS_SITE:
|
| + parent_->NotifyNeverForThisSiteClicked();
|
| + break;
|
| + case SaveAccountMoreComboboxModel::INDEX_SETTINGS:
|
| + parent_->model()->OnManageLinkClicked();
|
| + parent_->Close();
|
| + break;
|
| + }
|
| +}
|
| +
|
| +// ManagePasswordsBubbleView::ConfirmNeverView --------------------------------
|
|
|
| // A view offering the user the ability to undo her decision to never save
|
| // passwords for a particular site.
|
| @@ -982,10 +1110,14 @@ void ManagePasswordsBubbleView::Refresh() {
|
| RemoveAllChildViews(true);
|
| initially_focused_view_ = NULL;
|
| if (model()->state() == password_manager::ui::PENDING_PASSWORD_STATE) {
|
| - if (model()->never_save_passwords())
|
| + if (model()->never_save_passwords()) {
|
| AddChildView(new ConfirmNeverView(this));
|
| - else
|
| - AddChildView(new PendingView(this));
|
| + } else {
|
| + if (model()->IsNewUIActive())
|
| + AddChildView(new SaveAccountView(this));
|
| + else
|
| + AddChildView(new PendingView(this));
|
| + }
|
| } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) {
|
| AddChildView(new BlacklistedView(this));
|
| } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) {
|
| @@ -1012,6 +1144,7 @@ void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() {
|
| void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() {
|
| model()->OnUndoNeverForThisSite();
|
| Refresh();
|
| + SizeToContents();
|
| }
|
|
|
| void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
|
| @@ -1021,5 +1154,6 @@ void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
|
| } else {
|
| model()->OnConfirmationForNeverForThisSite();
|
| Refresh();
|
| + SizeToContents();
|
| }
|
| }
|
|
|