Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Side by Side Diff: chrome/browser/ui/ash/ash_init.cc

Issue 2777223002: Gets chrome --mus some what working (Closed)
Patch Set: fix mac Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/ash_init.h ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_delegate_aura.h" 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
8 #include "ash/aura/wm_shell_aura.h" 8 #include "ash/aura/wm_shell_aura.h"
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accessibility_types.h" 10 #include "ash/common/accessibility_types.h"
11 #include "ash/high_contrast/high_contrast_controller.h" 11 #include "ash/high_contrast/high_contrast_controller.h"
12 #include "ash/magnifier/magnification_controller.h" 12 #include "ash/magnifier/magnification_controller.h"
13 #include "ash/magnifier/partial_magnification_controller.h" 13 #include "ash/magnifier/partial_magnification_controller.h"
14 #include "ash/mus/bridge/wm_shell_mus.h"
15 #include "ash/mus/window_manager.h"
16 #include "ash/public/cpp/config.h"
14 #include "ash/shell.h" 17 #include "ash/shell.h"
15 #include "ash/shell_init_params.h" 18 #include "ash/shell_init_params.h"
16 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/memory/ptr_util.h"
17 #include "base/sys_info.h" 21 #include "base/sys_info.h"
18 #include "base/threading/sequenced_worker_pool.h" 22 #include "base/threading/sequenced_worker_pool.h"
19 #include "build/build_config.h" 23 #include "build/build_config.h"
20 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/browser_process_platform_part.h" 25 #include "chrome/browser/browser_process_platform_part.h"
22 #include "chrome/browser/browser_shutdown.h" 26 #include "chrome/browser/browser_shutdown.h"
23 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 28 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
29 #include "chrome/browser/chromeos/ash_config.h"
25 #include "chrome/browser/lifetime/application_lifetime.h" 30 #include "chrome/browser/lifetime/application_lifetime.h"
26 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" 31 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
27 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" 32 #include "chrome/browser/ui/ash/chrome_shell_content_state.h"
28 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 33 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
29 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" 34 #include "chrome/browser/ui/ash/ime_controller_chromeos.h"
30 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
31 #include "chromeos/accelerometer/accelerometer_reader.h" 36 #include "chromeos/accelerometer/accelerometer_reader.h"
32 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
33 #include "chromeos/login/login_state.h" 38 #include "chromeos/login/login_state.h"
34 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/context_factory.h" 40 #include "content/public/browser/context_factory.h"
41 #include "content/public/common/service_manager_connection.h"
36 #include "ui/aura/env.h" 42 #include "ui/aura/env.h"
43 #include "ui/aura/mus/window_tree_client.h"
37 #include "ui/aura/window_tree_host.h" 44 #include "ui/aura/window_tree_host.h"
38 45
39 #if defined(USE_X11) 46 #if defined(USE_X11)
40 #include "ui/base/x/x11_util.h" // nogncheck 47 #include "ui/base/x/x11_util.h" // nogncheck
41 #endif 48 #endif
42 49
43 namespace chrome { 50 namespace {
44 51
45 void OpenAsh(gfx::AcceleratedWidget remote_window) { 52 void CreateClassicShell() {
53 ash::ShellInitParams shell_init_params;
54 // Shell takes ownership of ChromeShellDelegate.
55 shell_init_params.delegate = new ChromeShellDelegate;
56 shell_init_params.context_factory = content::GetContextFactory();
57 shell_init_params.context_factory_private =
58 content::GetContextFactoryPrivate();
59 shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
60
61 ash::Shell::CreateInstance(shell_init_params);
62 }
63
64 std::unique_ptr<ash::mus::WindowManager> CreateMusShell() {
65 service_manager::Connector* connector =
66 content::ServiceManagerConnection::GetForProcess()->GetConnector();
67 std::unique_ptr<ash::mus::WindowManager> window_manager =
68 base::MakeUnique<ash::mus::WindowManager>(connector, ash::Config::MUS);
69 std::unique_ptr<aura::WindowTreeClient> window_tree_client =
70 base::MakeUnique<aura::WindowTreeClient>(connector, window_manager.get(),
71 window_manager.get());
72 window_tree_client->ConnectAsWindowManager();
73 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get());
74 window_manager->Init(std::move(window_tree_client),
75 content::BrowserThread::GetBlockingPool(),
76 base::MakeUnique<ChromeShellDelegate>());
77 CHECK(window_manager->WaitForInitialDisplays());
78 return window_manager;
79 }
80
81 } // namespace
82
83 AshInit::AshInit() {
46 #if defined(USE_X11) 84 #if defined(USE_X11)
47 if (base::SysInfo::IsRunningOnChromeOS()) { 85 if (base::SysInfo::IsRunningOnChromeOS()) {
86 // Mus only runs on ozone.
87 DCHECK_NE(ash::Config::MUS, chromeos::GetConfig());
48 // Hides the cursor outside of the Aura root window. The cursor will be 88 // Hides the cursor outside of the Aura root window. The cursor will be
49 // drawn within the Aura root window, and it'll remain hidden after the 89 // drawn within the Aura root window, and it'll remain hidden after the
50 // Aura window is closed. 90 // Aura window is closed.
51 ui::HideHostCursor(); 91 ui::HideHostCursor();
52 } 92 }
53 #endif 93 #endif
54 94
55 // Hide the mouse cursor completely at boot. 95 // Hide the mouse cursor completely at boot.
56 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) 96 if (!chromeos::LoginState::Get()->IsUserLoggedIn())
57 ash::Shell::set_initially_hide_cursor(true); 97 ash::Shell::set_initially_hide_cursor(true);
58 98
59 // Balanced by a call to DestroyInstance() in CloseAsh() below. 99 // Balanced by a call to DestroyInstance() in CloseAsh() below.
60 ash::ShellContentState::SetInstance(new ChromeShellContentState); 100 ash::ShellContentState::SetInstance(new ChromeShellContentState);
61 101
62 ash::ShellInitParams shell_init_params; 102 if (chromeos::GetConfig() == ash::Config::MUS)
63 // Shell takes ownership of ChromeShellDelegate. 103 window_manager_ = CreateMusShell();
64 shell_init_params.delegate = new ChromeShellDelegate; 104 else
65 shell_init_params.context_factory = content::GetContextFactory(); 105 CreateClassicShell();
66 shell_init_params.context_factory_private =
67 content::GetContextFactoryPrivate();
68 shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
69 106
70 ash::Shell* shell = ash::Shell::CreateInstance(shell_init_params); 107 ash::Shell* shell = ash::Shell::GetInstance();
71 ash::WmShellAura::Get() 108
72 ->accelerator_controller_delegate() 109 ash::AcceleratorControllerDelegateAura* accelerator_controller_delegate =
73 ->SetScreenshotDelegate(std::unique_ptr<ash::ScreenshotDelegate>( 110 nullptr;
74 new ChromeScreenshotGrabber)); 111 if (chromeos::GetConfig() == ash::Config::CLASSIC) {
112 accelerator_controller_delegate =
113 ash::WmShellAura::Get()->accelerator_controller_delegate();
114 } else if (chromeos::GetConfig() == ash::Config::MUS) {
115 accelerator_controller_delegate =
116 ash::mus::WmShellMus::Get()->accelerator_controller_delegate_classic();
117 }
118 if (accelerator_controller_delegate) {
119 std::unique_ptr<ChromeScreenshotGrabber> screenshot_delegate =
120 base::MakeUnique<ChromeScreenshotGrabber>();
121 accelerator_controller_delegate->SetScreenshotDelegate(
122 std::move(screenshot_delegate));
123 }
75 // TODO(flackr): Investigate exposing a blocking pool task runner to chromeos. 124 // TODO(flackr): Investigate exposing a blocking pool task runner to chromeos.
76 chromeos::AccelerometerReader::GetInstance()->Initialize( 125 chromeos::AccelerometerReader::GetInstance()->Initialize(
77 content::BrowserThread::GetBlockingPool() 126 content::BrowserThread::GetBlockingPool()
78 ->GetSequencedTaskRunnerWithShutdownBehavior( 127 ->GetSequencedTaskRunnerWithShutdownBehavior(
79 content::BrowserThread::GetBlockingPool()->GetSequenceToken(), 128 content::BrowserThread::GetBlockingPool()->GetSequenceToken(),
80 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 129 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
81 shell->accelerator_controller()->SetImeControlDelegate( 130 shell->accelerator_controller()->SetImeControlDelegate(
82 std::unique_ptr<ash::ImeControlDelegate>(new ImeController)); 131 std::unique_ptr<ash::ImeControlDelegate>(new ImeController));
83 shell->high_contrast_controller()->SetEnabled( 132 shell->high_contrast_controller()->SetEnabled(
84 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); 133 chromeos::AccessibilityManager::Get()->IsHighContrastEnabled());
85 134
86 DCHECK(chromeos::MagnificationManager::Get()); 135 DCHECK(chromeos::MagnificationManager::Get());
87 bool magnifier_enabled = 136 bool magnifier_enabled =
88 chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); 137 chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
89 ash::MagnifierType magnifier_type = 138 ash::MagnifierType magnifier_type =
90 chromeos::MagnificationManager::Get()->GetMagnifierType(); 139 chromeos::MagnificationManager::Get()->GetMagnifierType();
91 shell->magnification_controller()->SetEnabled( 140 shell->magnification_controller()->SetEnabled(
92 magnifier_enabled && magnifier_type == ash::MAGNIFIER_FULL); 141 magnifier_enabled && magnifier_type == ash::MAGNIFIER_FULL);
93 shell->partial_magnification_controller()->SetEnabled( 142 shell->partial_magnification_controller()->SetEnabled(
94 magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL); 143 magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL);
95 144
96 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 145 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
97 switches::kDisableZeroBrowsersOpenForTests)) { 146 switches::kDisableZeroBrowsersOpenForTests)) {
98 g_browser_process->platform_part()->RegisterKeepAlive(); 147 g_browser_process->platform_part()->RegisterKeepAlive();
99 } 148 }
100 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); 149 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
101 } 150 }
102 151
103 void CloseAsh() { 152 AshInit::~AshInit() {
104 if (ash::Shell::HasInstance()) { 153 // |window_manager_| deletes the Shell.
154 if (!window_manager_ && ash::Shell::HasInstance()) {
105 ash::Shell::DeleteInstance(); 155 ash::Shell::DeleteInstance();
106 ash::ShellContentState::DestroyInstance(); 156 ash::ShellContentState::DestroyInstance();
107 } 157 }
108 } 158 }
109
110 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/ash_init.h ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698