OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <algorithm> | |
sky
2012/03/21 15:26:18
This should be between 7 and 8, eg:
#include "chr
| |
6 | |
5 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" | 7 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" |
6 | 8 |
7 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
10 #include "ash/shell_window_ids.h" | |
8 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
9 #include "ash/wm/partial_screenshot_view.h" | 12 #include "ash/wm/partial_screenshot_view.h" |
13 #include "ash/wm/window_modality_controller.h" | |
10 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
11 #include "base/command_line.h" | 15 #include "base/command_line.h" |
12 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" | 18 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" |
15 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" | 19 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" |
16 #include "chrome/browser/ui/views/ash/status_area_host_aura.h" | 20 #include "chrome/browser/ui/views/ash/status_area_host_aura.h" |
17 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
18 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
19 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
20 | 24 |
21 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
22 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 26 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
23 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 27 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
24 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" | 28 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
25 #endif | 29 #endif |
26 namespace { | 30 namespace { |
27 | 31 |
28 // Returns a list of Aura windows from a BrowserList, using either a | 32 // Returns if the given window should skip on the window cycle list or not. |
29 // const_iterator or const_reverse_iterator. | 33 bool ShouldSkipOnCycle(aura::Window* window) { |
sky
2012/03/21 15:26:18
The ActivationClient is ultimately the place that
| |
30 template<typename IT> | 34 // Skips if the window can't have a focus. |
31 std::vector<aura::Window*> GetBrowserWindows(IT begin, IT end) { | 35 if (!window->CanFocus()) |
32 std::vector<aura::Window*> windows; | 36 return true; |
33 for (IT it = begin; it != end; ++it) { | 37 |
34 Browser* browser = *it; | 38 // Skips if the window has a modal child. |
35 if (browser && browser->window()->GetNativeHandle()) | 39 aura::Window* modal_transient = ash::wm::GetWindowModalTransient(window); |
36 windows.push_back(browser->window()->GetNativeHandle()); | 40 if (modal_transient && modal_transient != window) |
37 } | 41 return true; |
38 return windows; | 42 |
43 // Otherwise, remains. | |
44 return false; | |
39 } | 45 } |
40 | 46 |
41 } // namespace | 47 } // namespace |
42 | 48 |
43 // static | 49 // static |
44 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; | 50 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; |
45 | 51 |
46 ChromeShellDelegate::ChromeShellDelegate() { | 52 ChromeShellDelegate::ChromeShellDelegate() { |
47 instance_ = this; | 53 instance_ = this; |
48 } | 54 } |
(...skipping 28 matching lines...) Expand all Loading... | |
77 } | 83 } |
78 | 84 |
79 ash::AppListViewDelegate* | 85 ash::AppListViewDelegate* |
80 ChromeShellDelegate::CreateAppListViewDelegate() { | 86 ChromeShellDelegate::CreateAppListViewDelegate() { |
81 // Shell will own the created delegate. | 87 // Shell will own the created delegate. |
82 return new AppListViewDelegate; | 88 return new AppListViewDelegate; |
83 } | 89 } |
84 | 90 |
85 std::vector<aura::Window*> ChromeShellDelegate::GetCycleWindowList( | 91 std::vector<aura::Window*> ChromeShellDelegate::GetCycleWindowList( |
86 CycleSource source) const { | 92 CycleSource source) const { |
87 // BrowserList maintains a list of browsers sorted by activity. | 93 aura::Window* default_container = ash::Shell::GetInstance()->GetContainer( |
88 return GetBrowserWindows(BrowserList::begin_last_active(), | 94 ash::internal::kShellWindowId_DefaultContainer); |
89 BrowserList::end_last_active()); | 95 std::vector<aura::Window*> windows = default_container->children(); |
96 // Removes unforcusable windows. | |
97 std::vector<aura::Window*>::iterator last = | |
98 std::remove_if( | |
sky
2012/03/21 15:26:18
indent this line 4.
| |
99 windows.begin(), | |
100 windows.end(), | |
101 ShouldSkipOnCycle); | |
102 windows.erase(last, windows.end()); | |
103 // Window cycling expects the topmost window at the front of the list. | |
104 std::reverse(windows.begin(), windows.end()); | |
105 return windows; | |
90 } | 106 } |
91 | 107 |
92 void ChromeShellDelegate::StartPartialScreenshot( | 108 void ChromeShellDelegate::StartPartialScreenshot( |
93 ash::ScreenshotDelegate* screenshot_delegate) { | 109 ash::ScreenshotDelegate* screenshot_delegate) { |
94 ash::PartialScreenshotView::StartPartialScreenshot(screenshot_delegate); | 110 ash::PartialScreenshotView::StartPartialScreenshot(screenshot_delegate); |
95 } | 111 } |
96 | 112 |
97 ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate( | 113 ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate( |
98 ash::LauncherModel* model) { | 114 ash::LauncherModel* model) { |
99 ChromeLauncherDelegate* delegate = new ChromeLauncherDelegate(NULL, model); | 115 ChromeLauncherDelegate* delegate = new ChromeLauncherDelegate(NULL, model); |
100 delegate->Init(); | 116 delegate->Init(); |
101 return delegate; | 117 return delegate; |
102 } | 118 } |
103 | 119 |
104 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate( | 120 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate( |
105 ash::SystemTray* tray) { | 121 ash::SystemTray* tray) { |
106 #if defined(OS_CHROMEOS) | 122 #if defined(OS_CHROMEOS) |
107 return chromeos::CreateSystemTrayDelegate(tray); | 123 return chromeos::CreateSystemTrayDelegate(tray); |
108 #else | 124 #else |
109 return NULL; | 125 return NULL; |
110 #endif | 126 #endif |
111 } | 127 } |
OLD | NEW |