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 df206d6c4d7a6b59ad1e8617ad3fb96790d5a3e5..54a2fca24b476531890dc178d776f6d3edd9b536 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
| @@ -17,6 +17,8 @@ |
| #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" |
| @@ -512,6 +514,39 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( |
| parent_->Close(); |
| } |
| +// ManagePasswordsBubbleView::WebContentMouseHandler -------------------------- |
| + |
| +// The class listens WebContentsView for mouse clicks. |
|
vabr (Chromium)
2014/08/27 16:43:05
nit: listens -> listens to
vabr (Chromium)
2014/08/27 16:43:05
nit: Could you extend the comment to say what the
vasilii
2014/08/27 17:24:24
Done.
vasilii
2014/08/27 17:24:24
Done.
|
| +class ManagePasswordsBubbleView::WebContentMouseHandler |
| + : public ui::EventHandler { |
| + public: |
| + explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble) |
| + : bubble_(bubble) { |
| + GetWebContentsWindow()->AddPreTargetHandler(this); |
| + } |
| + |
| + virtual ~WebContentMouseHandler() { |
| + aura::Window* window = GetWebContentsWindow(); |
| + if (window) |
| + window->RemovePreTargetHandler(this); |
| + } |
| + |
| + virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| + if (event->type() == ui::ET_MOUSE_PRESSED) |
| + bubble_->OnWebContentClicked(); |
| + } |
| + |
| + private: |
| + aura::Window* GetWebContentsWindow() { |
| + content::WebContents* web_contents = bubble_->model()->web_contents(); |
| + return web_contents ? web_contents->GetNativeView() : NULL; |
| + } |
| + |
| + ManagePasswordsBubbleView* bubble_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler); |
| +}; |
| + |
| // ManagePasswordsBubbleView -------------------------------------------------- |
| // static |
| @@ -593,6 +628,7 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| set_notify_enter_exit_on_child(true); |
| if (anchor_view) |
| anchor_view->SetActive(true); |
| + mouse_handler_.reset(new WebContentMouseHandler(this)); |
| } |
| ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { |
| @@ -701,3 +737,7 @@ void ManagePasswordsBubbleView::StartTimerIfNecessary() { |
| this, |
| &ManagePasswordsBubbleView::Close); |
| } |
| + |
| +void ManagePasswordsBubbleView::OnWebContentClicked() { |
| + Close(); |
| +} |