diff options
Diffstat (limited to 'chrome/browser')
12 files changed, 101 insertions, 44 deletions
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 |