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 cdf8ba66f1219bc1a3f14764017595d5c9d3a438..915b88cad5bb0bbbc82ffb649ed198c7415333d2 100644 |
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
@@ -29,6 +29,7 @@ |
#include "ui/views/controls/combobox/combobox_listener.h" |
#include "ui/views/controls/link.h" |
#include "ui/views/controls/link_listener.h" |
+#include "ui/views/controls/separator.h" |
#include "ui/views/controls/styled_label.h" |
#include "ui/views/controls/styled_label_listener.h" |
#include "ui/views/layout/fill_layout.h" |
@@ -122,6 +123,16 @@ void BuildColumnSet(views::GridLayout* layout, ColumnSetType type) { |
column_set->AddPaddingColumn(0, views::kPanelHorizMargin); |
} |
+// Given |layout| and |color| adds border with |color| using |
+// SINGLE_VIEW_COLUMN_SET. |
+void AddBorderRow(views::GridLayout* layout, SkColor color) { |
+ layout->StartRowWithPadding(0, SINGLE_VIEW_COLUMN_SET, 0, |
+ views::kRelatedControlVerticalSpacing); |
+ views::Separator* border = new views::Separator(views::Separator::HORIZONTAL); |
+ border->SetColor(color); |
+ layout->AddView(border); |
+} |
+ |
// Given a layout and a model, add an appropriate title using a |
// SINGLE_VIEW_COLUMN_SET, followed by a spacer row. |
void AddTitleRow(views::GridLayout* layout, ManagePasswordsBubbleModel* model) { |
@@ -138,6 +149,18 @@ void AddTitleRow(views::GridLayout* layout, ManagePasswordsBubbleModel* model) { |
layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
} |
+// Given a |layout| and |text|, adds a text row with small font using a |
+// SINGLE_VIEW_COLUMN_SET. |
+void AddTextRow(views::GridLayout* layout, const base::string16& text) { |
+ views::Label* text_label = new views::Label(text); |
+ text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ text_label->SetMultiLine(true); |
+ text_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
+ ui::ResourceBundle::SmallFont)); |
+ layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
+ layout->AddView(text_label); |
+} |
+ |
} // namespace |
@@ -245,6 +268,94 @@ void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
parent_->Close(); |
} |
+// ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- |
+ |
+// Asks users if they want to report the URL when the password manager failed |
+// to detect the form. View has following structure: |
+// We detected that Chrome password manager failed to handle this URL. |
+// Do you want to send this URL to Google to improve Chrome? |
+// ------------------------------------------------------------- |
+// https://strangesite.com/ |
+// ------------------------------------------------------------- |
+// [Send URL] [Nope] |
+class ManagePasswordsBubbleView::AskUserToSubmitURLView |
+ : public views::View, |
+ public views::ButtonListener { |
+ public: |
+ explicit AskUserToSubmitURLView(ManagePasswordsBubbleView* parent); |
+ ~AskUserToSubmitURLView() override; |
+ |
+ private: |
+ // views::ButtonListener: |
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
+ |
+ ManagePasswordsBubbleView* parent_; |
+ |
+ views::LabelButton* send_button_; |
+ views::LabelButton* no_button_; |
+}; |
+ |
+ManagePasswordsBubbleView::AskUserToSubmitURLView::AskUserToSubmitURLView( |
+ ManagePasswordsBubbleView* parent) |
+ : parent_(parent) { |
+ GURL origin = parent->model()->origin(); |
+ DCHECK(origin.is_valid() && !origin.is_empty() && origin.has_host()); |
+ views::GridLayout* layout = new views::GridLayout(this); |
+ layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
+ SetLayoutManager(layout); |
+ |
+ send_button_ = new views::LabelButton( |
+ this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
+ send_button_->SetStyle(views::Button::STYLE_BUTTON); |
+ no_button_ = new views::LabelButton( |
+ this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SEND_URL_BUTTON)); |
+ no_button_->SetStyle(views::Button::STYLE_BUTTON); |
+ |
+ // Title row. |
+ BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
+ AddTitleRow(layout, parent_->model()); |
+ // Confirmation text. |
+ AddTextRow(layout, l10n_util::GetStringUTF16( |
+ IDS_MANAGE_PASSWORDS_ASK_TO_SUBMIT_URL_TEXT)); |
+ // Border row. |
+ SkColor color = GetNativeTheme()->GetSystemColor( |
+ ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); |
+ AddBorderRow(layout, color); |
+ layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
+ // URL row. |
+ // TODO(melandory) Use full URL instead of host. |
+ AddTextRow(layout, base::UTF8ToUTF16(parent->model()->origin().host())); |
+ layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
+ // Border row. |
+ AddBorderRow(layout, color); |
+ // Button row. |
+ BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
+ layout->StartRowWithPadding(0, DOUBLE_BUTTON_COLUMN_SET, 0, |
+ views::kRelatedControlVerticalSpacing); |
+ layout->AddView(no_button_); |
+ layout->AddView(send_button_); |
+ |
+ // Extra padding for visual awesomeness. |
+ layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
+ |
+ parent_->set_initially_focused_view(no_button_); |
+} |
+ |
+ManagePasswordsBubbleView::AskUserToSubmitURLView::~AskUserToSubmitURLView() { |
+} |
+ |
+void ManagePasswordsBubbleView::AskUserToSubmitURLView::ButtonPressed( |
+ views::Button* sender, |
+ const ui::Event& event) { |
+ DCHECK(sender == send_button_ || sender == no_button_); |
+ // TODO(melandory): Add actions on button clicks: url reporting, pref saving. |
+ if (sender == send_button_) |
+ parent_->model()->OnCollectURLClicked(); |
+ else if (sender == no_button_) |
+ parent_->model()->OnDoNotCollectURLClicked(); |
+ parent_->Close(); |
+} |
+ |
// ManagePasswordsBubbleView::PendingView ------------------------------------- |
// A view offering the user the ability to save credentials. Contains a |
@@ -771,10 +882,8 @@ void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
DCHECK(browser); |
DCHECK(browser->window()); |
DCHECK(browser->fullscreen_controller()); |
- |
vabr (Chromium)
2014/12/04 13:25:33
nit: There are still 3 removed blank lines in this
melandory
2014/12/05 12:56:52
Done.
|
if (IsShowing()) |
return; |
- |
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
bool is_fullscreen = browser_view->IsFullscreen(); |
ManagePasswordsIconView* anchor_view = |
@@ -883,6 +992,8 @@ void ManagePasswordsBubbleView::Refresh() { |
AddChildView(new ConfirmNeverView(this)); |
else |
AddChildView(new PendingView(this)); |
+ } else if (IsAskSubmitURLState(model()->state())) { |
+ AddChildView(new AskUserToSubmitURLView(this)); |
} else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
AddChildView(new BlacklistedView(this)); |
} else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { |
@@ -918,7 +1029,6 @@ void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
void ManagePasswordsBubbleView::Init() { |
views::FillLayout* layout = new views::FillLayout(); |
SetLayoutManager(layout); |
- |
Refresh(); |
} |