Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / ash / ash_init.cc
blob5e4229e377f69b7930081dec9c60379ae2346e0c
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_init.h"
7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/ash_switches.h"
9 #include "ash/high_contrast/high_contrast_controller.h"
10 #include "ash/magnifier/magnification_controller.h"
11 #include "ash/magnifier/partial_magnification_controller.h"
12 #include "ash/shell.h"
13 #include "ash/shell_init_params.h"
14 #include "base/command_line.h"
15 #include "chrome/browser/browser_shutdown.h"
16 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
18 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
19 #include "chrome/common/chrome_switches.h"
20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/context_factory.h"
22 #include "ui/aura/env.h"
23 #include "ui/aura/window_tree_host.h"
25 #if defined(OS_CHROMEOS)
26 #include "base/sys_info.h"
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
28 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
29 #include "chrome/browser/ui/ash/ime_controller_chromeos.h"
30 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
31 #include "chromeos/accelerometer/accelerometer_reader.h"
32 #include "chromeos/chromeos_switches.h"
33 #include "chromeos/login/login_state.h"
34 #include "ui/base/x/x11_util.h"
35 #endif
37 namespace chrome {
39 void OpenAsh(gfx::AcceleratedWidget remote_window) {
40 #if defined(OS_CHROMEOS)
41 #if defined(USE_X11)
42 if (base::SysInfo::IsRunningOnChromeOS()) {
43 // Hides the cursor outside of the Aura root window. The cursor will be
44 // drawn within the Aura root window, and it'll remain hidden after the
45 // Aura window is closed.
46 ui::HideHostCursor();
48 #endif
50 // Hide the mouse cursor completely at boot.
51 if (!chromeos::LoginState::Get()->IsUserLoggedIn())
52 ash::Shell::set_initially_hide_cursor(true);
53 #endif
55 ash::ShellInitParams shell_init_params;
56 // Shell takes ownership of ChromeShellDelegate.
57 shell_init_params.delegate = new ChromeShellDelegate;
58 shell_init_params.context_factory = content::GetContextFactory();
59 #if defined(OS_WIN)
60 shell_init_params.remote_hwnd = remote_window;
61 #endif
63 ash::Shell* shell = ash::Shell::CreateInstance(shell_init_params);
64 shell->accelerator_controller()->SetScreenshotDelegate(
65 scoped_ptr<ash::ScreenshotDelegate>(new ChromeScreenshotGrabber).Pass());
66 #if defined(OS_CHROMEOS)
67 // TODO(flackr): Investigate exposing a blocking pool task runner to chromeos.
68 chromeos::AccelerometerReader::GetInstance()->Initialize(
69 content::BrowserThread::GetBlockingPool()
70 ->GetTaskRunnerWithShutdownBehavior(
71 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
72 shell->accelerator_controller()->SetImeControlDelegate(
73 scoped_ptr<ash::ImeControlDelegate>(new ImeController).Pass());
74 shell->high_contrast_controller()->SetEnabled(
75 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled());
77 DCHECK(chromeos::MagnificationManager::Get());
78 bool magnifier_enabled =
79 chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
80 ui::MagnifierType magnifier_type =
81 chromeos::MagnificationManager::Get()->GetMagnifierType();
82 shell->magnification_controller()->
83 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_FULL);
84 shell->partial_magnification_controller()->
85 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_PARTIAL);
87 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
88 switches::kDisableZeroBrowsersOpenForTests)) {
89 chrome::IncrementKeepAliveCount();
91 #endif
92 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
95 void CloseAsh() {
96 if (ash::Shell::HasInstance())
97 ash::Shell::DeleteInstance();
100 } // namespace chrome