| 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 "chrome/browser/ui/views/ash/chrome_shell_delegate.h" | 5 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 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" |
| 10 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 11 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 12 #include "chrome/browser/chromeos/login/screen_locker.h" | 15 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" | 19 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" |
| 17 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" | 20 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" |
| 18 #include "chrome/browser/ui/views/ash/status_area_host_aura.h" | 21 #include "chrome/browser/ui/views/ash/status_area_host_aura.h" |
| 19 #include "chrome/browser/ui/views/ash/window_positioner.h" | 22 #include "chrome/browser/ui/views/ash/window_positioner.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_view.h" | 23 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 23 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 24 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 25 | 28 |
| 26 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 27 #include "base/chromeos/chromeos_version.h" | 30 #include "base/chromeos/chromeos_version.h" |
| 28 #include "chrome/browser/chromeos/background/desktop_background_observer.h" | 31 #include "chrome/browser/chromeos/background/desktop_background_observer.h" |
| 29 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 32 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 30 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 33 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 31 #include "chrome/browser/chromeos/login/user_manager.h" | 34 #include "chrome/browser/chromeos/login/user_manager.h" |
| 32 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" | 35 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
| 33 #endif | 36 #endif |
| 34 namespace { | |
| 35 | |
| 36 // Returns a list of Aura windows from a BrowserList, using either a | |
| 37 // const_iterator or const_reverse_iterator. | |
| 38 template<typename IT> | |
| 39 std::vector<aura::Window*> GetBrowserWindows(IT begin, IT end) { | |
| 40 std::vector<aura::Window*> windows; | |
| 41 for (IT it = begin; it != end; ++it) { | |
| 42 Browser* browser = *it; | |
| 43 if (browser && browser->window()->GetNativeHandle()) | |
| 44 windows.push_back(browser->window()->GetNativeHandle()); | |
| 45 } | |
| 46 return windows; | |
| 47 } | |
| 48 | |
| 49 } // namespace | |
| 50 | 37 |
| 51 // static | 38 // static |
| 52 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; | 39 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; |
| 53 | 40 |
| 54 ChromeShellDelegate::ChromeShellDelegate() | 41 ChromeShellDelegate::ChromeShellDelegate() |
| 55 : window_positioner_(new WindowPositioner()) { | 42 : window_positioner_(new WindowPositioner()) { |
| 56 instance_ = this; | 43 instance_ = this; |
| 57 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 58 registrar_.Add( | 45 registrar_.Add( |
| 59 this, | 46 this, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 113 } |
| 127 | 114 |
| 128 ash::AppListViewDelegate* | 115 ash::AppListViewDelegate* |
| 129 ChromeShellDelegate::CreateAppListViewDelegate() { | 116 ChromeShellDelegate::CreateAppListViewDelegate() { |
| 130 // Shell will own the created delegate. | 117 // Shell will own the created delegate. |
| 131 return new AppListViewDelegate; | 118 return new AppListViewDelegate; |
| 132 } | 119 } |
| 133 | 120 |
| 134 std::vector<aura::Window*> ChromeShellDelegate::GetCycleWindowList( | 121 std::vector<aura::Window*> ChromeShellDelegate::GetCycleWindowList( |
| 135 CycleSource source) const { | 122 CycleSource source) const { |
| 136 // BrowserList maintains a list of browsers sorted by activity. | 123 aura::Window* default_container = ash::Shell::GetInstance()->GetContainer( |
| 137 return GetBrowserWindows(BrowserList::begin_last_active(), | 124 ash::internal::kShellWindowId_DefaultContainer); |
| 138 BrowserList::end_last_active()); | 125 std::vector<aura::Window*> windows = default_container->children(); |
| 126 // Removes unforcusable windows. |
| 127 std::vector<aura::Window*>::iterator last = |
| 128 std::remove_if( |
| 129 windows.begin(), |
| 130 windows.end(), |
| 131 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
| 132 windows.erase(last, windows.end()); |
| 133 // Window cycling expects the topmost window at the front of the list. |
| 134 std::reverse(windows.begin(), windows.end()); |
| 135 return windows; |
| 139 } | 136 } |
| 140 | 137 |
| 141 void ChromeShellDelegate::StartPartialScreenshot( | 138 void ChromeShellDelegate::StartPartialScreenshot( |
| 142 ash::ScreenshotDelegate* screenshot_delegate) { | 139 ash::ScreenshotDelegate* screenshot_delegate) { |
| 143 ash::PartialScreenshotView::StartPartialScreenshot(screenshot_delegate); | 140 ash::PartialScreenshotView::StartPartialScreenshot(screenshot_delegate); |
| 144 } | 141 } |
| 145 | 142 |
| 146 ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate( | 143 ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate( |
| 147 ash::LauncherModel* model) { | 144 ash::LauncherModel* model) { |
| 148 ChromeLauncherDelegate* delegate = new ChromeLauncherDelegate(NULL, model); | 145 ChromeLauncherDelegate* delegate = new ChromeLauncherDelegate(NULL, model); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 176 ash::Shell::GetInstance()->CreateLauncher(); | 173 ash::Shell::GetInstance()->CreateLauncher(); |
| 177 break; | 174 break; |
| 178 default: | 175 default: |
| 179 NOTREACHED() << "Unexpected notification " << type; | 176 NOTREACHED() << "Unexpected notification " << type; |
| 180 } | 177 } |
| 181 #else | 178 #else |
| 182 // MSVC++ warns about switch statements without any cases. | 179 // MSVC++ warns about switch statements without any cases. |
| 183 NOTREACHED() << "Unexpected notification " << type; | 180 NOTREACHED() << "Unexpected notification " << type; |
| 184 #endif | 181 #endif |
| 185 } | 182 } |
| OLD | NEW |