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 cdf8ba66f1219bc1a3f14764017595d5c9d3a438..8d0de3e29e152a3ce9622d0645980756a242f050 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" |
| @@ -36,7 +37,6 @@ |
| #include "ui/views/layout/layout_constants.h" |
| #include "ui/views/widget/widget.h" |
| - |
|
vabr (Chromium)
2014/12/03 14:08:06
nit: As a general rule, formatting changes not rel
melandory
2014/12/04 10:33:47
Done.
|
| // Helpers -------------------------------------------------------------------- |
| namespace { |
| @@ -122,6 +122,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 +148,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 +267,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::BlueButton* send_button_; |
| + views::BlueButton* no_button_; |
| +}; |
| + |
| +ManagePasswordsBubbleView::AskUserToSubmitURLView::AskUserToSubmitURLView( |
| + ManagePasswordsBubbleView* parent) |
| + : parent_(parent) { |
| + views::GridLayout* layout = new views::GridLayout(this); |
| + layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| + SetLayoutManager(layout); |
| + |
| + send_button_ = new views::BlueButton( |
| + this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); |
| + send_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| + ui::ResourceBundle::SmallFont)); |
| + |
| + no_button_ = new views::BlueButton( |
| + this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SEND_URL_BUTTON)); |
| + no_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| + ui::ResourceBundle::SmallFont)); |
| + |
| + // 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)); |
| + GURL origin = parent->model()->origin(); |
| + // Better to omit url if it's incorrect or empty. |
|
vabr (Chromium)
2014/12/03 14:08:07
But what is the purpose of asking the user, if the
melandory
2014/12/04 10:33:47
Moved this check to PasswordManager::RecordFailur
|
| + if (origin.is_valid() && !origin.is_empty() && origin.has_host()) { |
| + // Border row. |
| + SkColor color = GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); |
| + AddBorderRow(layout, color); |
| + layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| + // URL row. |
| + 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(send_button_); |
|
vabr (Chromium)
2014/12/03 14:08:06
Please make sure that the choice of the default wa
melandory
2014/12/04 10:33:47
sabineb@ said that nope as default is better.
Done
|
| +} |
| + |
| +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. |
| + parent_->Close(); |
| +} |
| + |
| // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| // A view offering the user the ability to save credentials. Contains a |
| @@ -771,10 +881,8 @@ void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
| DCHECK(browser); |
| DCHECK(browser->window()); |
| DCHECK(browser->fullscreen_controller()); |
| - |
| if (IsShowing()) |
| return; |
| - |
| BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| bool is_fullscreen = browser_view->IsFullscreen(); |
| ManagePasswordsIconView* anchor_view = |
| @@ -883,6 +991,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 +1028,6 @@ void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
| void ManagePasswordsBubbleView::Init() { |
| views::FillLayout* layout = new views::FillLayout(); |
| SetLayoutManager(layout); |
| - |
| Refresh(); |
| } |