summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 19:25:41 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 19:25:41 +0000
commit984522c27db175de6fc1835fb6ef2d4327aa7657 (patch)
treeafcd1b6e5e459c82b5e7246da297fb74147903bf
parentc115677e34ec8c23b604570e546b1881091fbcf6 (diff)
downloadchromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.zip
chromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.tar.gz
chromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.tar.bz2
Revert 177182 - ViewTest.ChangeNativeViewHierarchyFindRoots failure
> Finally rip the global StackingClient bandaid off. > > - Removes the aura::client::SetStackingClient(StackingClient*) interface. > - Moves the ash StackingController from a singleton owned by ash::Shell to one StackingController per RootWindow owned by the ash::RootWindowController. (Also removes a spurious delegate method, where every implementation creates the same object, including tests.) > - Removes the global DesktopStackingClient and related interfaces. > - Fix the ChromeViewsDelegate so that it still sets context in chromeos builds. > - Rename content::ShellStackingClientAsh to content::MinimalAsh to reflect what it really does. > > In addition, the following fix ups apply: > > - Previously, WebContentsViewAura asserted that it needed a context window. Now if no context window is provided, it isn't added to an aura hierarchy. There are times when that context doesn't exist: various chromeos dialogs that directly invoke WebView and toplevel extension/app windows that are created from background pages that don't have contexts. > > BUG=161882 > > Review URL: https://codereview.chromium.org/11829040 TBR=erg@chromium.org Review URL: https://codereview.chromium.org/11962021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177190 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/root_window_controller.cc4
-rw-r--r--ash/root_window_controller.h3
-rw-r--r--ash/shell.cc9
-rw-r--r--ash/shell.h4
-rw-r--r--ash/shell/shell_delegate_impl.cc5
-rw-r--r--ash/shell/shell_delegate_impl.h1
-rw-r--r--ash/shell_delegate.h4
-rw-r--r--ash/test/test_shell_delegate.cc5
-rw-r--r--ash/test/test_shell_delegate.h1
-rw-r--r--chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc11
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc5
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h1
-rw-r--r--chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc5
-rw-r--r--chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h7
-rw-r--r--chrome/browser/ui/aura/stacking_client_aura.cc33
-rw-r--r--chrome/browser/ui/aura/stacking_client_aura.h42
-rw-r--r--chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc1
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.cc12
-rw-r--r--chrome/browser/ui/views/chrome_web_dialog_view.cc18
-rw-r--r--chrome/browser/ui/views/javascript_app_modal_dialog_views.cc5
-rw-r--r--chrome/browser/ui/views/simple_message_box_views.cc5
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc16
-rw-r--r--content/content_shell.gypi4
-rw-r--r--content/shell/minimal_ash.cc53
-rw-r--r--content/shell/shell.h15
-rw-r--r--content/shell/shell_aura.cc27
-rw-r--r--content/shell/shell_stacking_client_ash.cc56
-rw-r--r--content/shell/shell_stacking_client_ash.h (renamed from content/shell/minimal_ash.h)14
-rw-r--r--ui/aura/client/stacking_client.cc36
-rw-r--r--ui/aura/client/stacking_client.h4
-rw-r--r--ui/aura/demo/demo_main.cc4
-rw-r--r--ui/aura/env.cc3
-rw-r--r--ui/aura/env.h7
-rw-r--r--ui/aura/test/test_stacking_client.cc4
-rw-r--r--ui/aura/window.cc3
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.cc4
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.h9
-rw-r--r--ui/views/views.gyp2
-rw-r--r--ui/views/widget/desktop_aura/desktop_stacking_client.cc64
-rw-r--r--ui/views/widget/desktop_aura/desktop_stacking_client.h65
-rw-r--r--ui/views/widget/native_widget_aura.cc11
-rw-r--r--ui/views/widget/widget.cc13
43 files changed, 419 insertions, 178 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 9c6580a..543a084 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -26,7 +26,6 @@
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/screen_dimmer.h"
#include "ash/wm/shelf_layout_manager.h"
-#include "ash/wm/stacking_controller.h"
#include "ash/wm/status_area_layout_manager.h"
#include "ash/wm/system_background_controller.h"
#include "ash/wm/system_modal_container_layout_manager.h"
@@ -169,9 +168,6 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window)
panel_layout_manager_(NULL) {
SetRootWindowController(root_window, this);
screen_dimmer_.reset(new ScreenDimmer(root_window));
-
- stacking_controller_.reset(new ash::StackingController);
- aura::client::SetStackingClient(root_window, stacking_controller_.get());
}
RootWindowController::~RootWindowController() {
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 2dae441..e5e85ef1 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -32,7 +32,6 @@ class RootWindowEventFilter;
namespace ash {
class Launcher;
-class StackingController;
class SystemTray;
class ToplevelWindowEventHandler;
@@ -177,8 +176,6 @@ class ASH_EXPORT RootWindowController {
scoped_ptr<aura::RootWindow> root_window_;
RootWindowLayoutManager* root_window_layout_;
- scoped_ptr<StackingController> stacking_controller_;
-
// Widget containing system tray.
StatusAreaWidget* status_area_widget_;
diff --git a/ash/shell.cc b/ash/shell.cc
index 171c121..f1c6d99 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -56,6 +56,7 @@
#include "ash/wm/session_state_controller.h"
#include "ash/wm/session_state_controller_impl.h"
#include "ash/wm/session_state_controller_impl2.h"
+#include "ash/wm/stacking_controller.h"
#include "ash/wm/system_gesture_event_filter.h"
#include "ash/wm/system_modal_container_event_filter.h"
#include "ash/wm/system_modal_container_layout_manager.h"
@@ -70,6 +71,7 @@
#include "base/command_line.h"
#include "base/debug/leak_annotations.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/user_action_client.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
@@ -500,6 +502,9 @@ void Shell::Init() {
// Create Controllers that may need root window.
// TODO(oshima): Move as many controllers before creating
// RootWindowController as possible.
+ stacking_client_.reset(delegate_->CreateStackingClient());
+ if (stacking_client_.get())
+ aura::client::SetStackingClient(stacking_client_.get());
visibility_controller_.reset(new AshVisibilityController);
drag_drop_controller_.reset(new internal::DragDropController);
user_action_client_.reset(delegate_->CreateUserActionClient());
@@ -830,6 +835,10 @@ void Shell::DoInitialWorkspaceAnimation() {
DoInitialAnimation();
}
+aura::client::StackingClient* Shell::stacking_client() {
+ return stacking_client_.get();
+}
+
void Shell::InitRootWindowController(
internal::RootWindowController* controller) {
aura::RootWindow* root_window = controller->root_window();
diff --git a/ash/shell.h b/ash/shell.h
index 8978ce3..bc86059 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -33,6 +33,7 @@ class Window;
namespace client {
class ActivationClient;
class FocusClient;
+class StackingClient;
class UserActionClient;
}
}
@@ -428,6 +429,8 @@ class ASH_EXPORT Shell
}
#endif // defined(OS_CHROMEOS)
+ aura::client::StackingClient* stacking_client();
+
RootWindowHostFactory* root_window_host_factory() {
return root_window_host_factory_.get();
}
@@ -508,6 +511,7 @@ class ASH_EXPORT Shell
scoped_ptr<internal::AppListController> app_list_controller_;
+ scoped_ptr<aura::client::StackingClient> stacking_client_;
scoped_ptr<internal::ActivationController> activation_controller_;
scoped_ptr<internal::CaptureController> capture_controller_;
scoped_ptr<internal::DragDropController> drag_drop_controller_;
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 945fae9..681dfb5 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -11,6 +11,7 @@
#include "ash/shell/context_menu.h"
#include "ash/shell/toplevel_window.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/stacking_controller.h"
#include "ash/wm/window_util.h"
#include "base/message_loop.h"
#include "ui/aura/window.h"
@@ -214,6 +215,10 @@ ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::RootWindow* root) {
return new ContextMenu(root);
}
+aura::client::StackingClient* ShellDelegateImpl::CreateStackingClient() {
+ return new StackingController;
+}
+
RootWindowHostFactory* ShellDelegateImpl::CreateRootWindowHostFactory() {
return RootWindowHostFactory::Create();
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 66f6076..e94d08a 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -69,6 +69,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual double GetSavedScreenMagnifierScale() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu(
aura::RootWindow* root_window) OVERRIDE;
+ virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
private:
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 11482d5..6a9dd08 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -22,6 +22,7 @@ namespace aura {
class RootWindow;
class Window;
namespace client {
+class StackingClient;
class UserActionClient;
}
}
@@ -218,6 +219,9 @@ class ASH_EXPORT ShellDelegate {
// Creates a menu model of the context for the |root_window|.
virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root_window) = 0;
+ // Creates the stacking client. Shell takes ownership of the object.
+ virtual aura::client::StackingClient* CreateStackingClient() = 0;
+
// Creates a root window host factory. Shell takes ownership of the returned
// value.
virtual RootWindowHostFactory* CreateRootWindowHostFactory() = 0;
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 4690156..c2fdc60 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -11,6 +11,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/test_launcher_delegate.h"
+#include "ash/wm/stacking_controller.h"
#include "ash/wm/window_util.h"
#include "content/public/test/test_browser_context.h"
#include "ui/aura/window.h"
@@ -203,6 +204,10 @@ double TestShellDelegate::GetSavedScreenMagnifierScale() {
return std::numeric_limits<double>::min();
}
+aura::client::StackingClient* TestShellDelegate::CreateStackingClient() {
+ return new StackingController;
+}
+
RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() {
return RootWindowHostFactory::Create();
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 3b0ee76..76add5d 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -67,6 +67,7 @@ class TestShellDelegate : public ShellDelegate {
virtual void SaveScreenMagnifierScale(double scale) OVERRIDE;
virtual double GetSavedScreenMagnifierScale() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE;
+ virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
int num_exit_requests() const { return num_exit_requests_; }
diff --git a/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc b/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
index be2c7e8..261a8fc 100644
--- a/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
+++ b/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
@@ -10,10 +10,6 @@
#include "content/public/browser/web_contents_view.h"
#include "ui/base/text/text_elider.h"
-#if defined(USE_AURA)
-#include "ui/aura/root_window.h"
-#endif
-
using content::JavaScriptDialogCreator;
using content::WebContents;
@@ -84,13 +80,6 @@ JavaScriptAppModalDialog::~JavaScriptAppModalDialog() {
NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() {
gfx::NativeWindow parent_window =
web_contents()->GetView()->GetTopLevelNativeWindow();
-#if defined(USE_AURA)
- if (!parent_window->GetRootWindow()) {
- // When we are part of a WebContents that isn't actually being displayed on
- // the screen, we can't actually attach to it.
- parent_window = NULL;
- }
-#endif
return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this,
parent_window);
}
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index a0bc043..b784036 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -8,6 +8,7 @@
#include "ash/launcher/launcher_types.h"
#include "ash/magnifier/magnifier_constants.h"
#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/wm/stacking_controller.h"
#include "ash/wm/window_util.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -556,6 +557,10 @@ ui::MenuModel* ChromeShellDelegate::CreateContextMenu(aura::RootWindow* root) {
return new LauncherContextMenu(launcher_delegate_, root);
}
+aura::client::StackingClient* ChromeShellDelegate::CreateStackingClient() {
+ return new ash::StackingController;
+}
+
ash::RootWindowHostFactory* ChromeShellDelegate::CreateRootWindowHostFactory() {
return ash::RootWindowHostFactory::Create();
}
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index 1cf04aa..7270a37 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -83,6 +83,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual void SaveScreenMagnifierScale(double scale) OVERRIDE;
virtual double GetSavedScreenMagnifierScale() OVERRIDE;
virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE;
+ virtual aura::client::StackingClient* CreateStackingClient() OVERRIDE;
virtual ash::RootWindowHostFactory* CreateRootWindowHostFactory() OVERRIDE;
// content::NotificationObserver override:
diff --git a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
index 88b9861..21387c8 100644
--- a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
+++ b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
@@ -7,9 +7,11 @@
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/toolkit_extra_parts.h"
#include "chrome/browser/ui/aura/active_desktop_monitor.h"
+#include "chrome/browser/ui/aura/stacking_client_aura.h"
#include "ui/aura/env.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#include "ui/views/widget/native_widget_aura.h"
#if defined(OS_LINUX)
@@ -37,6 +39,8 @@ void ChromeBrowserMainExtraPartsAura::PreProfileInit() {
{
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
views::CreateDesktopScreen());
+ stacking_client_.reset(new views::DesktopStackingClient);
+ aura::client::SetStackingClient(stacking_client_.get());
}
#endif
@@ -47,6 +51,7 @@ void ChromeBrowserMainExtraPartsAura::PreProfileInit() {
}
void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() {
+ stacking_client_.reset();
active_desktop_monitor_.reset();
// aura::Env instance is deleted in BrowserProcessImpl::StartTearDown
diff --git a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h
index c6573c7..4bb8cfe 100644
--- a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h
+++ b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h
@@ -10,6 +10,12 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
+namespace aura {
+namespace client {
+class StackingClient;
+}
+}
+
class ActiveDesktopMonitor;
class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
@@ -22,6 +28,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
virtual void PostMainMessageLoopRun() OVERRIDE;
private:
+ scoped_ptr<aura::client::StackingClient> stacking_client_;
scoped_ptr<ActiveDesktopMonitor> active_desktop_monitor_;
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura);
diff --git a/chrome/browser/ui/aura/stacking_client_aura.cc b/chrome/browser/ui/aura/stacking_client_aura.cc
new file mode 100644
index 0000000..e2e70e4
--- /dev/null
+++ b/chrome/browser/ui/aura/stacking_client_aura.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/aura/stacking_client_aura.h"
+
+#include "ash/shell.h"
+#include "ash/wm/stacking_controller.h"
+#include "ui/aura/focus_manager.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
+
+StackingClientAura::StackingClientAura() {
+ desktop_stacking_client_.reset(new views::DesktopStackingClient);
+}
+
+StackingClientAura::~StackingClientAura() {
+}
+
+aura::Window* StackingClientAura::GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) {
+#if defined(USE_ASH)
+ if (chrome::GetHostDesktopTypeForNativeView(context) ==
+ chrome::HOST_DESKTOP_TYPE_ASH) {
+ return ash::Shell::GetInstance()->stacking_client()->GetDefaultParent(
+ context, window, bounds);
+ }
+#endif
+ return desktop_stacking_client_->GetDefaultParent(context, window, bounds);
+}
diff --git a/chrome/browser/ui/aura/stacking_client_aura.h b/chrome/browser/ui/aura/stacking_client_aura.h
new file mode 100644
index 0000000..e478df8
--- /dev/null
+++ b/chrome/browser/ui/aura/stacking_client_aura.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_AURA_STACKING_CLIENT_AURA_H_
+#define CHROME_BROWSER_UI_AURA_STACKING_CLIENT_AURA_H_
+
+#include "ui/aura/client/stacking_client.h"
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/ui/host_desktop.h"
+
+namespace ash {
+class StackingController;
+}
+
+namespace views {
+class DesktopStackingClient;
+class Window;
+}
+
+// A stacking client for the two worlds aura, dispatches to either a
+// DesktopStackingClient or an ash::StackingController.
+class StackingClientAura : public aura::client::StackingClient {
+ public:
+ StackingClientAura();
+ virtual ~StackingClientAura();
+
+ // Overridden from client::StackingClient:
+ virtual aura::Window* GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) OVERRIDE;
+
+ private:
+ scoped_ptr<views::DesktopStackingClient> desktop_stacking_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(StackingClientAura);
+};
+
+#endif // CHROME_BROWSER_UI_AURA_STACKING_CLIENT_AURA_H_
diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
index bd06618..44b9f3e3 100644
--- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
+++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
@@ -15,6 +15,7 @@
#include "ui/gfx/screen.h"
#include "ui/gfx/screen_type_delegate.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#if defined(FILE_MANAGER_EXTENSION)
#include "chrome/browser/ui/views/select_file_dialog_extension.h"
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 4be7e0f..3d4448e 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -24,12 +24,9 @@
#include "chrome/browser/app_icon_win.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/root_window.h"
-#endif
-
#if defined(USE_AURA) && !defined(OS_CHROMEOS)
#include "chrome/browser/ui/host_desktop.h"
+#include "ui/aura/root_window.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/native_widget_aura.h"
#endif
@@ -177,17 +174,12 @@ content::WebContents* ChromeViewsDelegate::CreateWebContents(
void ChromeViewsDelegate::OnBeforeWidgetInit(
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) {
+#if defined(USE_AURA) && !defined(OS_CHROMEOS)
// If we already have a native_widget, we don't have to try to come
// up with one.
if (params->native_widget)
return;
-#if defined(OS_CHROMEOS)
- // When we are doing straight chromeos builds, we still need to handle the
- // toplevel window case.
- if (params->parent == NULL && params->context == NULL && params->top_level)
- params->context = ash::Shell::GetPrimaryRootWindow();
-#elif defined(USE_AURA)
// 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.
diff --git a/chrome/browser/ui/views/chrome_web_dialog_view.cc b/chrome/browser/ui/views/chrome_web_dialog_view.cc
index c73f6ea..cc0a917 100644
--- a/chrome/browser/ui/views/chrome_web_dialog_view.cc
+++ b/chrome/browser/ui/views/chrome_web_dialog_view.cc
@@ -13,21 +13,9 @@ namespace chrome {
gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent,
content::BrowserContext* context,
ui::WebDialogDelegate* delegate) {
- views::Widget* widget = NULL;
- if (parent) {
- widget = views::Widget::CreateWindowWithParent(
- new views::WebDialogView(context,
- delegate,
- new ChromeWebContentsHandler),
- parent);
- } else {
- // We shouldn't be called with a NULL parent, but sometimes are.
- widget = views::Widget::CreateWindow(
- new views::WebDialogView(context,
- delegate,
- new ChromeWebContentsHandler));
- }
-
+ views::Widget* widget = views::Widget::CreateWindowWithParent(
+ new views::WebDialogView(context, delegate, new ChromeWebContentsHandler),
+ parent);
widget->Show();
return widget->GetNativeWindow();
}
diff --git a/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc b/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
index d715b05..d324d37 100644
--- a/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
+++ b/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
@@ -162,9 +162,6 @@ NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
JavaScriptAppModalDialog* dialog,
gfx::NativeWindow parent_window) {
JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog);
- if (parent_window)
- views::Widget::CreateWindowWithParent(d, parent_window);
- else
- views::Widget::CreateWindow(d);
+ views::Widget::CreateWindowWithParent(d, parent_window);
return d;
}
diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc
index 2faa66f..f87e526 100644
--- a/chrome/browser/ui/views/simple_message_box_views.cc
+++ b/chrome/browser/ui/views/simple_message_box_views.cc
@@ -167,10 +167,7 @@ MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
scoped_refptr<SimpleMessageBoxViews> dialog(
new SimpleMessageBoxViews(title, message, type));
- if (parent)
- views::Widget::CreateWindowWithParent(dialog, parent)->Show();
- else
- views::Widget::CreateWindow(dialog)->Show();
+ views::Widget::CreateWindowWithParent(dialog, parent)->Show();
#if defined(USE_AURA)
// Use the widget's window itself so that the message loop
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index fa14a98..378c6ea 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -194,6 +194,8 @@
'browser/ui/aura/active_desktop_monitor.h',
'browser/ui/aura/chrome_browser_main_extra_parts_aura.cc',
'browser/ui/aura/chrome_browser_main_extra_parts_aura.h',
+ 'browser/ui/aura/stacking_client_aura.cc',
+ 'browser/ui/aura/stacking_client_aura.h',
'browser/ui/aura/tabs/dock_info_aurax11.cc',
'browser/ui/autofill/autofill_dialog_controller.cc',
'browser/ui/autofill/autofill_dialog_controller.h',
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 4b9e9ce..a6c8cf4 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -634,18 +634,10 @@ void WebContentsViewAura::CreateView(
window_->SetType(aura::client::WINDOW_TYPE_CONTROL);
window_->SetTransparent(false);
window_->Init(ui::LAYER_NOT_DRAWN);
- if (context) {
- // There are places where there is no context currently because object
- // hierarchies are built before they're attached to a Widget. (See
- // views::WebView as an example; GetWidget() returns NULL at the point
- // where we are created.)
- //
- // It should be OK to not set a default parent since such users will
- // explicitly add this WebContentsViewAura to their tree after they create
- // us.
- window_->SetDefaultParentByRootWindow(context->GetRootWindow(),
- gfx::Rect());
- }
+ // TODO(mukai, erg): Should use a non-NULL value later when the DCHECK is
+ // turned on in SetDefaultParentByRootWindow().
+ aura::RootWindow* target_root = context ? context->GetRootWindow() : NULL;
+ window_->SetDefaultParentByRootWindow(target_root, gfx::Rect());
window_->layer()->SetMasksToBounds(true);
window_->SetName("WebContentsViewAura");
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index 2bb1417..429f0a9 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -54,8 +54,6 @@
'sources': [
'shell/geolocation/shell_access_token_store.cc',
'shell/geolocation/shell_access_token_store.h',
- 'shell/minimal_ash.cc',
- 'shell/minimal_ash.h',
'shell/paths_mac.h',
'shell/paths_mac.mm',
'shell/shell.cc',
@@ -106,6 +104,8 @@
'shell/shell_resource_context.h',
'shell/shell_resource_dispatcher_host_delegate.cc',
'shell/shell_resource_dispatcher_host_delegate.h',
+ 'shell/shell_stacking_client_ash.cc',
+ 'shell/shell_stacking_client_ash.h',
'shell/shell_switches.cc',
'shell/shell_switches.h',
'shell/shell_url_request_context_getter.cc',
diff --git a/content/shell/minimal_ash.cc b/content/shell/minimal_ash.cc
deleted file mode 100644
index e1ff94a..0000000
--- a/content/shell/minimal_ash.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/shell/minimal_ash.h"
-
-#include "ui/aura/client/default_capture_client.h"
-#include "ui/aura/focus_manager.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/test/test_activation_client.h"
-#include "ui/views/corewm/compound_event_filter.h"
-#include "ui/views/corewm/input_method_event_filter.h"
-
-namespace content {
-
-MinimalAsh::MinimalAsh() {
- root_window_.reset(new aura::RootWindow(
- aura::RootWindow::CreateParams(gfx::Rect(100, 100))));
- root_window_->Init();
- aura::client::SetStackingClient(root_window_.get(), this);
-
- focus_client_.reset(new aura::FocusManager);
- aura::client::SetFocusClient(root_window_.get(), focus_client_.get());
-
- root_window_event_filter_ = new views::corewm::CompoundEventFilter;
- // Pass ownership of the filter to the root_window.
- root_window_->SetEventFilter(root_window_event_filter_);
-
- input_method_filter_.reset(new views::corewm::InputMethodEventFilter(
- root_window_->GetAcceleratedWidget()));
- input_method_filter_->SetInputMethodPropertyInRootWindow(
- root_window_.get());
- root_window_event_filter_->AddHandler(input_method_filter_.get());
-
- test_activation_client_.reset(
- new aura::test::TestActivationClient(root_window_.get()));
-
- capture_client_.reset(
- new aura::client::DefaultCaptureClient(root_window_.get()));
-}
-
-MinimalAsh::~MinimalAsh() {
- root_window_event_filter_->RemoveHandler(input_method_filter_.get());
-}
-
-aura::Window* MinimalAsh::GetDefaultParent(
- aura::Window* context,
- aura::Window* window,
- const gfx::Rect& bounds) {
- return root_window_.get();
-}
-
-} // namespace content
diff --git a/content/shell/shell.h b/content/shell/shell.h
index e2162e8..82e2a6a 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -1,6 +1,7 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
#ifndef CONTENT_SHELL_SHELL_H_
#define CONTENT_SHELL_SHELL_H_
@@ -26,15 +27,15 @@ typedef struct _GtkToolItem GtkToolItem;
#elif defined(OS_ANDROID)
#include "base/android/scoped_java_ref.h"
#elif defined(USE_AURA)
-#if defined(OS_CHROMEOS)
-namespace content {
-class MinimalAsh;
-}
-#endif
namespace views {
class Widget;
class ViewsDelegate;
}
+namespace aura {
+namespace client {
+class StackingClient;
+}
+}
#endif
class GURL;
@@ -236,9 +237,7 @@ class Shell : public WebContentsDelegate,
#elif defined(OS_ANDROID)
base::android::ScopedJavaGlobalRef<jobject> java_object_;
#elif defined(USE_AURA)
-#if defined(OS_CHROMEOS)
- static content::MinimalAsh* minimal_ash_;
-#endif
+ static aura::client::StackingClient* stacking_client_;
static views::ViewsDelegate* views_delegate_;
views::Widget* window_widget_;
diff --git a/content/shell/shell_aura.cc b/content/shell/shell_aura.cc
index 6641cda..a0986c4 100644
--- a/content/shell/shell_aura.cc
+++ b/content/shell/shell_aura.cc
@@ -29,8 +29,10 @@
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "content/shell/minimal_ash.h"
+#include "content/shell/shell_stacking_client_ash.h"
#include "ui/aura/test/test_screen.h"
+#else
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#endif
// ViewDelegate implementation for aura content shell
@@ -272,9 +274,7 @@ using views::ShellWindowDelegateView;
namespace content {
-#if defined(OS_CHROMEOS)
-MinimalAsh* Shell::minimal_ash_ = NULL;
-#endif
+aura::client::StackingClient* Shell::stacking_client_ = NULL;
views::ViewsDelegate* Shell::views_delegate_ = NULL;
// static
@@ -283,21 +283,21 @@ void Shell::PlatformInitialize() {
chromeos::DBusThreadManager::Initialize();
#endif
#if defined(OS_CHROMEOS)
+ stacking_client_ = new content::ShellStackingClientAsh();
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, new aura::TestScreen);
- minimal_ash_ = new content::MinimalAsh();
#else
+ stacking_client_ = new views::DesktopStackingClient();
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
#endif
+ aura::client::SetStackingClient(stacking_client_);
views_delegate_ = new ShellViewsDelegateAura();
}
void Shell::PlatformExit() {
-#if defined(OS_CHROMEOS)
- if (minimal_ash_)
- delete minimal_ash_;
-#endif
+ if (stacking_client_)
+ delete stacking_client_;
if (views_delegate_)
delete views_delegate_;
#if defined(OS_CHROMEOS)
@@ -334,18 +334,9 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
-#if defined(OS_CHROMEOS)
- window_widget_ =
- views::Widget::CreateWindowWithContextAndBounds(
- new ShellWindowDelegateView(this),
- minimal_ash_->GetDefaultParent(NULL, NULL, gfx::Rect()),
- gfx::Rect(0, 0, width, height));
-#else
window_widget_ =
views::Widget::CreateWindowWithBounds(new ShellWindowDelegateView(this),
gfx::Rect(0, 0, width, height));
-#endif
-
window_ = window_widget_->GetNativeWindow();
window_widget_->Show();
}
diff --git a/content/shell/shell_stacking_client_ash.cc b/content/shell/shell_stacking_client_ash.cc
new file mode 100644
index 0000000..f9e7c0a
--- /dev/null
+++ b/content/shell/shell_stacking_client_ash.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell_stacking_client_ash.h"
+
+#include "ui/aura/client/default_capture_client.h"
+#include "ui/aura/focus_manager.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/test/test_activation_client.h"
+#include "ui/views/corewm/compound_event_filter.h"
+#include "ui/views/corewm/input_method_event_filter.h"
+
+namespace content {
+
+ShellStackingClientAsh::ShellStackingClientAsh() {
+}
+
+ShellStackingClientAsh::~ShellStackingClientAsh() {
+ if (root_window_.get())
+ root_window_event_filter_->RemoveHandler(input_method_filter_.get());
+
+ aura::client::SetStackingClient(NULL);
+}
+
+aura::Window* ShellStackingClientAsh::GetDefaultParent(
+ aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) {
+ if (!root_window_.get()) {
+ root_window_.reset(new aura::RootWindow(
+ aura::RootWindow::CreateParams(gfx::Rect(100, 100))));
+ root_window_->Init();
+ focus_client_.reset(new aura::FocusManager);
+ aura::client::SetFocusClient(root_window_.get(), focus_client_.get());
+
+ root_window_event_filter_ = new views::corewm::CompoundEventFilter;
+ // Pass ownership of the filter to the root_window.
+ root_window_->SetEventFilter(root_window_event_filter_);
+
+ input_method_filter_.reset(new views::corewm::InputMethodEventFilter(
+ root_window_->GetAcceleratedWidget()));
+ input_method_filter_->SetInputMethodPropertyInRootWindow(
+ root_window_.get());
+ root_window_event_filter_->AddHandler(input_method_filter_.get());
+
+ test_activation_client_.reset(
+ new aura::test::TestActivationClient(root_window_.get()));
+
+ capture_client_.reset(
+ new aura::client::DefaultCaptureClient(root_window_.get()));
+ }
+ return root_window_.get();
+}
+
+} // namespace content
diff --git a/content/shell/minimal_ash.h b/content/shell/shell_stacking_client_ash.h
index f3ec43b..de169c4 100644
--- a/content/shell/minimal_ash.h
+++ b/content/shell/shell_stacking_client_ash.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_SHELL_MINIMAL_ASH_H_
-#define CONTENT_SHELL_MINIMAL_ASH_H_
+#ifndef CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_
+#define CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -37,10 +37,10 @@ namespace content {
// Creates a minimal environment for running the shell. We can't pull in all of
// ash here, but we can create attach several of the same things we'd find in
// the ash parts of the code.
-class MinimalAsh : public aura::client::StackingClient {
+class ShellStackingClientAsh : public aura::client::StackingClient {
public:
- MinimalAsh();
- virtual ~MinimalAsh();
+ ShellStackingClientAsh();
+ virtual ~ShellStackingClientAsh();
// Overridden from client::StackingClient:
virtual aura::Window* GetDefaultParent(aura::Window* context,
@@ -58,9 +58,9 @@ class MinimalAsh : public aura::client::StackingClient {
scoped_ptr<aura::test::TestActivationClient> test_activation_client_;
scoped_ptr<aura::client::FocusClient> focus_client_;
- DISALLOW_COPY_AND_ASSIGN(MinimalAsh);
+ DISALLOW_COPY_AND_ASSIGN(ShellStackingClientAsh);
};
} // namespace content;
-#endif // CONTENT_SHELL_MINIMAL_ASH_H_
+#endif // CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_
diff --git a/ui/aura/client/stacking_client.cc b/ui/aura/client/stacking_client.cc
index 5d93d98..2bab521 100644
--- a/ui/aura/client/stacking_client.cc
+++ b/ui/aura/client/stacking_client.cc
@@ -16,22 +16,34 @@ namespace client {
DEFINE_WINDOW_PROPERTY_KEY(
StackingClient*, kRootWindowStackingClientKey, NULL);
-void SetStackingClient(Window* window, StackingClient* stacking_client) {
- DCHECK(window);
+void SetStackingClient(StackingClient* stacking_client) {
+ Env::GetInstance()->set_stacking_client(stacking_client);
+}
- RootWindow* root_window = window->GetRootWindow();
- DCHECK(root_window);
- root_window->SetProperty(kRootWindowStackingClientKey, stacking_client);
+StackingClient* GetStackingClient() {
+ return Env::GetInstance()->stacking_client();
+}
+
+void SetStackingClient(Window* window, StackingClient* stacking_client) {
+ if (window) {
+ RootWindow* root_window = window->GetRootWindow();
+ DCHECK(root_window);
+ root_window->SetProperty(kRootWindowStackingClientKey, stacking_client);
+ } else {
+ SetStackingClient(stacking_client);
+ }
}
StackingClient* GetStackingClient(Window* window) {
- DCHECK(window);
- RootWindow* root_window = window->GetRootWindow();
- DCHECK(root_window);
- StackingClient* root_window_stacking_client =
- root_window->GetProperty(kRootWindowStackingClientKey);
- DCHECK(root_window_stacking_client);
- return root_window_stacking_client;
+ if (window) {
+ RootWindow* root_window = window->GetRootWindow();
+ DCHECK(root_window);
+ StackingClient* root_window_stacking_client =
+ root_window->GetProperty(kRootWindowStackingClientKey);
+ if (root_window_stacking_client)
+ return root_window_stacking_client;
+ }
+ return GetStackingClient();
}
} // namespace client
diff --git a/ui/aura/client/stacking_client.h b/ui/aura/client/stacking_client.h
index 89f83eb..6c0aa59 100644
--- a/ui/aura/client/stacking_client.h
+++ b/ui/aura/client/stacking_client.h
@@ -35,6 +35,10 @@ class AURA_EXPORT StackingClient {
const gfx::Rect& bounds) = 0;
};
+// Set/Get the default stacking client.
+AURA_EXPORT void SetStackingClient(StackingClient* stacking_client);
+StackingClient* GetStackingClient();
+
// Set/Get a stacking client for a specific window. Setting the stacking client
// sets the stacking client on the window's RootWindow, not the window itself.
// Likewise getting obtains it from the window's RootWindow. If |window| is
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 4d27b50..b688e45 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -81,11 +81,11 @@ class DemoStackingClient : public aura::client::StackingClient {
public:
explicit DemoStackingClient(aura::RootWindow* root_window)
: root_window_(root_window) {
- aura::client::SetStackingClient(root_window_, this);
+ aura::client::SetStackingClient(this);
}
virtual ~DemoStackingClient() {
- aura::client::SetStackingClient(root_window_, NULL);
+ aura::client::SetStackingClient(NULL);
}
// Overridden from aura::client::StackingClient:
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index ecccaf1..bd094c0 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -26,7 +26,8 @@ Env* Env::instance_ = NULL;
Env::Env()
: mouse_button_flags_(0),
is_touch_down_(false),
- render_white_bg_(true) {
+ render_white_bg_(true),
+ stacking_client_(NULL) {
}
Env::~Env() {
diff --git a/ui/aura/env.h b/ui/aura/env.h
index ae4f1a6..24d7f4f 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "base/observer_list.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/client/stacking_client.h"
#include "ui/base/events/event_handler.h"
#include "ui/base/events/event_target.h"
#include "ui/gfx/point.h"
@@ -63,6 +64,11 @@ class AURA_EXPORT Env : public ui::EventTarget {
bool render_white_bg() const { return render_white_bg_; }
void set_render_white_bg(bool value) { render_white_bg_ = value; }
+ client::StackingClient* stacking_client() { return stacking_client_; }
+ void set_stacking_client(client::StackingClient* stacking_client) {
+ stacking_client_ = stacking_client;
+ }
+
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
@@ -96,6 +102,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
gfx::Point last_mouse_location_;
bool is_touch_down_;
bool render_white_bg_;
+ client::StackingClient* stacking_client_;
#if defined(USE_X11)
DeviceListUpdaterAuraX11 device_list_updater_aurax11_;
diff --git a/ui/aura/test/test_stacking_client.cc b/ui/aura/test/test_stacking_client.cc
index 746ad6c..6dd5dcf 100644
--- a/ui/aura/test/test_stacking_client.cc
+++ b/ui/aura/test/test_stacking_client.cc
@@ -11,11 +11,11 @@ namespace test {
TestStackingClient::TestStackingClient(RootWindow* root_window)
: root_window_(root_window) {
- client::SetStackingClient(root_window_, this);
+ client::SetStackingClient(this);
}
TestStackingClient::~TestStackingClient() {
- client::SetStackingClient(root_window_, NULL);
+ client::SetStackingClient(NULL);
}
Window* TestStackingClient::GetDefaultParent(Window* context,
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 5999290..9eec35c 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -320,7 +320,8 @@ void Window::SetExternalTexture(ui::Texture* texture) {
void Window::SetDefaultParentByRootWindow(RootWindow* root_window,
const gfx::Rect& bounds_in_screen) {
- DCHECK(root_window);
+ // TODO(erg): Enable this DCHECK once it is safe.
+ // DCHECK(root_window);
// Stacking clients are mandatory on RootWindow objects.
client::StackingClient* client = client::GetStackingClient(root_window);
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc
index 1714922a..e353b57 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.cc
+++ b/ui/views/examples/content_client/examples_browser_main_parts.cc
@@ -22,6 +22,7 @@
#include "ui/aura/env.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#include "ui/views/widget/native_widget_aura.h"
#endif
@@ -39,6 +40,8 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
browser_context_.reset(new content::ShellBrowserContext(false));
#if !defined(OS_CHROMEOS) && defined(USE_AURA)
+ stacking_client_.reset(new DesktopStackingClient);
+ aura::client::SetStackingClient(stacking_client_.get());
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen());
#endif
@@ -51,6 +54,7 @@ void ExamplesBrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
views_delegate_.reset();
#if defined(USE_AURA)
+ stacking_client_.reset();
aura::Env::DeleteInstance();
#endif
}
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.h b/ui/views/examples/content_client/examples_browser_main_parts.h
index 932ed72..ec76226 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.h
+++ b/ui/views/examples/content_client/examples_browser_main_parts.h
@@ -9,6 +9,12 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_main_parts.h"
+namespace aura {
+namespace client {
+class StackingClient;
+}
+}
+
namespace content {
class ShellBrowserContext;
struct MainFunctionParams;
@@ -38,6 +44,9 @@ class ExamplesBrowserMainParts : public content::BrowserMainParts {
scoped_ptr<content::ShellBrowserContext> browser_context_;
scoped_ptr<ViewsDelegate> views_delegate_;
+#if defined(USE_AURA)
+ scoped_ptr<aura::client::StackingClient> stacking_client_;
+#endif
DISALLOW_COPY_AND_ASSIGN(ExamplesBrowserMainParts);
};
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index d4a6806..8a100fd 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -372,6 +372,8 @@
'widget/desktop_aura/desktop_screen_win.cc',
'widget/desktop_aura/desktop_screen_win.h',
'widget/desktop_aura/desktop_screen_x11.cc',
+ 'widget/desktop_aura/desktop_stacking_client.cc',
+ 'widget/desktop_aura/desktop_stacking_client.h',
'widget/desktop_aura/x11_desktop_handler.cc',
'widget/desktop_aura/x11_desktop_handler.h',
'widget/desktop_aura/x11_desktop_window_move_client.cc',
diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.cc b/ui/views/widget/desktop_aura/desktop_stacking_client.cc
new file mode 100644
index 0000000..fc7ecb0
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_stacking_client.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
+
+#include "ui/aura/client/activation_client.h"
+#include "ui/aura/client/default_capture_client.h"
+#include "ui/aura/focus_manager.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/views/corewm/compound_event_filter.h"
+#include "ui/views/corewm/input_method_event_filter.h"
+#include "ui/views/widget/desktop_aura/desktop_activation_client.h"
+
+namespace views {
+
+DesktopStackingClient::DesktopStackingClient()
+ : window_event_filter_(NULL) {
+ aura::client::SetStackingClient(this);
+}
+
+DesktopStackingClient::~DesktopStackingClient() {
+ if (window_event_filter_)
+ window_event_filter_->RemoveHandler(input_method_filter_.get());
+
+ aura::client::SetStackingClient(NULL);
+}
+
+aura::Window* DesktopStackingClient::GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) {
+ if (!null_parent_.get())
+ CreateNULLParent();
+
+ return null_parent_.get();
+}
+
+void DesktopStackingClient::CreateNULLParent() {
+ focus_client_.reset(new aura::FocusManager);
+
+ null_parent_.reset(new aura::RootWindow(
+ aura::RootWindow::CreateParams(gfx::Rect(100, 100))));
+ null_parent_->Init();
+ aura::client::SetFocusClient(null_parent_.get(), focus_client_.get());
+
+ activation_client_.reset(new DesktopActivationClient(null_parent_.get()));
+
+ window_event_filter_ = new corewm::CompoundEventFilter;
+ null_parent_->SetEventFilter(window_event_filter_);
+
+ input_method_filter_.reset(new corewm::InputMethodEventFilter(
+ null_parent_->GetAcceleratedWidget()));
+ input_method_filter_->SetInputMethodPropertyInRootWindow(null_parent_.get());
+ window_event_filter_->AddHandler(input_method_filter_.get());
+
+ capture_client_.reset(
+ new aura::client::DefaultCaptureClient(null_parent_.get()));
+
+ // Hide the window so we don't attempt to draw to it and what not.
+ null_parent_->Hide();
+}
+
+} // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.h b/ui/views/widget/desktop_aura/desktop_stacking_client.h
new file mode 100644
index 0000000..56abc60
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_stacking_client.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
+#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
+
+#include "ui/aura/client/stacking_client.h"
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/views/views_export.h"
+
+namespace aura {
+class RootWindow;
+class Window;
+namespace client {
+class DefaultCaptureClient;
+class FocusClient;
+}
+}
+
+namespace views {
+class DesktopActivationClient;
+namespace corewm {
+class CompoundEventFilter;
+class InputMethodEventFilter;
+}
+
+// A stacking client for the desktop; always sets the default parent to the
+// RootWindow of the passed in Window.
+class VIEWS_EXPORT DesktopStackingClient : public aura::client::StackingClient {
+ public:
+ DesktopStackingClient();
+ virtual ~DesktopStackingClient();
+
+ // Overridden from aura::client::StackingClient:
+ virtual aura::Window* GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) OVERRIDE;
+
+ private:
+ void CreateNULLParent();
+
+ // Windows with NULL parents are parented to this.
+ scoped_ptr<aura::RootWindow> null_parent_;
+
+ // All the member variables below are necessary for the NULL parent root
+ // window to function.
+ scoped_ptr<aura::client::FocusClient> focus_client_;
+ // Depends on focus_manager_.
+ scoped_ptr<DesktopActivationClient> activation_client_;
+
+ scoped_ptr<corewm::InputMethodEventFilter> input_method_filter_;
+ corewm::CompoundEventFilter* window_event_filter_;
+
+ scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopStackingClient);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 1888378..5089485 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -136,8 +136,15 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
if (parent) {
parent->AddChild(window_);
} else {
- window_->SetDefaultParentByRootWindow(context->GetRootWindow(),
- window_bounds);
+ // TODO(erg): Once I've threaded context through chrome, uncomment this
+ // check, which currently fails on the NULL == NULL case.
+ //
+ // DCHECK_NE(params.GetParent(), params.context);
+
+ // TODO(erg): Remove this NULL check once we've made everything in views
+ // actually pass us a context.
+ aura::RootWindow* root_window = context ? context->GetRootWindow() : NULL;
+ window_->SetDefaultParentByRootWindow(root_window, window_bounds);
}
// Wait to set the bounds until we have a parent. That way we can know our
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 8194e5a..8a1923d 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -221,15 +221,8 @@ Widget::~Widget() {
// static
Widget* Widget::CreateWindow(WidgetDelegate* delegate) {
- return CreateWindowWithBounds(delegate, gfx::Rect());
-}
-
-// static
-Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
- const gfx::Rect& bounds) {
Widget* widget = new Widget;
Widget::InitParams params;
- params.bounds = bounds;
params.delegate = delegate;
params.top_level = true;
widget->Init(params);
@@ -237,6 +230,12 @@ Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
}
// static
+Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
+ const gfx::Rect& bounds) {
+ return CreateWindowWithParentAndBounds(delegate, NULL, bounds);
+}
+
+// static
Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate,
gfx::NativeWindow parent) {
return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect());