diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-14 06:25:37 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-14 06:25:37 +0000 |
commit | 4d9b083160466cee96855a80318a904b7c89eec7 (patch) | |
tree | 55b1b9acc1860f0551751e570993776a6805b9c3 /ui/views | |
parent | d5b13808a0a79f898f042f4d224e834d99f8a56a (diff) | |
download | chromium_src-4d9b083160466cee96855a80318a904b7c89eec7.zip chromium_src-4d9b083160466cee96855a80318a904b7c89eec7.tar.gz chromium_src-4d9b083160466cee96855a80318a904b7c89eec7.tar.bz2 |
Add desktop-awareness to ChromeViewsDelegate::OnBeforeWidgetInit when deciding whether to make a window top-level or not.
This replaces an earlier spot-fix in http://crrev.com/197949 to explicitly unparent JS dialogs in aura win and doesn't suffer from bad window placement side-effects.
BUG=181162, 238249
TEST=All desktop aura dialogs are now correctly-placed top-level windows. See crbug.com/181162#c11 for a partial list of such dialogs.
Review URL: https://chromiumcodereview.appspot.com/14678017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/controls/webview/web_dialog_view.cc | 13 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 7 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.h | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget.h | 7 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 7 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget_private.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 3 |
9 files changed, 48 insertions, 4 deletions
diff --git a/ui/views/controls/webview/web_dialog_view.cc b/ui/views/controls/webview/web_dialog_view.cc index 9ea236a..1517379 100644 --- a/ui/views/controls/webview/web_dialog_view.cc +++ b/ui/views/controls/webview/web_dialog_view.cc @@ -24,6 +24,7 @@ #if defined(USE_AURA) #include "ui/base/events/event.h" +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" #include "ui/views/widget/native_widget_aura.h" #endif @@ -273,14 +274,18 @@ void WebDialogView::HandleKeyboardEvent(content::WebContents* source, if (!event.os_event) return; ui::KeyEvent aura_event(event.os_event->native_event(), false); - views::NativeWidgetAura* aura_widget = - static_cast<views::NativeWidgetAura*>(GetWidget()->native_widget()); - aura_widget->OnKeyEvent(&aura_event); + ui::EventHandler* event_handler = + GetWidget()->native_widget()->GetEventHandler(); + + DCHECK(event_handler); + if (event_handler) + event_handler->OnKeyEvent(&aura_event); + #elif defined(OS_WIN) // Any unhandled keyboard/character messages should be defproced. // This allows stuff like F10, etc to work correctly. DefWindowProc(event.os_event.hwnd, event.os_event.message, - event.os_event.wParam, event.os_event.lParam); + event.os_event.wParam, event.os_event.lParam); #endif } diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index c4634c3..588ba82 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -862,4 +862,11 @@ void DesktopNativeWidgetAura::OnRootWindowHostCloseRequested( Close(); } +//////////////////////////////////////////////////////////////////////////////// +// DesktopNativeWidgetAura, NativeWidget implementation: + +ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { + return this; +} + } // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index fed511c..e8284f0 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -69,6 +69,9 @@ class VIEWS_EXPORT DesktopNativeWidgetAura return root_window_event_filter_; } + // Overridden from NativeWidget: + virtual ui::EventHandler* GetEventHandler() OVERRIDE; + protected: // Overridden from internal::NativeWidgetPrivate: virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; diff --git a/ui/views/widget/native_widget.h b/ui/views/widget/native_widget.h index d01265f..39255ff 100644 --- a/ui/views/widget/native_widget.h +++ b/ui/views/widget/native_widget.h @@ -7,6 +7,10 @@ #include "ui/views/widget/widget.h" +namespace ui { +class EventHandler; +} + namespace views { namespace internal { class NativeWidgetPrivate; @@ -26,6 +30,9 @@ class VIEWS_EXPORT NativeWidget { public: virtual ~NativeWidget() {} + // Retrieves the event handler + virtual ui::EventHandler* GetEventHandler() = 0; + private: friend class Widget; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 17724b9..f3b55ff 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -874,6 +874,13 @@ int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { } //////////////////////////////////////////////////////////////////////////////// +// NativeWidgetAura, NativeWidget implementation: + +ui::EventHandler* NativeWidgetAura::GetEventHandler() { + return this; +} + +//////////////////////////////////////////////////////////////////////////////// // NativeWidgetAura, protected: NativeWidgetAura::~NativeWidgetAura() { diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index c40901a..68f8bf5 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -173,6 +173,9 @@ class VIEWS_EXPORT NativeWidgetAura virtual void OnDragExited() OVERRIDE; virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; + // Overridden from NativeWidget: + virtual ui::EventHandler* GetEventHandler() OVERRIDE; + protected: virtual ~NativeWidgetAura(); diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index 058e645..7a751f7 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -215,6 +215,7 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { // Overridden from NativeWidget: virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; + virtual ui::EventHandler* GetEventHandler() = 0; }; } // namespace internal diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index ba4a33f..5271318 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -450,6 +450,14 @@ ui::NativeTheme* NativeWidgetWin::GetNativeTheme() const { } //////////////////////////////////////////////////////////////////////////////// +// NativeWidgetWin, NativeWidget implementation: + +ui::EventHandler* NativeWidgetWin::GetEventHandler() { + NOTIMPLEMENTED(); + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, protected: void NativeWidgetWin::OnFinalMessage(HWND window) { diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index a2c3f91..7ee8d35 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -146,6 +146,9 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; + // Overridden from NativeWidget: + virtual ui::EventHandler* GetEventHandler() OVERRIDE; + protected: // Deletes this window as it is destroyed, override to provide different // behavior. |