diff options
author | sadrul <sadrul@chromium.org> | 2016-02-16 22:17:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-17 06:19:03 +0000 |
commit | f3122bcd7fcbad8e149c5c4705521d22913cac1d (patch) | |
tree | c61e776a58aab188f3dbd7ba6430aba6b818f958 | |
parent | 7a187c6baf50ff6819ff73b3c094f2affd2f233d (diff) | |
download | chromium_src-f3122bcd7fcbad8e149c5c4705521d22913cac1d.zip chromium_src-f3122bcd7fcbad8e149c5c4705521d22913cac1d.tar.gz chromium_src-f3122bcd7fcbad8e149c5c4705521d22913cac1d.tar.bz2 |
chrome/chromeos: Fix launching chrome as a mus client.
Avoid initializaing ash::Shell when running chrome as a mus client. This
requires a number of components to be turned off that depend on a Shell
instance.
Notable changes:
. Do not initialize ash::Shell when chrome is launched as a mus client.
This is because the window-management and system-ui functionality are
provided by separate mus clients (desktop_wm and ash_sysui).
. Turn off AccessibilityManager (and MagnificationManager) when launching
chrome as a mus client. Accessibility should be a separate service.
That work is tracked in crbug.com/557401
. Turn off PowerButtonObserver, DataPromoNotification, and EventRewriter.
These too should be separate mus/mojo apps.
BUG=585918
Review URL: https://codereview.chromium.org/1706593002
Cr-Commit-Position: refs/heads/master@{#375808}
4 files changed, 54 insertions, 24 deletions
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 5300d0a..1cb9f9a 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -188,6 +188,13 @@ void InitializeNetworkPortalDetector() { } } +bool IsRunningAsMusClient() { +#if defined(MOJO_SHELL_CLIENT) + return !!content::MojoShellConnection::Get(); +#endif + return false; +} + } // namespace namespace internal { @@ -378,7 +385,7 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { #if defined(MOJO_SHELL_CLIENT) - if (content::MojoShellConnection::Get()) { + if (IsRunningAsMusClient()) { interface_factory_.reset(new ChromeInterfaceFactory); content::MojoShellConnection::Get()->AddListener(interface_factory_.get()); } @@ -473,10 +480,16 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { media::SoundsManager::Create(); - // Initialize magnification manager before ash tray is created. And this must - // be placed after UserManager::SessionStarted(); - AccessibilityManager::Initialize(); - MagnificationManager::Initialize(); + if (!IsRunningAsMusClient()) { + // Initialize magnification manager before ash tray is created. And this + // must be placed after UserManager::SessionStarted(); + // TODO(sad): These components expects the ash::Shell instance to be + // created. However, when running as a mus-client, an ash::Shell instance is + // not created. These accessibility services should instead be exposed as + // separate services. crbug.com/557401 + AccessibilityManager::Initialize(); + MagnificationManager::Initialize(); + } wallpaper::WallpaperManagerBase::SetPathIds( chrome::DIR_USER_DATA, @@ -707,21 +720,25 @@ void ChromeBrowserMainPartsChromeos::PreBrowserStart() { void ChromeBrowserMainPartsChromeos::PostBrowserStart() { system::InputDeviceSettings::Get()->InitTouchDevicesStatusFromLocalPrefs(); - // These are dependent on the ash::Shell singleton already having been - // initialized. - // TODO(oshima): Remove ash dependency in PowerButtonObserver. - // crbug.com/408832. - power_button_observer_.reset(new PowerButtonObserver); - data_promo_notification_.reset(new DataPromoNotification()); - - keyboard_event_rewriters_.reset(new EventRewriterController()); - keyboard_event_rewriters_->AddEventRewriter( - scoped_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter())); - keyboard_event_rewriters_->AddEventRewriter( - scoped_ptr<ui::EventRewriter>(new SpokenFeedbackEventRewriter())); - keyboard_event_rewriters_->AddEventRewriter(scoped_ptr<ui::EventRewriter>( - new EventRewriter(ash::Shell::GetInstance()->sticky_keys_controller()))); - keyboard_event_rewriters_->Init(); + if (!IsRunningAsMusClient()) { + // These are dependent on the ash::Shell singleton already having been + // initialized. Consequently, these cannot be used when running as a mus + // client. + // TODO(oshima): Remove ash dependency in PowerButtonObserver. + // crbug.com/408832. + power_button_observer_.reset(new PowerButtonObserver); + data_promo_notification_.reset(new DataPromoNotification()); + + keyboard_event_rewriters_.reset(new EventRewriterController()); + keyboard_event_rewriters_->AddEventRewriter( + scoped_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter())); + keyboard_event_rewriters_->AddEventRewriter( + scoped_ptr<ui::EventRewriter>(new SpokenFeedbackEventRewriter())); + keyboard_event_rewriters_->AddEventRewriter( + scoped_ptr<ui::EventRewriter>(new EventRewriter( + ash::Shell::GetInstance()->sticky_keys_controller()))); + keyboard_event_rewriters_->Init(); + } ChromeBrowserMainPartsLinux::PostBrowserStart(); } diff --git a/chrome/browser/notifications/login_state_notification_blocker_chromeos.cc b/chrome/browser/notifications/login_state_notification_blocker_chromeos.cc index 79b3617..d7f5b96 100644 --- a/chrome/browser/notifications/login_state_notification_blocker_chromeos.cc +++ b/chrome/browser/notifications/login_state_notification_blocker_chromeos.cc @@ -20,8 +20,11 @@ LoginStateNotificationBlockerChromeOS::LoginStateNotificationBlockerChromeOS( locked_(false), observing_(true) { // This class is created in the ctor of NotificationUIManager which is created - // when a notification is created, so ash::Shell should be initialized. - ash::Shell::GetInstance()->AddShellObserver(this); + // when a notification is created, so ash::Shell should be initialized, except + // when running as a mus client (ash::Shell is not initialized when that is + // the case). + if (ash::Shell::HasInstance()) + ash::Shell::GetInstance()->AddShellObserver(this); // LoginState may not exist in some tests. if (chromeos::LoginState::IsInitialized()) @@ -65,7 +68,8 @@ void LoginStateNotificationBlockerChromeOS::OnLockStateChanged(bool locked) { } void LoginStateNotificationBlockerChromeOS::OnAppTerminating() { - ash::Shell::GetInstance()->RemoveShellObserver(this); + if (ash::Shell::HasInstance()) + ash::Shell::GetInstance()->RemoveShellObserver(this); chromeos::UserAddingScreen::Get()->RemoveObserver(this); observing_ = false; } diff --git a/chrome/browser/ui/ash/ash_util.cc b/chrome/browser/ui/ash/ash_util.cc index 23622fe..3571624 100644 --- a/chrome/browser/ui/ash/ash_util.cc +++ b/chrome/browser/ui/ash/ash_util.cc @@ -11,10 +11,16 @@ #include "chrome/browser/ui/host_desktop.h" #include "ui/aura/window_event_dispatcher.h" +#if defined(MOJO_SHELL_CLIENT) +#include "content/public/common/mojo_shell_connection.h" +#endif + namespace chrome { bool ShouldOpenAshOnStartup() { -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) && defined(MOJO_SHELL_CLIENT) + return !content::MojoShellConnection::Get(); +#elif defined(OS_CHROMEOS) return true; #else return false; diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash.cc b/chrome/browser/ui/window_sizer/window_sizer_ash.cc index 918b957..1112648 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash.cc @@ -7,6 +7,7 @@ #include "ash/shell.h" #include "ash/wm/window_positioner.h" #include "ash/wm/window_state.h" +#include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "ui/aura/window.h" @@ -15,6 +16,8 @@ bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, ui::WindowShowState* show_state) const { + if (!chrome::ShouldOpenAshOnStartup()) + return false; if (!browser_ || browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) return false; |