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

Unified Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 952023002: Credential Manager API: pop up the new "Manage accounts" bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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..dd6ac315f1fdf9fd087f89b266d9f76eca257772 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -300,8 +300,6 @@ ManagePasswordsBubbleView::AutoSigninView::AutoSigninView(
CredentialsItemView::AUTO_SIGNIN,
parent_->model()->GetProfile()->GetRequestContext());
AddChildView(credential);
- // TODO(vasilii): enable the button to switch to the "Managed" state.
- credential->SetEnabled(false);
parent_->set_initially_focused_view(credential);
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kAutoSigninToastTimeout),
@@ -310,7 +308,8 @@ ManagePasswordsBubbleView::AutoSigninView::AutoSigninView(
void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed(
views::Button* sender, const ui::Event& event) {
- // TODO(vasilii): close the toast and switch to the "Managed" state.
+ parent_->model()->OnAutoSignInClicked();
+ parent_->Close();
}
void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
@@ -632,14 +631,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 +701,19 @@ 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:
- explicit ManageAccountsView(ManagePasswordsBubbleView* parent);
+ explicit ManageAccountsView(ManagePasswordsBubbleView* parent);
private:
- ManagePasswordsBubbleView* parent_;
+ // views::ButtonListener:
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+
+ ManagePasswordsBubbleView* parent_;
+
+ views::LabelButton* done_button_;
};
ManagePasswordsBubbleView::ManageAccountsView::ManageAccountsView(
@@ -721,15 +727,46 @@ 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),
+ 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);
}
+ 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, SINGLE_BUTTON_COLUMN_SET);
+ layout->StartRowWithPadding(
+ 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing);
+ 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();
}
// ManagePasswordsBubbleView::BlacklistedView ---------------------------------
@@ -1017,8 +1054,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 +1069,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;
@@ -1063,6 +1098,8 @@ void ManagePasswordsBubbleView::Refresh() {
AddChildView(new AccountChooserView(this));
} else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) {
AddChildView(new AutoSigninView(this));
+ } else if (model()->state() == password_manager::ui::MANAGE_ACCOUNTS_STATE) {
+ AddChildView(new ManageAccountsView(this));
} else {
AddChildView(new ManageView(this));
}

Powered by Google App Engine
This is Rietveld 408576698