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

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

Issue 730833006: MacViews: Implement event monitoring for a specific window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 3238816c32e1196fcbf7d89b5592fdac6f639767..85592c863fbb5525e3e8e6590a43fcd47ef6a2c5 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -20,7 +20,6 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/button/blue_button.h"
@@ -31,6 +30,7 @@
#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/event_monitor.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
@@ -714,15 +714,13 @@ class ManagePasswordsBubbleView::WebContentMouseHandler
: public ui::EventHandler {
public:
explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble);
- ~WebContentMouseHandler() override;
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override;
private:
- aura::Window* GetWebContentsWindow();
-
ManagePasswordsBubbleView* bubble_;
+ scoped_ptr<views::EventMonitor> event_monitor_;
DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler);
};
@@ -730,17 +728,16 @@ class ManagePasswordsBubbleView::WebContentMouseHandler
ManagePasswordsBubbleView::WebContentMouseHandler::WebContentMouseHandler(
ManagePasswordsBubbleView* bubble)
: bubble_(bubble) {
- GetWebContentsWindow()->AddPreTargetHandler(this);
-}
-
-ManagePasswordsBubbleView::WebContentMouseHandler::~WebContentMouseHandler() {
- if (aura::Window* window = GetWebContentsWindow())
- window->RemovePreTargetHandler(this);
+ content::WebContents* web_contents = bubble_->web_contents();
+ if (web_contents) {
+ gfx::NativeWindow target_window = web_contents->GetTopLevelNativeWindow();
+ event_monitor_.reset(views::EventMonitor::Create(this, target_window));
tapted 2014/11/21 00:57:34 can you make the views::EventMonitor::Create* retu
Andre 2014/12/10 00:18:13 Done.
+ }
}
void ManagePasswordsBubbleView::WebContentMouseHandler::OnKeyEvent(
ui::KeyEvent* event) {
- content::WebContents* web_contents = bubble_->model()->web_contents();
+ content::WebContents* web_contents = bubble_->web_contents();
content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
if (rvh->IsFocusedElementEditable() &&
event->type() == ui::ET_KEY_PRESSED)
@@ -753,12 +750,6 @@ void ManagePasswordsBubbleView::WebContentMouseHandler::OnMouseEvent(
bubble_->Close();
}
-aura::Window*
-ManagePasswordsBubbleView::WebContentMouseHandler::GetWebContentsWindow() {
- content::WebContents* web_contents = bubble_->model()->web_contents();
- return web_contents ? web_contents->GetNativeView() : NULL;
-}
-
// ManagePasswordsBubbleView --------------------------------------------------
// static
@@ -786,8 +777,7 @@ void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
web_contents, anchor_view, reason);
if (is_fullscreen) {
tapted 2014/11/20 22:39:02 nit: no curlies
Andre 2014/12/10 00:18:13 Done.
- manage_passwords_bubble_->set_parent_window(
- web_contents->GetTopLevelNativeWindow());
+ manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView());
}
views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_);

Powered by Google App Engine
This is Rietveld 408576698