blob: 97f6f16c2ec401796e1d1cce86ea87ff9f8c3fe0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/ash_init.h"
#include "ash/accelerators/accelerator_controller.h"
#include "ash/ash_switches.h"
#include "ash/high_contrast/high_contrast_controller.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/shell.h"
#include "ash/wm/key_rewriter_event_filter.h"
#include "ash/wm/property_util.h"
#include "base/command_line.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/views/ash/caps_lock_handler.h"
#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h"
#include "chrome/browser/ui/views/ash/key_rewriter.h"
#include "chrome/browser/ui/views/ash/screenshot_taker.h"
#include "chrome/common/chrome_switches.h"
#include "ui/aura/aura_switches.h"
#include "ui/aura/env.h"
#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
#include "ui/compositor/compositor_setup.h"
#if defined(OS_CHROMEOS)
#include "base/chromeos/chromeos_version.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/ui/views/ash/brightness_controller_chromeos.h"
#include "chrome/browser/ui/views/ash/ime_controller_chromeos.h"
#include "chrome/browser/ui/views/ash/volume_controller_chromeos.h"
#endif
namespace browser {
bool ShouldOpenAshOnStartup() {
#if defined(OS_CHROMEOS)
return true;
#endif
return CommandLine::ForCurrentProcess()->HasSwitch(switches::kOpenAsh);
}
void OpenAsh() {
bool use_fullscreen = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAuraHostWindowUseFullscreen);
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS())
use_fullscreen = true;
#endif
if (use_fullscreen) {
aura::DisplayManager::set_use_fullscreen_host_window(true);
#if defined(OS_CHROMEOS)
aura::RootWindow::set_hide_host_cursor(true);
// Hide the mouse cursor completely at boot.
if (!chromeos::UserManager::Get()->IsUserLoggedIn())
ash::Shell::set_initially_hide_cursor(true);
#endif
}
// Its easier to mark all windows as persisting and exclude the ones we care
// about (browser windows), rather than explicitly excluding certain windows.
ash::SetDefaultPersistsAcrossAllWorkspaces(true);
// Shell takes ownership of ChromeShellDelegate.
ash::Shell* shell = ash::Shell::CreateInstance(new ChromeShellDelegate);
shell->key_rewriter_filter()->SetKeyRewriterDelegate(
scoped_ptr<ash::KeyRewriterDelegate>(new KeyRewriter).Pass());
shell->accelerator_controller()->SetScreenshotDelegate(
scoped_ptr<ash::ScreenshotDelegate>(new ScreenshotTaker).Pass());
#if defined(OS_CHROMEOS)
shell->accelerator_controller()->SetBrightnessControlDelegate(
scoped_ptr<ash::BrightnessControlDelegate>(
new BrightnessController).Pass());
chromeos::input_method::XKeyboard* xkeyboard =
chromeos::input_method::InputMethodManager::GetInstance()->GetXKeyboard();
shell->accelerator_controller()->SetCapsLockDelegate(
scoped_ptr<ash::CapsLockDelegate>(new CapsLockHandler(xkeyboard)).Pass());
shell->accelerator_controller()->SetImeControlDelegate(
scoped_ptr<ash::ImeControlDelegate>(new ImeController).Pass());
shell->accelerator_controller()->SetVolumeControlDelegate(
scoped_ptr<ash::VolumeControlDelegate>(new VolumeController).Pass());
ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(
chromeos::accessibility::IsHighContrastEnabled());
ash::Shell::GetInstance()->magnification_controller()->SetEnabled(
chromeos::accessibility::IsScreenMagnifierEnabled());
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableZeroBrowsersOpenForTests)) {
browser::StartKeepAlive();
}
#endif
ash::Shell::GetPrimaryRootWindow()->ShowRootWindow();
}
void CloseAsh() {
if (ash::Shell::GetInstance())
ash::Shell::DeleteInstance();
}
} // namespace browser
|