| 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/shell_init_params.h" | 13 #include "ash/shell_init_params.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/sys_info.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browser_process_platform_part.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 19 #include "chrome/browser/browser_shutdown.h" |
| 20 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 17 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 18 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 23 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 19 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | 24 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
| 20 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 25 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 26 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" |
| 27 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" |
| 21 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 30 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/login/login_state.h" |
| 22 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/context_factory.h" | 33 #include "content/public/browser/context_factory.h" |
| 24 #include "ui/aura/env.h" | 34 #include "ui/aura/env.h" |
| 25 #include "ui/aura/window_tree_host.h" | 35 #include "ui/aura/window_tree_host.h" |
| 26 | 36 |
| 27 #if defined(OS_CHROMEOS) | 37 #if defined(USE_X11) |
| 28 #include "base/sys_info.h" | |
| 29 #include "chrome/browser/browser_process.h" | |
| 30 #include "chrome/browser/browser_process_platform_part.h" | |
| 31 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | |
| 32 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | |
| 33 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" | |
| 34 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" | |
| 35 #include "chromeos/accelerometer/accelerometer_reader.h" | |
| 36 #include "chromeos/chromeos_switches.h" | |
| 37 #include "chromeos/login/login_state.h" | |
| 38 #include "ui/base/x/x11_util.h" | 38 #include "ui/base/x/x11_util.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #if defined(MOJO_SHELL_CLIENT) | 41 #if defined(MOJO_SHELL_CLIENT) |
| 42 #include "chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h" | 42 #include "chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 namespace chrome { | 45 namespace chrome { |
| 46 | 46 |
| 47 void OpenAsh(gfx::AcceleratedWidget remote_window) { | 47 void OpenAsh(gfx::AcceleratedWidget remote_window) { |
| 48 #if defined(OS_CHROMEOS) | |
| 49 #if defined(USE_X11) | 48 #if defined(USE_X11) |
| 50 if (base::SysInfo::IsRunningOnChromeOS()) { | 49 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 51 // Hides the cursor outside of the Aura root window. The cursor will be | 50 // Hides the cursor outside of the Aura root window. The cursor will be |
| 52 // drawn within the Aura root window, and it'll remain hidden after the | 51 // drawn within the Aura root window, and it'll remain hidden after the |
| 53 // Aura window is closed. | 52 // Aura window is closed. |
| 54 ui::HideHostCursor(); | 53 ui::HideHostCursor(); |
| 55 } | 54 } |
| 56 #endif | 55 #endif |
| 57 | 56 |
| 58 // Hide the mouse cursor completely at boot. | 57 // Hide the mouse cursor completely at boot. |
| 59 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) | 58 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) |
| 60 ash::Shell::set_initially_hide_cursor(true); | 59 ash::Shell::set_initially_hide_cursor(true); |
| 61 #endif | |
| 62 | 60 |
| 63 // Balanced by a call to DestroyInstance() in CloseAsh() below. | 61 // Balanced by a call to DestroyInstance() in CloseAsh() below. |
| 64 ash::ShellContentState::SetInstance(new ChromeShellContentState); | 62 ash::ShellContentState::SetInstance(new ChromeShellContentState); |
| 65 | 63 |
| 66 ash::ShellInitParams shell_init_params; | 64 ash::ShellInitParams shell_init_params; |
| 67 // Shell takes ownership of ChromeShellDelegate. | 65 // Shell takes ownership of ChromeShellDelegate. |
| 68 shell_init_params.delegate = new ChromeShellDelegate; | 66 shell_init_params.delegate = new ChromeShellDelegate; |
| 69 shell_init_params.context_factory = content::GetContextFactory(); | 67 shell_init_params.context_factory = content::GetContextFactory(); |
| 70 shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); | 68 shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); |
| 71 #if defined(OS_WIN) | |
| 72 shell_init_params.remote_hwnd = remote_window; | |
| 73 #endif | |
| 74 | 69 |
| 75 ash::Shell* shell = ash::Shell::CreateInstance(shell_init_params); | 70 ash::Shell* shell = ash::Shell::CreateInstance(shell_init_params); |
| 76 shell->accelerator_controller()->SetScreenshotDelegate( | 71 shell->accelerator_controller()->SetScreenshotDelegate( |
| 77 std::unique_ptr<ash::ScreenshotDelegate>(new ChromeScreenshotGrabber)); | 72 std::unique_ptr<ash::ScreenshotDelegate>(new ChromeScreenshotGrabber)); |
| 78 #if defined(OS_CHROMEOS) | |
| 79 // TODO(flackr): Investigate exposing a blocking pool task runner to chromeos. | 73 // TODO(flackr): Investigate exposing a blocking pool task runner to chromeos. |
| 80 chromeos::AccelerometerReader::GetInstance()->Initialize( | 74 chromeos::AccelerometerReader::GetInstance()->Initialize( |
| 81 content::BrowserThread::GetBlockingPool() | 75 content::BrowserThread::GetBlockingPool() |
| 82 ->GetSequencedTaskRunnerWithShutdownBehavior( | 76 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 83 content::BrowserThread::GetBlockingPool()->GetSequenceToken(), | 77 content::BrowserThread::GetBlockingPool()->GetSequenceToken(), |
| 84 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 78 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 85 shell->accelerator_controller()->SetImeControlDelegate( | 79 shell->accelerator_controller()->SetImeControlDelegate( |
| 86 std::unique_ptr<ash::ImeControlDelegate>(new ImeController)); | 80 std::unique_ptr<ash::ImeControlDelegate>(new ImeController)); |
| 87 shell->high_contrast_controller()->SetEnabled( | 81 shell->high_contrast_controller()->SetEnabled( |
| 88 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); | 82 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); |
| 89 | 83 |
| 90 DCHECK(chromeos::MagnificationManager::Get()); | 84 DCHECK(chromeos::MagnificationManager::Get()); |
| 91 bool magnifier_enabled = | 85 bool magnifier_enabled = |
| 92 chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); | 86 chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); |
| 93 ui::MagnifierType magnifier_type = | 87 ui::MagnifierType magnifier_type = |
| 94 chromeos::MagnificationManager::Get()->GetMagnifierType(); | 88 chromeos::MagnificationManager::Get()->GetMagnifierType(); |
| 95 shell->magnification_controller()-> | 89 shell->magnification_controller()-> |
| 96 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_FULL); | 90 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_FULL); |
| 97 shell->partial_magnification_controller()-> | 91 shell->partial_magnification_controller()-> |
| 98 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_PARTIAL); | 92 SetEnabled(magnifier_enabled && magnifier_type == ui::MAGNIFIER_PARTIAL); |
| 99 | 93 |
| 100 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 94 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 101 switches::kDisableZeroBrowsersOpenForTests)) { | 95 switches::kDisableZeroBrowsersOpenForTests)) { |
| 102 g_browser_process->platform_part()->RegisterKeepAlive(); | 96 g_browser_process->platform_part()->RegisterKeepAlive(); |
| 103 } | 97 } |
| 104 #endif | |
| 105 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 98 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 106 } | 99 } |
| 107 | 100 |
| 108 void InitializeMash() { | 101 void InitializeMash() { |
| 109 #if defined(MOJO_SHELL_CLIENT) | 102 #if defined(MOJO_SHELL_CLIENT) |
| 110 DCHECK(!ash::Shell::HasInstance()); | 103 DCHECK(!ash::Shell::HasInstance()); |
| 111 ChromeMashShelfController::CreateInstance(); | 104 ChromeMashShelfController::CreateInstance(); |
| 112 #endif | 105 #endif |
| 113 } | 106 } |
| 114 | 107 |
| 115 void CloseAsh() { | 108 void CloseAsh() { |
| 116 if (ash::Shell::HasInstance()) { | 109 if (ash::Shell::HasInstance()) { |
| 117 ash::Shell::DeleteInstance(); | 110 ash::Shell::DeleteInstance(); |
| 118 ash::ShellContentState::DestroyInstance(); | 111 ash::ShellContentState::DestroyInstance(); |
| 119 } | 112 } |
| 120 } | 113 } |
| 121 | 114 |
| 122 } // namespace chrome | 115 } // namespace chrome |
| OLD | NEW |