diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 20:41:04 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 20:41:04 +0000 |
commit | 40fdd014c3a6847c472ce5da8e43ffeb99441b04 (patch) | |
tree | 38ce89ecd9edd61a21803369096e665571af3d0e | |
parent | 77d25d81a95dd1945d6a0edf5766cddf32849723 (diff) | |
download | chromium_src-40fdd014c3a6847c472ce5da8e43ffeb99441b04.zip chromium_src-40fdd014c3a6847c472ce5da8e43ffeb99441b04.tar.gz chromium_src-40fdd014c3a6847c472ce5da8e43ffeb99441b04.tar.bz2 |
Fixes crash when running aura on windows without ash.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11275053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164395 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/wm/window_util.cc | 12 | ||||
-rw-r--r-- | ash/wm/window_util.h | 3 | ||||
-rw-r--r-- | chrome/browser/fullscreen_ash.cc | 27 | ||||
-rw-r--r-- | chrome/browser/fullscreen_win.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/host_desktop.cc | 29 | ||||
-rw-r--r-- | chrome/browser/ui/host_desktop.h | 3 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
7 files changed, 54 insertions, 31 deletions
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index 55513af..b3a9b5d 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -52,6 +52,18 @@ aura::Window* GetActivatableWindow(aura::Window* window) { return internal::ActivationController::GetActivatableWindow(window, NULL); } +bool IsActiveWindowFullscreen() { + aura::Window* window = GetActiveWindow(); + while (window) { + if (window->GetProperty(aura::client::kShowStateKey) == + ui::SHOW_STATE_FULLSCREEN) { + return true; + } + window = window->parent(); + } + return false; +} + bool CanActivateWindow(aura::Window* window) { DCHECK(window); if (!window->GetRootWindow()) diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h index 849f587..081a40e 100644 --- a/ash/wm/window_util.h +++ b/ash/wm/window_util.h @@ -35,6 +35,9 @@ ASH_EXPORT bool CanActivateWindow(aura::Window* window); // this is probably what you're looking for. ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); +// Returns true if the active window or one its ancestors is fullscreen. +ASH_EXPORT bool IsActiveWindowFullscreen(); + // Returns true if |window| can be maximized. ASH_EXPORT bool CanMaximizeWindow(aura::Window* window); diff --git a/chrome/browser/fullscreen_ash.cc b/chrome/browser/fullscreen_ash.cc index a0951cb..e8dd0d2 100644 --- a/chrome/browser/fullscreen_ash.cc +++ b/chrome/browser/fullscreen_ash.cc @@ -4,34 +4,11 @@ #include "chrome/browser/fullscreen.h" -#include "ash/shell.h" -#include "base/logging.h" -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/base/ui_base_types.h" - -namespace { - -bool CheckIfFullscreenWindowExists(aura::Window* window) { - if (window->GetProperty(aura::client::kShowStateKey) == - ui::SHOW_STATE_FULLSCREEN) - return true; - aura::Window::Windows children = window->children(); - for (aura::Window::Windows::const_iterator i = children.begin(); - i != children.end(); - ++i) { - if (CheckIfFullscreenWindowExists(*i)) - return true; - } - return false; -} - -} // namespace +#include "ash/wm/window_util.h" bool IsFullScreenMode() { // This is used only by notification_ui_manager.cc. On aura, notification // will be managed in panel. This is temporary to get certain feature running // until we implement it for aura. - return CheckIfFullscreenWindowExists(ash::Shell::GetPrimaryRootWindow()); + return ash::wm::IsActiveWindowFullscreen(); } diff --git a/chrome/browser/fullscreen_win.cc b/chrome/browser/fullscreen_win.cc index 7546b2d..4c3da9f 100644 --- a/chrome/browser/fullscreen_win.cc +++ b/chrome/browser/fullscreen_win.cc @@ -10,6 +10,11 @@ #include "base/logging.h" #include "base/win/windows_version.h" +#if defined(USE_ASH) +#include "ash/wm/window_util.h" +#include "chrome/browser/ui/host_desktop.h" +#endif + static bool IsPlatformFullScreenMode() { // SHQueryUserNotificationState is only available for Vista and above. #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_VISTA) @@ -96,6 +101,10 @@ static bool IsFullScreenConsoleMode() { } bool IsFullScreenMode() { +#if defined(USE_ASH) + if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) + return ash::wm::IsActiveWindowFullscreen(); +#endif return IsPlatformFullScreenMode() || IsFullScreenWindowMode() || IsFullScreenConsoleMode(); diff --git a/chrome/browser/ui/host_desktop.cc b/chrome/browser/ui/host_desktop.cc index 0d2e1c8..e2c34bb 100644 --- a/chrome/browser/ui/host_desktop.cc +++ b/chrome/browser/ui/host_desktop.cc @@ -4,8 +4,17 @@ #include "chrome/browser/ui/host_desktop.h" -#include "chrome/browser/ui/ash/ash_util.h" -#include "chrome/browser/ui/browser_list_impl.h" +#if defined(OS_WIN) +#include <windows.h> +#endif + +#include "chrome/browser/ui/ash/ash_util.h" +#include "chrome/browser/ui/browser_list_impl.h" + +#if defined(OS_WIN) +#include "ash/shell.h" +#include "ui/aura/root_window.h" +#endif namespace chrome { @@ -69,4 +78,20 @@ HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser) { return HOST_DESKTOP_TYPE_NATIVE; } +HostDesktopType GetActiveDesktop() { +#if defined(OS_WIN) && defined(USE_ASH) + if (ash::Shell::HasInstance()) { + HWND active_window = GetActiveWindow(); + typedef ash::Shell::RootWindowList RootWindowList; + RootWindowList roots(ash::Shell::GetAllRootWindows()); + for (RootWindowList::const_iterator i = roots.begin(); i != roots.end(); + ++i) { + if ((*i)->GetAcceleratedWidget() == active_window) + return HOST_DESKTOP_TYPE_ASH; + } + } +#endif + return HOST_DESKTOP_TYPE_NATIVE; +} + } // namespace chrome diff --git a/chrome/browser/ui/host_desktop.h b/chrome/browser/ui/host_desktop.h index 8f00bcb..b0f188b 100644 --- a/chrome/browser/ui/host_desktop.h +++ b/chrome/browser/ui/host_desktop.h @@ -47,10 +47,7 @@ HostDesktopType GetHostDesktopTypeForNativeWindow( gfx::NativeWindow native_window); HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser); -/* -TODO(beng): implement utilities as needed, e.g.: HostDesktopType GetActiveDesktop(); -*/ } // namespace chrome diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b86e5d9..8bed5f0 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2411,7 +2411,7 @@ ['OS=="win"', { 'sources/': [ ['exclude', '^browser/background/background_mode_manager_aura.cc'], - ['exclude', '^browser/fullscreen_win.cc'], + ['exclude', '^browser/fullscreen_ash.cc'], ['exclude', '^browser/lifetime/application_lifetime_win.cc'], ], 'dependencies': [ |