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/ash/ash_init.h" | 5 #include "chrome/browser/ui/ash/ash_init.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/high_contrast/high_contrast_controller.h" | 9 #include "ash/high_contrast/high_contrast_controller.h" |
10 #include "ash/magnifier/magnification_controller.h" | 10 #include "ash/magnifier/magnification_controller.h" |
11 #include "ash/magnifier/partial_magnification_controller.h" | 11 #include "ash/magnifier/partial_magnification_controller.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/wm/event_rewriter_event_filter.h" | 13 #include "ash/wm/event_rewriter_event_filter.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
17 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 17 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 19 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
20 #include "chrome/browser/ui/ash/event_rewriter.h" | 20 #include "chrome/browser/ui/ash/event_rewriter.h" |
21 #include "chrome/browser/ui/ash/screenshot_taker.h" | 21 #include "chrome/browser/ui/ash/screenshot_taker.h" |
22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
23 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
24 #include "ui/aura/root_window.h" | 24 #include "ui/aura/root_window.h" |
25 | 25 |
26 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
27 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
| 28 #include "chrome/browser/app_mode/app_mode_utils.h" |
28 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" | 29 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" |
29 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" | 30 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" |
30 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
31 #include "chromeos/login/login_state.h" | 32 #include "chromeos/login/login_state.h" |
32 #include "ui/base/x/x11_util.h" | 33 #include "ui/base/x/x11_util.h" |
33 #endif | 34 #endif |
34 | 35 |
35 namespace chrome { | 36 namespace chrome { |
36 | 37 |
37 bool ShouldOpenAshOnStartup() { | 38 bool ShouldOpenAshOnStartup() { |
(...skipping 20 matching lines...) Expand all Loading... |
58 | 59 |
59 // Shell takes ownership of ChromeShellDelegate. | 60 // Shell takes ownership of ChromeShellDelegate. |
60 ash::Shell* shell = ash::Shell::CreateInstance(new ChromeShellDelegate); | 61 ash::Shell* shell = ash::Shell::CreateInstance(new ChromeShellDelegate); |
61 shell->event_rewriter_filter()->SetEventRewriterDelegate( | 62 shell->event_rewriter_filter()->SetEventRewriterDelegate( |
62 scoped_ptr<ash::EventRewriterDelegate>(new EventRewriter).Pass()); | 63 scoped_ptr<ash::EventRewriterDelegate>(new EventRewriter).Pass()); |
63 shell->accelerator_controller()->SetScreenshotDelegate( | 64 shell->accelerator_controller()->SetScreenshotDelegate( |
64 scoped_ptr<ash::ScreenshotDelegate>(new ScreenshotTaker).Pass()); | 65 scoped_ptr<ash::ScreenshotDelegate>(new ScreenshotTaker).Pass()); |
65 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
66 shell->accelerator_controller()->SetImeControlDelegate( | 67 shell->accelerator_controller()->SetImeControlDelegate( |
67 scoped_ptr<ash::ImeControlDelegate>(new ImeController).Pass()); | 68 scoped_ptr<ash::ImeControlDelegate>(new ImeController).Pass()); |
68 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled( | 69 shell->high_contrast_controller()->SetEnabled( |
69 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); | 70 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); |
70 | 71 |
71 DCHECK(chromeos::MagnificationManager::Get()); | 72 DCHECK(chromeos::MagnificationManager::Get()); |
72 bool magnifier_enabled = | 73 bool magnifier_enabled = |
73 chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); | 74 chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); |
74 ash::MagnifierType magnifier_type = | 75 ash::MagnifierType magnifier_type = |
75 chromeos::MagnificationManager::Get()->GetMagnifierType(); | 76 chromeos::MagnificationManager::Get()->GetMagnifierType(); |
76 ash::Shell::GetInstance()->magnification_controller()-> | 77 shell->magnification_controller()-> |
77 SetEnabled(magnifier_enabled && magnifier_type == ash::MAGNIFIER_FULL); | 78 SetEnabled(magnifier_enabled && magnifier_type == ash::MAGNIFIER_FULL); |
78 ash::Shell::GetInstance()->partial_magnification_controller()-> | 79 // Enable magnifier accelerators for modes that may not have mouse cursor. |
| 80 shell->magnification_controller()-> |
| 81 SetMagnifierAcceleratorsEnabled(chrome::IsRunningInForcedAppMode()); |
| 82 shell->partial_magnification_controller()-> |
79 SetEnabled(magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL); | 83 SetEnabled(magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL); |
80 | 84 |
81 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 85 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
82 switches::kDisableZeroBrowsersOpenForTests)) { | 86 switches::kDisableZeroBrowsersOpenForTests)) { |
83 chrome::StartKeepAlive(); | 87 chrome::StartKeepAlive(); |
84 } | 88 } |
85 #endif | 89 #endif |
86 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->Show(); | 90 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->Show(); |
87 } | 91 } |
88 | 92 |
89 void CloseAsh() { | 93 void CloseAsh() { |
90 // If shutdown is initiated by |BrowserX11IOErrorHandler|, don't | 94 // If shutdown is initiated by |BrowserX11IOErrorHandler|, don't |
91 // try to cleanup resources. | 95 // try to cleanup resources. |
92 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers() && | 96 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers() && |
93 ash::Shell::HasInstance()) { | 97 ash::Shell::HasInstance()) { |
94 ash::Shell::DeleteInstance(); | 98 ash::Shell::DeleteInstance(); |
95 } | 99 } |
96 } | 100 } |
97 | 101 |
98 } // namespace chrome | 102 } // namespace chrome |
OLD | NEW |