OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/host_desktop.h" | 5 #include "chrome/browser/ui/host_desktop.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "chrome/browser/ui/ash/ash_util.h" | 11 #include "chrome/browser/ui/ash/ash_util.h" |
12 #include "chrome/browser/ui/aura/active_desktop_monitor.h" | 12 #include "chrome/browser/ui/aura/active_desktop_monitor.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
15 | 15 |
16 #if defined(USE_ASH) | 16 #if defined(USE_ASH) |
17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
18 #endif | 18 #endif |
19 | 19 |
20 namespace chrome { | 20 namespace chrome { |
21 | 21 |
22 HostDesktopType GetHostDesktopTypeForNativeView(gfx::NativeView native_view) { | 22 ui::HostDesktopType GetHostDesktopTypeForNativeView( |
| 23 gfx::NativeView native_view) { |
23 #if defined(USE_ASH) | 24 #if defined(USE_ASH) |
24 // TODO(ananta) | 25 // TODO(ananta) |
25 // Once we've threaded creation context to wherever needed, we should remove | 26 // Once we've threaded creation context to wherever needed, we should remove |
26 // this check here. | 27 // this check here. |
27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
28 if (!native_view) | 29 if (!native_view) |
29 return GetActiveDesktop(); | 30 return GetActiveDesktop(); |
30 #endif | 31 #endif |
31 return IsNativeViewInAsh(native_view) ? | 32 return IsNativeViewInAsh(native_view) ? ui::HOST_DESKTOP_TYPE_ASH |
32 HOST_DESKTOP_TYPE_ASH : | 33 : ui::HOST_DESKTOP_TYPE_NATIVE; |
33 HOST_DESKTOP_TYPE_NATIVE; | |
34 #else | 34 #else |
35 return HOST_DESKTOP_TYPE_NATIVE; | 35 return ui::HOST_DESKTOP_TYPE_NATIVE; |
36 #endif | 36 #endif |
37 } | 37 } |
38 | 38 |
39 HostDesktopType GetHostDesktopTypeForNativeWindow( | 39 ui::HostDesktopType GetHostDesktopTypeForNativeWindow( |
40 gfx::NativeWindow native_window) { | 40 gfx::NativeWindow native_window) { |
41 #if defined(USE_ASH) | 41 #if defined(USE_ASH) |
42 // TODO(ananta) | 42 // TODO(ananta) |
43 // Once we've threaded creation context to wherever needed, we should remove | 43 // Once we've threaded creation context to wherever needed, we should remove |
44 // this check here. | 44 // this check here. |
45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
46 if (!native_window) | 46 if (!native_window) |
47 return GetActiveDesktop(); | 47 return GetActiveDesktop(); |
48 #endif | 48 #endif |
49 return IsNativeWindowInAsh(native_window) ? | 49 return IsNativeWindowInAsh(native_window) ? ui::HOST_DESKTOP_TYPE_ASH |
50 HOST_DESKTOP_TYPE_ASH : | 50 : ui::HOST_DESKTOP_TYPE_NATIVE; |
51 HOST_DESKTOP_TYPE_NATIVE; | |
52 #else | 51 #else |
53 return HOST_DESKTOP_TYPE_NATIVE; | 52 return ui::HOST_DESKTOP_TYPE_NATIVE; |
54 #endif | 53 #endif |
55 } | 54 } |
56 | 55 |
57 HostDesktopType GetActiveDesktop() { | 56 ui::HostDesktopType GetActiveDesktop() { |
58 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 57 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
59 // The Ash desktop is considered active if a non-desktop RootWindow was last | 58 // The Ash desktop is considered active if a non-desktop RootWindow was last |
60 // activated and the Ash desktop is still open. As it is, the Ash desktop | 59 // activated and the Ash desktop is still open. As it is, the Ash desktop |
61 // will be considered the last active if a user switches from metro Chrome to | 60 // will be considered the last active if a user switches from metro Chrome to |
62 // the Windows desktop but doesn't activate any Chrome windows there (e.g., | 61 // the Windows desktop but doesn't activate any Chrome windows there (e.g., |
63 // by clicking on one or otherwise giving one focus). Consider finding a way | 62 // by clicking on one or otherwise giving one focus). Consider finding a way |
64 // to detect that the Windows desktop has been activated so that the native | 63 // to detect that the Windows desktop has been activated so that the native |
65 // desktop can be considered active once the user switches to it if its | 64 // desktop can be considered active once the user switches to it if its |
66 // BrowserList isn't empty. | 65 // BrowserList isn't empty. |
67 if ((ActiveDesktopMonitor::GetLastActivatedDesktopType() == | 66 if ((ActiveDesktopMonitor::GetLastActivatedDesktopType() == |
68 chrome::HOST_DESKTOP_TYPE_ASH) && | 67 ui::HOST_DESKTOP_TYPE_ASH) && |
69 ash::Shell::HasInstance()) { | 68 ash::Shell::HasInstance()) { |
70 return HOST_DESKTOP_TYPE_ASH; | 69 return ui::HOST_DESKTOP_TYPE_ASH; |
71 } | 70 } |
72 #endif | 71 #endif |
73 return HOST_DESKTOP_TYPE_NATIVE; | 72 return ui::HOST_DESKTOP_TYPE_NATIVE; |
74 } | 73 } |
75 | 74 |
76 } // namespace chrome | 75 } // namespace chrome |
OLD | NEW |