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

Unified Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 11578014: Desktop aura: Expand what the ViewsDelegate can do to new windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/chrome_views_delegate.cc
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 7cc0f53e5a8dd6f2eb70c209bbb12065677778d8..bb7711c7d997b3fc0cb9377a5fc253d5c2c89b3f 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -25,6 +25,7 @@
#endif
#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+#include "chrome/browser/ui/host_desktop.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/native_widget_aura.h"
#endif
@@ -173,20 +174,48 @@ content::WebContents* ChromeViewsDelegate::CreateWebContents(
return NULL;
}
-views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget(
- views::Widget::InitParams::Type type,
- views::internal::NativeWidgetDelegate* delegate,
- gfx::NativeView parent,
- gfx::NativeView context) {
+void ChromeViewsDelegate::OnWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) {
#if defined(USE_AURA) && !defined(OS_CHROMEOS)
- if (parent && type != views::Widget::InitParams::TYPE_MENU)
- return new views::NativeWidgetAura(delegate);
- // TODO(erg): Once we've threaded context to everywhere that needs it, we
- // should remove this check here.
- gfx::NativeView to_check = context ? context : parent;
- if (chrome::GetHostDesktopTypeForNativeView(to_check) ==
- chrome::HOST_DESKTOP_TYPE_NATIVE)
- return new views::DesktopNativeWidgetAura(delegate);
+ // While the majority of the time, context wasn't plumbed through due to the
+ // existence of a global StackingClient, if this window is a toplevel, it's
+ // possible that there is no contextual state that we can use.
+ if (params->parent == NULL &&
+ params->context == NULL &&
+ params->top_level == true) {
Ben Goodger (Google) 2012/12/13 23:47:41 params->top_level
+ // We need to make a decision about where to place this window based on the
+ // desktop type.
+ switch (chrome::GetActiveDesktop()) {
+ case chrome::HOST_DESKTOP_TYPE_NATIVE: {
Ben Goodger (Google) 2012/12/13 23:47:41 you don't need the braces on each case since you'r
+ // If we're native, we should give this window its own toplevel desktop
+ // widget.
+ params->native_widget = new views::DesktopNativeWidgetAura(delegate);
+ break;
+ }
+ case chrome::HOST_DESKTOP_TYPE_ASH: {
+#if defined(USE_ASH)
robertshield 2012/12/14 01:15:58 How about moving the #if to completely surround th
+ // If we're in ash, give this window the context of the main monitor.
+ params->context = ash::Shell::GetPrimaryRootWindow();
+#endif
+ break;
+ }
+ default: {
+ NOTREACHED();
+ }
+ }
+ } else {
+ if (params->parent && params->type != views::Widget::InitParams::TYPE_MENU)
+ params->native_widget = new views::NativeWidgetAura(delegate);
+
+ // TODO(erg): Once we've threaded context to everywhere that needs it, we
+ // should remove this check here.
+ gfx::NativeView to_check =
+ params->context ? params->context : params->parent;
+ if (chrome::GetHostDesktopTypeForNativeView(to_check) ==
+ chrome::HOST_DESKTOP_TYPE_NATIVE) {
+ params->native_widget = new views::DesktopNativeWidgetAura(delegate);
+ }
+ }
#endif
- return NULL;
}

Powered by Google App Engine
This is Rietveld 408576698