Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / ash / ash_util.cc
blob775003f0e7e71e714bab505c7ae78b5103caf648
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/ash_util.h"
7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h"
9 #include "chrome/browser/ui/ash/ash_init.h"
10 #include "chrome/browser/ui/host_desktop.h"
11 #include "ui/aura/window_event_dispatcher.h"
13 #if !defined(OS_CHROMEOS)
14 #include "base/command_line.h"
15 #include "chrome/common/chrome_switches.h"
16 #endif
18 namespace chrome {
20 bool ShouldOpenAshOnStartup() {
21 #if defined(OS_CHROMEOS)
22 return true;
23 #else
24 // TODO(scottmg): http://crbug.com/133312, will need this for Win8 too.
25 return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOpenAsh);
26 #endif
29 bool IsNativeViewInAsh(gfx::NativeView native_view) {
30 #if defined(OS_CHROMEOS)
31 // Optimization. There is only ash on ChromeOS.
32 return true;
33 #endif
35 if (!ash::Shell::HasInstance())
36 return false;
38 aura::Window::Windows root_windows =
39 ash::Shell::GetInstance()->GetAllRootWindows();
41 for (aura::Window::Windows::const_iterator it = root_windows.begin();
42 it != root_windows.end(); ++it) {
43 if ((*it)->Contains(native_view))
44 return true;
47 return false;
50 bool IsNativeWindowInAsh(gfx::NativeWindow native_window) {
51 return IsNativeViewInAsh(native_window);
54 bool IsAcceleratorDeprecated(const ui::Accelerator& accelerator) {
55 ash::AcceleratorController* controller =
56 ash::Shell::GetInstance()->accelerator_controller();
57 return controller->IsDeprecated(accelerator);
60 } // namespace chrome