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

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

Issue 512683003: Password bubble should close if user clicks on the web page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a test Created 6 years, 4 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 df206d6c4d7a6b59ad1e8617ad3fb96790d5a3e5..47b68eb41fb2805b5439d100d69adb807bce15fd 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,40 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
parent_->Close();
}
+// ManagePasswordsBubbleView::WebContentMouseHandler --------------------------
+
+// The class listens for WebContentsView events and notifies the bubble if the
+// view was clicked on.
+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 +629,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 +738,7 @@ void ManagePasswordsBubbleView::StartTimerIfNecessary() {
this,
&ManagePasswordsBubbleView::Close);
}
+
+void ManagePasswordsBubbleView::OnWebContentClicked() {
+ Close();
+}

Powered by Google App Engine
This is Rietveld 408576698