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 67114c5368d1824165c33d06513fe1e2870f68ef..163efd6c40943e157529d424c7408edede1cecf8 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| @@ -4,31 +4,30 @@ |
| #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| -#include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| -#include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| +#include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
| #include "chrome/browser/ui/views/frame/browser_view.h" |
| #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" |
| #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
| #include "chrome/grit/generated_resources.h" |
| -#include "components/password_manager/core/common/password_manager_ui.h" |
| -#include "content/public/browser/notification_source.h" |
| #include "content/public/browser/web_contents.h" |
| #include "ui/aura/window.h" |
| #include "ui/base/l10n/l10n_util.h" |
| -#include "ui/base/models/combobox_model.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/compositor/layer_animation_observer.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| -#include "ui/gfx/text_utils.h" |
| #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/combobox/combobox_listener.h" |
| +#include "ui/views/controls/link.h" |
| +#include "ui/views/controls/link_listener.h" |
| #include "ui/views/controls/styled_label.h" |
| +#include "ui/views/controls/styled_label_listener.h" |
| #include "ui/views/layout/fill_layout.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/layout/layout_constants.h" |
| @@ -165,6 +164,35 @@ void ShowManagePasswordsBubble(content::WebContents* web_contents) { |
| // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| +// A view offering the user the ability to save credentials. Contains a |
| +// single ManagePasswordItemView, along with a "Save Passwords" button |
| +// and a rejection combobox. |
| +class ManagePasswordsBubbleView::PendingView : public views::View, |
| + public views::ButtonListener, |
| + public views::ComboboxListener { |
| + public: |
| + explicit PendingView(ManagePasswordsBubbleView* parent); |
| + |
| + private: |
| + // views::ButtonListener: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + // Handles the event when the user changes an index of a combobox. |
| + virtual void OnPerformAction(views::Combobox* source) OVERRIDE; |
| + |
| + ManagePasswordsBubbleView* parent_; |
| + |
| + views::BlueButton* save_button_; |
| + |
| + // The combobox doesn't take ownership of its model. If we created a |
| + // combobox we need to ensure that we delete the model here, and because the |
| + // combobox uses the model in it's destructor, we need to make sure we |
| + // delete the model _after_ the combobox itself is deleted. |
| + scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_; |
| + scoped_ptr<views::Combobox> refuse_combobox_; |
| +}; |
| + |
| ManagePasswordsBubbleView::PendingView::PendingView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| @@ -209,9 +237,6 @@ ManagePasswordsBubbleView::PendingView::PendingView( |
| parent_->set_initially_focused_view(save_button_); |
| } |
| -ManagePasswordsBubbleView::PendingView::~PendingView() { |
|
vabr (Chromium)
2014/09/02 13:29:28
Any particular reason for dropping the destructors
vasilii
2014/09/02 15:33:33
Not really. Reverted.
|
| -} |
| - |
| void ManagePasswordsBubbleView::PendingView::ButtonPressed( |
| views::Button* sender, |
| const ui::Event& event) { |
| @@ -236,6 +261,25 @@ void ManagePasswordsBubbleView::PendingView::OnPerformAction( |
| // ManagePasswordsBubbleView::ConfirmNeverView --------------------------------- |
| +// A view offering the user the ability to undo her decision to never save |
| +// passwords for a particular site. |
| +class ManagePasswordsBubbleView::ConfirmNeverView |
| + : public views::View, |
| + public views::ButtonListener { |
| + public: |
| + explicit ConfirmNeverView(ManagePasswordsBubbleView* parent); |
| + |
| + private: |
| + // views::ButtonListener: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + ManagePasswordsBubbleView* parent_; |
| + |
| + views::LabelButton* confirm_button_; |
| + views::LabelButton* undo_button_; |
| +}; |
| + |
| ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| @@ -295,9 +339,6 @@ ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( |
| parent_->set_initially_focused_view(confirm_button_); |
| } |
| -ManagePasswordsBubbleView::ConfirmNeverView::~ConfirmNeverView() { |
| -} |
| - |
| void ManagePasswordsBubbleView::ConfirmNeverView::ButtonPressed( |
| views::Button* sender, |
| const ui::Event& event) { |
| @@ -310,6 +351,29 @@ void ManagePasswordsBubbleView::ConfirmNeverView::ButtonPressed( |
| // ManagePasswordsBubbleView::ManageView -------------------------------------- |
| +// A view offering the user a list of her currently saved credentials |
| +// for the current page, along with a "Manage passwords" link and a |
| +// "Done" button. |
| +class ManagePasswordsBubbleView::ManageView : public views::View, |
| + public views::ButtonListener, |
| + public views::LinkListener { |
| + public: |
| + explicit ManageView(ManagePasswordsBubbleView* parent); |
| + |
| + private: |
| + // views::ButtonListener: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + // views::LinkListener: |
| + virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| + |
| + ManagePasswordsBubbleView* parent_; |
| + |
| + views::Link* manage_link_; |
| + views::LabelButton* done_button_; |
| +}; |
| + |
| ManagePasswordsBubbleView::ManageView::ManageView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| @@ -379,9 +443,6 @@ ManagePasswordsBubbleView::ManageView::ManageView( |
| parent_->set_initially_focused_view(done_button_); |
| } |
| -ManagePasswordsBubbleView::ManageView::~ManageView() { |
| -} |
| - |
| void ManagePasswordsBubbleView::ManageView::ButtonPressed( |
| views::Button* sender, |
| const ui::Event& event) { |
| @@ -399,6 +460,25 @@ void ManagePasswordsBubbleView::ManageView::LinkClicked(views::Link* source, |
| // ManagePasswordsBubbleView::BlacklistedView --------------------------------- |
| +// A view offering the user the ability to re-enable the password manager for |
| +// a specific site after she's decided to "never save passwords". |
| +class ManagePasswordsBubbleView::BlacklistedView |
| + : public views::View, |
| + public views::ButtonListener { |
| + public: |
| + explicit BlacklistedView(ManagePasswordsBubbleView* parent); |
| + |
| + private: |
| + // views::ButtonListener: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + ManagePasswordsBubbleView* parent_; |
| + |
| + views::BlueButton* unblacklist_button_; |
| + views::LabelButton* done_button_; |
| +}; |
| + |
| ManagePasswordsBubbleView::BlacklistedView::BlacklistedView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| @@ -444,9 +524,6 @@ ManagePasswordsBubbleView::BlacklistedView::BlacklistedView( |
| parent_->set_initially_focused_view(unblacklist_button_); |
| } |
| -ManagePasswordsBubbleView::BlacklistedView::~BlacklistedView() { |
| -} |
| - |
| void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed( |
| views::Button* sender, |
| const ui::Event& event) { |
| @@ -461,6 +538,29 @@ void ManagePasswordsBubbleView::BlacklistedView::ButtonPressed( |
| // ManagePasswordsBubbleView::SaveConfirmationView ---------------------------- |
| +// A view confirming to the user that a password was saved and offering a link |
| +// to the Google account manager. |
| +class ManagePasswordsBubbleView::SaveConfirmationView |
| + : public views::View, |
| + public views::ButtonListener, |
| + public views::StyledLabelListener { |
| + public: |
| + explicit SaveConfirmationView(ManagePasswordsBubbleView* parent); |
| + |
| + private: |
| + // views::ButtonListener: |
| + virtual void ButtonPressed(views::Button* sender, |
| + const ui::Event& event) OVERRIDE; |
| + |
| + // views::StyledLabelListener implementation |
| + virtual void StyledLabelLinkClicked(const gfx::Range& range, |
| + int event_flags) OVERRIDE; |
| + |
| + ManagePasswordsBubbleView* parent_; |
| + |
| + views::LabelButton* ok_button_; |
| +}; |
| + |
| ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
| ManagePasswordsBubbleView* parent) |
| : parent_(parent) { |
| @@ -499,9 +599,6 @@ ManagePasswordsBubbleView::SaveConfirmationView::SaveConfirmationView( |
| parent_->set_initially_focused_view(ok_button_); |
| } |
| -ManagePasswordsBubbleView::SaveConfirmationView::~SaveConfirmationView() { |
| -} |
| - |
| void ManagePasswordsBubbleView::SaveConfirmationView::StyledLabelLinkClicked( |
| const gfx::Range& range, int event_flags) { |
| DCHECK_EQ(range, parent_->model()->save_confirmation_link_range()); |
| @@ -678,35 +775,6 @@ void ManagePasswordsBubbleView::Close() { |
| GetWidget()->Close(); |
| } |
| -void ManagePasswordsBubbleView::Init() { |
| - views::FillLayout* layout = new views::FillLayout(); |
| - SetLayoutManager(layout); |
| - |
| - 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::OnWidgetActivationChanged(views::Widget* widget, |
| - bool active) { |
| - if (active && widget == GetWidget()) |
| - CancelFadingOut(); |
| - BubbleDelegateView::OnWidgetActivationChanged(widget, active); |
| -} |
| - |
| -views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
| - return initially_focused_view_; |
| -} |
| - |
| -void ManagePasswordsBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
| - CancelFadingOut(); |
| -} |
| - |
| void ManagePasswordsBubbleView::Refresh() { |
| RemoveAllChildViews(true); |
| initially_focused_view_ = NULL; |
| @@ -746,6 +814,35 @@ void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
| Refresh(); |
| } |
| +void ManagePasswordsBubbleView::Init() { |
| + views::FillLayout* layout = new views::FillLayout(); |
| + SetLayoutManager(layout); |
| + |
| + 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::OnWidgetActivationChanged(views::Widget* widget, |
| + bool active) { |
| + if (active && widget == GetWidget()) |
| + CancelFadingOut(); |
| + BubbleDelegateView::OnWidgetActivationChanged(widget, active); |
| +} |
| + |
| +views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
| + return initially_focused_view_; |
| +} |
| + |
| +void ManagePasswordsBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
| + CancelFadingOut(); |
| +} |
| + |
| void ManagePasswordsBubbleView::StartFadingOut() { |
| if (fadeout_observer_) |
| return; |