From 2db27be7dbb16f02587b90f150a843d8ad234563 Mon Sep 17 00:00:00 2001 From: "twiz@chromium.org" Date: Wed, 10 Feb 2010 22:46:47 +0000 Subject: CL implementing focus-dismissal of the chrome.experimental.popup set of extension APIs. Specifically, these changes cause a displayed pop-up to be dismissed when the focus shifts away from both the pop-up view, and the extension-view that launched the pop-up.I had to do a lot of investigating and trial-and-error to converge to the solution present here. I was hoping to be able to piggy-back on the existing FocusManager's various listener routines, but because the pop-up is hosted in a BubbleWidget, which is a separate top-level window with its own focus manager, I could not rely on a given focus manager to take care of the focus change notifications. To get around the above issue, I added a new type of focus listener that can listen on native-window focus change events. I added invocations to this listener throughout the Widget classes in the system so that registered listeners will be notified on focus change. I found some of the focus change events problematic, as the system will arbitrarily reassign the focus to the main browser window when shifting activation between chrome windows. (SeefocusManagerWin::ClearNativeFocus). To prevent this focus bounce from confusing focus listeners, I added a means to suppress notification of focus change during these operations. I added GTK and Mac stubs for the new widget functions that will assert when called. GTK and Cocoa development is not my expertise, so I thought // TODO(port) would be wiser.I'm uncertain of the best means to unit-test these changes. Direction in this regard would be appreciated. BUG=None TEST=None Review URL: http://codereview.chromium.org/552167 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38685 0039d316-1c4b-4281-b951-d872f2087c98 --- .../renderer_host/render_widget_host_view.h | 9 +++++ .../renderer_host/render_widget_host_view_gtk.cc | 22 +++++++++++ .../renderer_host/render_widget_host_view_gtk.h | 1 + .../renderer_host/render_widget_host_view_mac.h | 1 + .../renderer_host/render_widget_host_view_mac.mm | 18 +++++++++ .../renderer_host/render_widget_host_view_win.cc | 45 +++++++++++++++++++++- .../renderer_host/render_widget_host_view_win.h | 1 + .../renderer_host/test/test_render_view_host.h | 4 ++ 8 files changed, 100 insertions(+), 1 deletion(-) (limited to 'chrome/browser/renderer_host') diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index f761053..e2f58d8 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -51,6 +51,11 @@ class RenderWidgetHostView { // going to be a regular RenderWidgetHost or a RenderViewHost (a subclass). static RenderWidgetHostView* CreateViewForWidget(RenderWidgetHost* widget); + // Retrieves the RenderWidgetHostView corresponding to the specified + // |native_view|, or NULL if there is no such instance. + static RenderWidgetHostView* GetRenderWidgetHostViewFromNativeView( + gfx::NativeView native_view); + // Perform all the initialization steps necessary for this object to represent // a popup (such as a