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 3def416d48442c3957d405a10ff44a1c96e9091b..b4fefbf55ba31ef08ce2d09970639fc93c828fe2 100644 |
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
@@ -632,14 +632,14 @@ ManagePasswordsBubbleView::ManageView::ManageView( |
// them to the user for management. Otherwise, render a "No passwords for |
// this site" message. |
if (!parent_->model()->best_matches().empty()) { |
- std::vector<const autofill::PasswordForm*> password_forms; |
- for (auto password_form : parent_->model()->best_matches()) { |
- password_forms.push_back(password_form.second); |
- } |
- ManagePasswordItemsView* item = new ManagePasswordItemsView( |
- parent_->model(), password_forms); |
- layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
- layout->AddView(item); |
+ std::vector<const autofill::PasswordForm*> password_forms; |
+ for (auto password_form : parent_->model()->best_matches()) { |
+ password_forms.push_back(password_form.second); |
+ } |
+ ManagePasswordItemsView* item = new ManagePasswordItemsView( |
+ parent_->model(), password_forms); |
+ layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
+ layout->AddView(item); |
} else { |
views::Label* empty_label = new views::Label( |
l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS)); |
@@ -702,12 +702,24 @@ void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, |
// A view offering the user a list of his currently saved through the Credential |
// Manager API accounts for the current page. |
-class ManagePasswordsBubbleView::ManageAccountsView : public views::View { |
+class ManagePasswordsBubbleView::ManageAccountsView |
+ : public views::View, |
+ public views::ButtonListener, |
+ public views::LinkListener { |
public: |
- explicit ManageAccountsView(ManagePasswordsBubbleView* parent); |
+ explicit ManageAccountsView(ManagePasswordsBubbleView* parent); |
private: |
- ManagePasswordsBubbleView* parent_; |
+ // views::ButtonListener: |
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
+ |
+ // views::LinkListener: |
+ void LinkClicked(views::Link* source, int event_flags) override; |
+ |
+ ManagePasswordsBubbleView* parent_; |
+ |
+ views::Link* manage_link_; |
+ views::LabelButton* done_button_; |
}; |
ManagePasswordsBubbleView::ManageAccountsView::ManageAccountsView( |
@@ -721,15 +733,63 @@ ManagePasswordsBubbleView::ManageAccountsView::ManageAccountsView( |
BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
AddTitleRow(layout, parent_->model()); |
- for (const autofill::PasswordForm* form : |
- parent_->model()->local_pending_credentials()) { |
- // Add the title to the layout with appropriate padding. |
+ if (!parent_->model()->local_pending_credentials().empty()) { |
+ for (const autofill::PasswordForm* form : |
+ parent_->model()->local_pending_credentials()) { |
+ layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
+ layout->AddView(new ManageCredentialItemView(parent_->model(), form)); |
+ } |
+ } else { |
+ views::Label* empty_label = new views::Label( |
+ l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_NO_PASSWORDS), |
Mike West
2015/02/25 11:40:26
Will you be folding blacklisting in here as well i
vasilii
2015/02/25 11:46:46
No, the "Blacklisted" bubble stays separate.
|
+ ui::ResourceBundle::GetSharedInstance().GetFontList( |
+ ui::ResourceBundle::SmallFont)); |
+ empty_label->SetMultiLine(true); |
+ empty_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ |
layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
- layout->AddView(new ManageCredentialItemView(parent_->model(), form)); |
+ layout->AddView(empty_label); |
+ layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
} |
+ // Then add the "manage passwords" link and "Done" button. |
+ manage_link_ = new views::Link(parent_->model()->manage_link()); |
+ manage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ manage_link_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
+ ui::ResourceBundle::SmallFont)); |
+ manage_link_->SetUnderline(false); |
+ manage_link_->set_listener(this); |
+ |
+ done_button_ = |
+ new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); |
+ done_button_->SetStyle(views::Button::STYLE_BUTTON); |
+ done_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
+ ui::ResourceBundle::SmallFont)); |
+ |
+ BuildColumnSet(layout, LINK_BUTTON_COLUMN_SET); |
+ layout->StartRowWithPadding( |
+ 0, LINK_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
+ layout->AddView(manage_link_); |
+ layout->AddView(done_button_); |
+ |
// Extra padding for visual awesomeness. |
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
+ |
+ parent_->set_initially_focused_view(done_button_); |
+} |
+ |
+void ManagePasswordsBubbleView::ManageAccountsView::ButtonPressed( |
+ views::Button* sender, const ui::Event& event) { |
+ DCHECK(sender == done_button_); |
+ parent_->model()->OnDoneClicked(); |
+ parent_->Close(); |
+} |
+ |
+void ManagePasswordsBubbleView::ManageAccountsView::LinkClicked( |
+ views::Link* source, int event_flags) { |
+ DCHECK_EQ(source, manage_link_); |
+ parent_->model()->OnManageLinkClicked(); |
+ parent_->Close(); |
} |
// ManagePasswordsBubbleView::BlacklistedView --------------------------------- |
@@ -768,6 +828,7 @@ ManagePasswordsBubbleView::BlacklistedView::BlacklistedView( |
views::Label* blacklisted = new views::Label( |
l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED)); |
blacklisted->SetMultiLine(true); |
+ blacklisted->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
blacklisted->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
ui::ResourceBundle::SmallFont)); |
layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
@@ -1017,8 +1078,8 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
} |
ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { |
- if (anchor_view_) |
- anchor_view_->SetActive(false); |
+ if (manage_passwords_bubble_ == this) |
+ manage_passwords_bubble_ = NULL; |
} |
views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
@@ -1032,18 +1093,16 @@ void ManagePasswordsBubbleView::Init() { |
Refresh(); |
} |
-void ManagePasswordsBubbleView::WindowClosing() { |
- // Close() closes the window asynchronously, so by the time we reach here, |
- // |manage_passwords_bubble_| may have already been reset. |
- if (manage_passwords_bubble_ == this) |
- manage_passwords_bubble_ = NULL; |
-} |
- |
void ManagePasswordsBubbleView::Close() { |
mouse_handler_.reset(); |
ManagedFullScreenBubbleDelegateView::Close(); |
} |
+void ManagePasswordsBubbleView::OnWidgetClosing(views::Widget* /*widget*/) { |
+ if (anchor_view_) |
+ anchor_view_->SetActive(false); |
+} |
+ |
void ManagePasswordsBubbleView::Refresh() { |
RemoveAllChildViews(true); |
initially_focused_view_ = NULL; |