diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 00:48:31 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 00:48:31 +0000 |
commit | c95ec93e47364e0386e1a1ac09b353e6e2c83b45 (patch) | |
tree | 1bdd91a44ddced8a6fb56f849a1aadc5e3fcda56 /ui | |
parent | ff3761a21bdd9985d559d45e50fbaecf69df16ab (diff) | |
download | chromium_src-c95ec93e47364e0386e1a1ac09b353e6e2c83b45.zip chromium_src-c95ec93e47364e0386e1a1ac09b353e6e2c83b45.tar.gz chromium_src-c95ec93e47364e0386e1a1ac09b353e6e2c83b45.tar.bz2 |
Recommitting Aura/ash split: Remove hacks and get chrome linking without ash.
This changes TestViewsDelegate::CreateNativeWidgetHelper to always return NULL, and for views_examples_exe to use its own subclass that create the desktop implementation.
For the first time now, you can do:
> build/gyp_chromium -Duse_aura=1 -Duse_ash=0
And get a running chrome. It has lots of issues, especially related to
window placement, tab handling, etc, but it pops up and renders web content.
Also consolidates most of the desktop behavior into its own class.
Also makes views_examples_exe work again. Several of the hacks are no longer
needed after Ben's refactoring to support WebView.
BUG=116458,119759
TEST=none
First Review URL: http://codereview.chromium.org/10081022
Review URL: http://codereview.chromium.org/10083058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/aura.gyp | 2 | ||||
-rw-r--r-- | ui/aura/desktop/desktop_stacking_client.cc | 24 | ||||
-rw-r--r-- | ui/aura/desktop/desktop_stacking_client.h | 32 | ||||
-rw-r--r-- | ui/views/examples/content_client/examples_browser_main_parts.cc | 45 | ||||
-rw-r--r-- | ui/views/examples/content_client/examples_browser_main_parts.h | 8 | ||||
-rw-r--r-- | ui/views/test/test_views_delegate.cc | 7 | ||||
-rw-r--r-- | ui/views/test/test_views_delegate.h | 5 | ||||
-rw-r--r-- | ui/views/views.gyp | 3 | ||||
-rw-r--r-- | ui/views/views_delegate.h | 12 | ||||
-rw-r--r-- | ui/views/widget/desktop_native_widget_helper_aura.cc | 78 | ||||
-rw-r--r-- | ui/views/widget/desktop_native_widget_helper_aura.h | 54 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 70 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 16 | ||||
-rw-r--r-- | ui/views/widget/native_widget_helper_aura.h | 38 |
14 files changed, 297 insertions, 97 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index aa46a9f..48a8122 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -57,6 +57,8 @@ 'desktop/desktop_dispatcher_client.h', 'desktop/desktop_root_window_event_filter.cc', 'desktop/desktop_root_window_event_filter.h', + 'desktop/desktop_stacking_client.cc', + 'desktop/desktop_stacking_client.h', 'dispatcher_linux.cc', 'dispatcher_linux.h', 'dispatcher_win.cc', diff --git a/ui/aura/desktop/desktop_stacking_client.cc b/ui/aura/desktop/desktop_stacking_client.cc new file mode 100644 index 0000000..cbe6c27 --- /dev/null +++ b/ui/aura/desktop/desktop_stacking_client.cc @@ -0,0 +1,24 @@ +// 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/aura/desktop/desktop_stacking_client.h" + +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" + +namespace aura { + +DesktopStackingClient::DesktopStackingClient() { + aura::client::SetStackingClient(this); +} + +DesktopStackingClient::~DesktopStackingClient() { + aura::client::SetStackingClient(NULL); +} + +Window* DesktopStackingClient::GetDefaultParent(Window* window) { + return window->GetRootWindow(); +} + +} // namespace aura diff --git a/ui/aura/desktop/desktop_stacking_client.h b/ui/aura/desktop/desktop_stacking_client.h new file mode 100644 index 0000000..34b8a67 --- /dev/null +++ b/ui/aura/desktop/desktop_stacking_client.h @@ -0,0 +1,32 @@ +// 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_AURA_DESKTOP_DESKTOP_STACKING_CLIENT_H_ +#define UI_AURA_DESKTOP_DESKTOP_STACKING_CLIENT_H_ + +#include "ui/aura/client/stacking_client.h" + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/aura/aura_export.h" + +namespace aura { +class Window; + +// A stacking client for the desktop; always sets the default parent to the +// RootWindow of the passed in Window. +class AURA_EXPORT DesktopStackingClient : public client::StackingClient { + public: + DesktopStackingClient(); + virtual ~DesktopStackingClient(); + + // Overridden from client::StackingClient: + virtual Window* GetDefaultParent(Window* window) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(DesktopStackingClient); +}; + +} // namespace aura + +#endif // UI_AURA_DESKTOP_DESKTOP_STACKING_CLIENT_H_ 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 62d3686..e1233e3 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.cc +++ b/ui/views/examples/content_client/examples_browser_main_parts.cc @@ -23,39 +23,28 @@ #include "ui/views/focus/accelerator_handler.h" #if defined(USE_AURA) -#include "ui/aura/client/stacking_client.h" +#if !defined(USE_ASH) +#include "ui/views/widget/desktop_native_widget_helper_aura.h" +#endif +#include "ui/aura/desktop/desktop_stacking_client.h" #include "ui/aura/env.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/gfx/compositor/compositor.h" -#include "ui/gfx/compositor/test/compositor_test_support.h" #include "ui/views/widget/native_widget_aura.h" #endif namespace views { namespace examples { + namespace { -#if defined(USE_AURA) -class RootWindowStackingClient : public aura::client::StackingClient { +class ExamplesViewsDelegate : public views::TestViewsDelegate { public: - explicit RootWindowStackingClient() { - aura::client::SetStackingClient(this); - } - - virtual ~RootWindowStackingClient() { - aura::client::SetStackingClient(NULL); +#if defined(USE_AURA) && !defined(USE_ASH) + virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( + views::NativeWidgetAura* native_widget) OVERRIDE { + return new views::DesktopNativeWidgetHelperAura(native_widget); } - - // Overridden from aura::client::StackingClient: - virtual aura::Window* GetDefaultParent(aura::Window* window) OVERRIDE { - return window->GetRootWindow(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(RootWindowStackingClient); +#endif // !USE_ASH }; -#endif -} +} // namespace ExamplesBrowserMainParts::ExamplesBrowserMainParts( const content::MainFunctionParams& parameters) @@ -79,12 +68,9 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() { browser_context_.reset(new content::ShellBrowserContext); #if defined(USE_AURA) - // TURN ON THE HAX. - views::NativeWidgetAura::set_aura_desktop_hax(); - ui::CompositorTestSupport::Initialize(); - root_window_stacking_client_.reset(new RootWindowStackingClient); + stacking_client_.reset(new aura::DesktopStackingClient); #endif - views_delegate_.reset(new views::TestViewsDelegate); + views_delegate_.reset(new ExamplesViewsDelegate); views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE, browser_context_.get()); @@ -96,9 +82,8 @@ void ExamplesBrowserMainParts::PostMainMessageLoopRun() { browser_context_.reset(); views_delegate_.reset(); #if defined(USE_AURA) - root_window_stacking_client_.reset(); + stacking_client_.reset(); aura::Env::DeleteInstance(); - ui::CompositorTestSupport::Terminate(); #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 bdbcbc9..ea4e959 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.h +++ b/ui/views/examples/content_client/examples_browser_main_parts.h @@ -10,6 +10,12 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_main_parts.h" +namespace aura { +namespace client { +class StackingClient; +} +} + namespace base { class Thread; } @@ -63,7 +69,7 @@ class ExamplesBrowserMainParts : public content::BrowserMainParts { content::ShellDevToolsDelegate* devtools_delegate_; scoped_ptr<views::ViewsDelegate> views_delegate_; #if defined(USE_AURA) - scoped_ptr<aura::client::StackingClient> root_window_stacking_client_; + scoped_ptr<aura::client::StackingClient> stacking_client_; #endif DISALLOW_COPY_AND_ASSIGN(ExamplesBrowserMainParts); diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc index 6fa6bb7..a8fe511 100644 --- a/ui/views/test/test_views_delegate.cc +++ b/ui/views/test/test_views_delegate.cc @@ -57,4 +57,11 @@ int TestViewsDelegate::GetDispositionForEvent(int event_flags) { return 0; } +#if defined(USE_AURA) +views::NativeWidgetHelperAura* TestViewsDelegate::CreateNativeWidgetHelper( + views::NativeWidgetAura* native_widget) { + return NULL; +} +#endif + } // namespace views diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h index 99976a2..1ea5cdf 100644 --- a/ui/views/test/test_views_delegate.h +++ b/ui/views/test/test_views_delegate.h @@ -59,6 +59,11 @@ class TestViewsDelegate : public ViewsDelegate { virtual int GetDispositionForEvent(int event_flags) OVERRIDE; +#if defined(USE_AURA) + virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( + views::NativeWidgetAura* native_widget) OVERRIDE; +#endif + private: mutable scoped_ptr<ui::Clipboard> clipboard_; bool use_transparent_windows_; diff --git a/ui/views/views.gyp b/ui/views/views.gyp index d30c4a6..f28e810 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -316,6 +316,8 @@ 'widget/child_window_message_processor.h', 'widget/default_theme_provider.cc', 'widget/default_theme_provider.h', + 'widget/desktop_native_widget_helper_aura.cc', + 'widget/desktop_native_widget_helper_aura.h', 'widget/drop_helper.cc', 'widget/drop_helper.h', 'widget/drop_target_win.cc', @@ -334,6 +336,7 @@ 'widget/native_widget_aura.cc', 'widget/native_widget_aura.h', 'widget/native_widget_delegate.h', + 'widget/native_widget_helper_aura.h', 'widget/native_widget_private.h', 'widget/native_widget_win.cc', 'widget/native_widget_win.h', diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h index af9c665..d1fc739 100644 --- a/ui/views/views_delegate.h +++ b/ui/views/views_delegate.h @@ -31,6 +31,11 @@ class NonClientFrameView; class View; class Widget; +#if defined(USE_AURA) +class NativeWidgetAura; +class NativeWidgetHelperAura; +#endif + // ViewsDelegate is an interface implemented by an object using the views // framework. It is used to obtain various high level application utilities // and perform some actions such as window placement saving. @@ -96,6 +101,13 @@ class VIEWS_EXPORT ViewsDelegate { // Converts views::Event::flags to a WindowOpenDisposition. virtual int GetDispositionForEvent(int event_flags) = 0; + +#if defined(USE_AURA) + // Creates an object that implements desktop integration behavior. Returned + // object is owned by the NativeWidgetAura passed in. May return NULL. + virtual NativeWidgetHelperAura* CreateNativeWidgetHelper( + NativeWidgetAura* native_widget) = 0; +#endif }; } // namespace views diff --git a/ui/views/widget/desktop_native_widget_helper_aura.cc b/ui/views/widget/desktop_native_widget_helper_aura.cc new file mode 100644 index 0000000..d05c062 --- /dev/null +++ b/ui/views/widget/desktop_native_widget_helper_aura.cc @@ -0,0 +1,78 @@ +// 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_native_widget_helper_aura.h" + +#include "ui/views/widget/native_widget_aura.h" +#include "ui/aura/root_window.h" +#include "ui/aura/desktop/desktop_activation_client.h" +#include "ui/aura/desktop/desktop_dispatcher_client.h" +#include "ui/aura/desktop/desktop_root_window_event_filter.h" +#include "ui/aura/client/dispatcher_client.h" + +namespace views { + +DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( + NativeWidgetAura* widget) + : widget_(widget) { +} + +DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() {} + +void DesktopNativeWidgetHelperAura::PreInitialize( + const Widget::InitParams& params) { + gfx::Rect bounds = params.bounds; + if (bounds.IsEmpty()) { + // We must pass some non-zero value when we initialize a RootWindow. This + // will probably be SetBounds()ed soon. + bounds.set_size(gfx::Size(100, 100)); + } + root_window_.reset(new aura::RootWindow(bounds)); + root_window_->SetEventFilter( + new aura::DesktopRootWindowEventFilter(root_window_.get())); + root_window_->AddRootWindowObserver(this); + + aura::client::SetActivationClient( + root_window_.get(), + new aura::DesktopActivationClient(root_window_.get())); + aura::client::SetDispatcherClient(root_window_.get(), + new aura::DesktopDispatcherClient); +} + +void DesktopNativeWidgetHelperAura::ShowRootWindow() { + if (root_window_.get()) + root_window_->ShowRootWindow(); +} + +aura::RootWindow* DesktopNativeWidgetHelperAura::GetRootWindow() { + return root_window_.get(); +} + +gfx::Rect DesktopNativeWidgetHelperAura::ModifyAndSetBounds(gfx::Rect bounds) { + if (root_window_.get() && !bounds.IsEmpty()) { + root_window_->SetHostBounds(bounds); + bounds.set_x(0); + bounds.set_y(0); + } + + return bounds; +} + +//////////////////////////////////////////////////////////////////////////////// +// DesktopNativeWidgetHelperAura, aura::RootWindowObserver implementation: + +void DesktopNativeWidgetHelperAura::OnRootWindowResized( + const aura::RootWindow* root, + const gfx::Size& old_size) { + DCHECK_EQ(root, root_window_.get()); + widget_->SetBounds(gfx::Rect(root->GetHostSize())); +} + +void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( + const aura::RootWindow* root) { + DCHECK_EQ(root, root_window_.get()); + widget_->GetWidget()->Close(); +} + +} // namespace views diff --git a/ui/views/widget/desktop_native_widget_helper_aura.h b/ui/views/widget/desktop_native_widget_helper_aura.h new file mode 100644 index 0000000..72c169d --- /dev/null +++ b/ui/views/widget/desktop_native_widget_helper_aura.h @@ -0,0 +1,54 @@ +// 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_NATIVE_WIDGET_HELPER_AURA_H_ +#define UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_HELPER_AURA_H_ +#pragma once + +#include "ui/aura/root_window_observer.h" +#include "ui/gfx/rect.h" +#include "ui/views/views_export.h" +#include "ui/views/widget/native_widget_helper_aura.h" +#include "ui/views/widget/widget.h" + +namespace aura { +class RootWindow; +} + +namespace views { +class NativeWidgetAura; + +// Implementation of non-Ash desktop integration code, allowing +// NativeWidgetAuras to work in a traditional desktop environment. +class VIEWS_EXPORT DesktopNativeWidgetHelperAura + : public NativeWidgetHelperAura, + public aura::RootWindowObserver { + public: + explicit DesktopNativeWidgetHelperAura(NativeWidgetAura* widget); + virtual ~DesktopNativeWidgetHelperAura(); + + // Overridden from aura::NativeWidgetHelperAura: + virtual void PreInitialize(const Widget::InitParams& params) OVERRIDE; + virtual void ShowRootWindow() OVERRIDE; + virtual aura::RootWindow* GetRootWindow() OVERRIDE; + virtual gfx::Rect ModifyAndSetBounds(gfx::Rect bounds) OVERRIDE; + + // Overridden from aura::RootWindowObserver: + virtual void OnRootWindowResized(const aura::RootWindow* root, + const gfx::Size& old_size) OVERRIDE; + virtual void OnRootWindowHostClosed(const aura::RootWindow* root) OVERRIDE; + + private: + // A weak pointer back to our owning widget. + NativeWidgetAura* widget_; + + // Optionally, a RootWindow that we attach ourselves to. + scoped_ptr<aura::RootWindow> root_window_; + + DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetHelperAura); +}; + +} // namespace views + +#endif // UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_HELPER_AURA_H_ diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 1f8e15e..202caa8 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -9,13 +9,9 @@ #include "third_party/skia/include/core/SkRegion.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" -#include "ui/aura/client/dispatcher_client.h" #include "ui/aura/client/drag_drop_client.h" #include "ui/aura/client/window_move_client.h" #include "ui/aura/client/window_types.h" -#include "ui/aura/desktop/desktop_activation_client.h" -#include "ui/aura/desktop/desktop_dispatcher_client.h" -#include "ui/aura/desktop/desktop_root_window_event_filter.h" #include "ui/aura/env.h" #include "ui/aura/event.h" #include "ui/aura/root_window.h" @@ -29,8 +25,10 @@ #include "ui/gfx/screen.h" #include "ui/views/drag_utils.h" #include "ui/views/ime/input_method_bridge.h" +#include "ui/views/views_delegate.h" #include "ui/views/widget/drop_helper.h" #include "ui/views/widget/native_widget_delegate.h" +#include "ui/views/widget/native_widget_helper_aura.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/tooltip_manager_aura.h" #include "ui/views/widget/widget_delegate.h" @@ -48,8 +46,6 @@ namespace views { -bool NativeWidgetAura::g_aura_desktop_hax = false; - namespace { aura::client::WindowType GetAuraWindowTypeForWidgetType( @@ -139,7 +135,10 @@ class NativeWidgetAura::ActiveWindowObserver : public aura::WindowObserver { NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) : delegate_(delegate), - root_window_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST(desktop_helper_( + ViewsDelegate::views_delegate ? + ViewsDelegate::views_delegate->CreateNativeWidgetHelper(this) : + NULL)), ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), @@ -173,25 +172,9 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() { void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { ownership_ = params.ownership; - // TODO(erg): What kind of windows do we want to have their own root windows? - if (g_aura_desktop_hax) { - gfx::Rect bounds = params.bounds; - if (bounds.IsEmpty()) { - // We must pass some non-zero value when we initialize a RootWindow. This - // will probably be SetBounds()ed soon. - bounds.set_size(gfx::Size(100, 100)); - } - root_window_.reset(new aura::RootWindow(bounds)); - root_window_->SetEventFilter( - new aura::DesktopRootWindowEventFilter(root_window_.get())); - root_window_->AddRootWindowObserver(this); - - aura::client::SetActivationClient( - root_window_.get(), - new aura::DesktopActivationClient(root_window_.get())); - aura::client::SetDispatcherClient(root_window_.get(), - new aura::DesktopDispatcherClient); - } + + if (desktop_helper_.get()) + desktop_helper_->PreInitialize(params); window_->set_user_data(this); window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); @@ -204,8 +187,8 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { window_->Show(); delegate_->OnNativeWidgetCreated(); - if (root_window_.get()) { - window_->SetParent(root_window_.get()); + if (desktop_helper_.get() && desktop_helper_->GetRootWindow()) { + window_->SetParent(desktop_helper_->GetRootWindow()); } else if (params.child) { window_->SetParent(params.GetParent()); } else { @@ -220,7 +203,7 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { // client per root window instead. For now, we hax our way around this by // forcing the parent to be the root window instead of passing NULL as // the parent which will dispatch to the stacking client. - if (g_aura_desktop_hax) + if (desktop_helper_.get()) parent = parent->GetRootWindow(); else parent = NULL; @@ -253,8 +236,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { aura::client::SetActivationDelegate(window_, this); - if (root_window_.get()) - root_window_->ShowRootWindow(); + // TODO(erg): Move this somewhere else? + if (desktop_helper_.get()) + desktop_helper_->ShowRootWindow(); } NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { @@ -471,11 +455,8 @@ gfx::Rect NativeWidgetAura::GetRestoredBounds() const { void NativeWidgetAura::SetBounds(const gfx::Rect& in_bounds) { gfx::Rect bounds = in_bounds; - if (root_window_.get() && !bounds.IsEmpty()) { - root_window_->SetHostBounds(bounds); - bounds.set_x(0); - bounds.set_y(0); - } + if (desktop_helper_.get()) + bounds = desktop_helper_->ModifyAndSetBounds(bounds); #if defined(ENABLE_DIP) bounds = ConvertRectToMonitor(bounds); #endif @@ -873,23 +854,6 @@ void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { } //////////////////////////////////////////////////////////////////////////////// -// NativeWidgetAura, aura::RootWindowObserver implementation: - -void NativeWidgetAura::OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) { - // This case can only happen if we have our own aura::RootWindow*. When that - // happens, our main window should be at the origin and sized to the - // RootWindow. - DCHECK_EQ(root, root_window_.get()); - SetBounds(gfx::Rect(root->GetHostSize())); -} - -void NativeWidgetAura::OnRootWindowHostClosed(const aura::RootWindow* root) { - DCHECK_EQ(root, root_window_.get()); - GetWidget()->Close(); -} - -//////////////////////////////////////////////////////////////////////////////// // NativeWidgetAura, aura::ActivationDelegate implementation: bool NativeWidgetAura::ShouldActivate(const aura::Event* event) { diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index d09a77d..388da85 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -10,7 +10,6 @@ #include "base/memory/weak_ptr.h" #include "ui/aura/client/activation_delegate.h" #include "ui/aura/client/drag_drop_delegate.h" -#include "ui/aura/root_window_observer.h" #include "ui/aura/window_delegate.h" #include "ui/base/events.h" #include "ui/views/views_export.h" @@ -18,7 +17,6 @@ namespace aura { class Monitor; -class RootWindow; class Window; } namespace gfx { @@ -28,19 +26,17 @@ class Font; namespace views { class DropHelper; +class NativeWidgetHelperAura; class TooltipManagerAura; class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, public aura::WindowDelegate, - public aura::RootWindowObserver, public aura::client::ActivationDelegate, public aura::client::DragDropDelegate { public: explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate); virtual ~NativeWidgetAura(); - static void set_aura_desktop_hax() { g_aura_desktop_hax = true; } - // TODO(beng): Find a better place for this, and the similar method on // NativeWidgetWin. static gfx::Font GetWindowTitleFont(); @@ -152,11 +148,6 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void OnWindowDestroyed() OVERRIDE; virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE; - // Overridden from aura::RootWindowObserver: - virtual void OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) OVERRIDE; - virtual void OnRootWindowHostClosed(const aura::RootWindow* root) OVERRIDE; - // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate(const aura::Event* event) OVERRIDE; virtual void OnActivated() OVERRIDE; @@ -191,7 +182,8 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, internal::NativeWidgetDelegate* delegate_; - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<NativeWidgetHelperAura> desktop_helper_; + aura::Window* window_; // See class documentation for Widget in widget.h for a note about ownership. @@ -216,8 +208,6 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, scoped_ptr<DropHelper> drop_helper_; int last_drop_operation_; - static bool g_aura_desktop_hax; - DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura); }; diff --git a/ui/views/widget/native_widget_helper_aura.h b/ui/views/widget/native_widget_helper_aura.h new file mode 100644 index 0000000..4d73932 --- /dev/null +++ b/ui/views/widget/native_widget_helper_aura.h @@ -0,0 +1,38 @@ +// 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_NATIVE_WIDGET_HELPER_AURA_H_ +#define UI_VIEWS_WIDGET_NATIVE_WIDGET_HELPER_AURA_H_ +#pragma once + +#include "ui/views/views_export.h" +#include "ui/views/widget/widget.h" + +namespace views { + +// A special delegate that encapsulates all logic for use of NativeWidgetAura +// on the desktop. +class VIEWS_EXPORT NativeWidgetHelperAura { + public: + virtual ~NativeWidgetHelperAura() {} + + // Called at the start of InitNativeWidget; determines whether we should + // set up a root_window_ for this widget. + virtual void PreInitialize(const Widget::InitParams& params) = 0; + + // Passes through a message to show the RootWindow, if it exists. + virtual void ShowRootWindow() = 0; + + // If we own a RootWindow, return it. Otherwise NULL. + virtual aura::RootWindow* GetRootWindow() = 0; + + // If this NativeWidgetAura has its own RootWindow, sets the position at the + // |root_window_|, and returns modified bounds to set the origin to + // zero. Otherwise, pass through in_bounds. + virtual gfx::Rect ModifyAndSetBounds(gfx::Rect bounds) = 0; +}; + +} // namespace views + +#endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_HELPER_AURA_H_ |