Chromium Code Reviews| 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 d30aa93217b16e33ebc2b12a85c37084755f0347..7224df843e09fc9dce72c2bc7c68ad26ac0c29da 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| @@ -376,6 +376,8 @@ class ManagePasswordsBubbleView::PendingView |
| views::BlueButton* save_button_; |
| + 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
|
| + |
| // 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 |
| @@ -388,26 +390,42 @@ class ManagePasswordsBubbleView::PendingView |
| ManagePasswordsBubbleView::PendingView::PendingView( |
| ManagePasswordsBubbleView* parent) |
| - : parent_(parent) { |
| + : parent_(parent), save_button_(nullptr), nope_button_(nullptr) { |
| views::GridLayout* layout = new views::GridLayout(this); |
| layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| SetLayoutManager(layout); |
| - std::vector<const autofill::PasswordForm*> credentials( |
| - 1, &parent->model()->pending_password()); |
| + std::vector<const autofill::PasswordForm*> credentials; |
| + if (parent->model()->account_for_update_selection()) { |
| + for (auto local_credential : parent->model()->local_credentials()) |
| + credentials.push_back(local_credential); |
| + } else { |
| + credentials.push_back(&parent->model()->pending_password()); |
| + } |
| // Create the pending credential item, save button and refusal combobox. |
| ManagePasswordItemsView* item = |
| new ManagePasswordItemsView(parent_->model(), credentials); |
| - save_button_ = new views::BlueButton( |
| - this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
| - save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::SmallFont)); |
| - |
| - combobox_model_.reset(new SavePasswordRefusalComboboxModel); |
| - refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); |
| - refuse_combobox_->set_listener(this); |
| - refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
| - // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. |
| + if (parent->model()->is_password_change_form_without_username()) { |
| + nope_button_ = new views::LabelButton( |
| + this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
| + nope_button_->SetStyle(views::Button::STYLE_BUTTON); |
| + nope_button_->SetFontList( |
| + ui::ResourceBundle::GetSharedInstance().GetFontList( |
| + ui::ResourceBundle::SmallFont)); |
| + } else { |
| + combobox_model_.reset(new SavePasswordRefusalComboboxModel); |
| + refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); |
| + refuse_combobox_->set_listener(this); |
| + refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
| + // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. |
| + } |
| + if (!parent->model()->account_for_update_selection()) { |
| + save_button_ = |
| + new views::BlueButton(this, parent_->model()->save_button_text()); |
| + save_button_->SetFontList( |
| + ui::ResourceBundle::GetSharedInstance().GetFontList( |
| + ui::ResourceBundle::SmallFont)); |
| + } |
| // Title row. |
| views::StyledLabel* title_label = |
| @@ -430,11 +448,22 @@ ManagePasswordsBubbleView::PendingView::PendingView( |
| layout->AddView(item); |
| // Button row. |
| - BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
| - layout->StartRowWithPadding( |
| - 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
| - layout->AddView(save_button_); |
| - layout->AddView(refuse_combobox_.get()); |
| + ColumnSetType button_column_type = |
| + parent->model()->account_for_update_selection() |
| + ? SINGLE_BUTTON_COLUMN_SET |
| + : DOUBLE_BUTTON_COLUMN_SET; |
| + BuildColumnSet(layout, button_column_type); |
| + layout->StartRowWithPadding(0, button_column_type, 0, |
| + views::kRelatedControlVerticalSpacing); |
| + if (parent->model()->account_for_update_selection()) { |
| + layout->AddView(nope_button_); |
| + } else { |
| + layout->AddView(save_button_); |
| + if (parent->model()->is_password_change_form_without_username()) |
| + layout->AddView(nope_button_); |
| + else |
| + layout->AddView(refuse_combobox_.get()); |
| + } |
| // Extra padding for visual awesomeness. |
| layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| @@ -448,8 +477,9 @@ ManagePasswordsBubbleView::PendingView::~PendingView() { |
| void ManagePasswordsBubbleView::PendingView::ButtonPressed( |
| views::Button* sender, |
| const ui::Event& event) { |
| - DCHECK(sender == save_button_); |
| - parent_->model()->OnSaveClicked(); |
| + DCHECK(sender == save_button_ || sender == nope_button_); |
| + if (sender == save_button_) |
| + parent_->model()->OnSaveClicked(); |
| parent_->Close(); |
| } |