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

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

Issue 399573002: [Password Generation] Trigger confirmation bubble when a password is saved (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win Again Created 6 years, 5 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 f8f08d6fbd6dae7c821836692877af401d427336..d74dc3800d11f0a6ff24b00be3ce0ea014aeea35 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -24,6 +24,7 @@
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/combobox/combobox.h"
+#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
@@ -50,6 +51,11 @@ enum ColumnSetType {
// Used for buttons at the bottom of the bubble which should occupy
// the corners.
LINK_BUTTON_COLUMN_SET = 2,
+
+ // | | (TRAILING, CENTER) | |
+ // Used when there is only one button which should next at the bottom-right
+ // corner.
+ SINGLE_BUTTON_COLUMN_SET = 3,
};
// Construct an appropriate ColumnSet for the given |type|, and add it
@@ -98,6 +104,13 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) {
0,
0);
break;
+ case SINGLE_BUTTON_COLUMN_SET:
+ column_set->AddColumn(views::GridLayout::TRAILING,
+ views::GridLayout::CENTER,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
}
column_set->AddPaddingColumn(0, views::kPanelHorizMargin);
}
@@ -130,8 +143,7 @@ void ShowManagePasswordsBubble(content::WebContents* web_contents) {
ManagePasswordsUIController::FromWebContents(web_contents);
ManagePasswordsBubbleView::ShowBubble(
web_contents,
- controller->state() ==
- password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE
+ password_manager::ui::IsAutomaticDisplayState(controller->state())
? ManagePasswordsBubbleView::AUTOMATIC
: ManagePasswordsBubbleView::USER_ACTION);
}
@@ -297,7 +309,7 @@ ManagePasswordsBubbleView::ManageView::ManageView(
// them to the user for management. Otherwise, render a "No passwords for
// this site" message.
if (!parent_->model()->best_matches().empty()) {
- for (autofill::PasswordFormMap::const_iterator i(
+ for (autofill::ConstPasswordFormMap::const_iterator i(
parent_->model()->best_matches().begin());
i != parent_->model()->best_matches().end();
++i) {
@@ -427,6 +439,62 @@ void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed(
parent_->Close();
}
+// ManagePasswordsBubbleView::SaveConfirmationView ----------------------------
+
+ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView(
+ ManagePasswordsBubbleView* parent)
+ : parent_(parent) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
+ SetLayoutManager(layout);
+
+ BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
+ AddTitleRow(layout, parent_->model());
+
+ views::StyledLabel* confirmation =
+ new views::StyledLabel(parent_->model()->save_confirmation_text(), this);
+ confirmation->SetBaseFontList(
+ ui::ResourceBundle::GetSharedInstance().GetFontList(
+ ui::ResourceBundle::SmallFont));
+ confirmation->AddStyleRange(
+ parent_->model()->save_confirmation_link_range(),
+ views::StyledLabel::RangeStyleInfo::CreateForLink());
+
+ layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
+ layout->AddView(confirmation);
+
+ ok_button_ =
+ new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_OK));
+ ok_button_->SetStyle(views::Button::STYLE_BUTTON);
+ ok_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(ok_button_);
+
+ // Extra padding for visual awesomeness.
+ layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
+}
+
+ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() {
+}
+
+void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked(
+ const gfx::Range& range, int event_flags) {
+ DCHECK_EQ(range, parent_->model()->save_confirmation_link_range());
+ parent_->model()->OnRemoteManageLinkClicked();
+ parent_->Close();
+}
+
+void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
+ views::Button* sender, const ui::Event& event) {
+ DCHECK_EQ(sender, ok_button_);
+ parent_->model()->OnOKClicked();
+ parent_->Close();
+}
+
// ManagePasswordsBubbleView --------------------------------------------------
// static
@@ -546,6 +614,8 @@ void ManagePasswordsBubbleView::Refresh() {
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) {
+ AddChildView(new SaveConfirmationView(this));
} else {
AddChildView(new ManageView(this));
}

Powered by Google App Engine
This is Rietveld 408576698