Commit cb176c8f authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Fix crash in ArcVoiceInteractionFrameworkService on mash

The desktopui_MashLogin autotest is failing on eve. This code tries to
access ash::Shell from the browser process.  There's a real fix coming,
but for now just early exit before each Shell access to get the test
passing.

TBR=xiyuan@chromium.org

Bug: 757012, 779129
Test: unit_tests, browser_tests --gtest_filter="Arc*" --mash
Change-Id: Ic20e890402705dd974195e5e8d1be959c5416a2f
Reviewed-on: https://chromium-review.googlesource.com/742045
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512842}
parent c58c2da7
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_boot_phase_monitor_bridge.h" #include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_boot_phase_monitor_bridge.h"
#include "chrome/browser/chromeos/arc/voice_interaction/highlighter_controller_client.h" #include "chrome/browser/chromeos/arc/voice_interaction/highlighter_controller_client.h"
#include "chrome/browser/chromeos/ash_config.h"
#include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -82,10 +83,13 @@ std::unique_ptr<ui::LayerTreeOwner> CreateLayerTreeForSnapshot( ...@@ -82,10 +83,13 @@ std::unique_ptr<ui::LayerTreeOwner> CreateLayerTreeForSnapshot(
LayerSet excluded_layers; LayerSet excluded_layers;
// Exclude metalayer-related layers. This will also include other layers // Exclude metalayer-related layers. This will also include other layers
// under kShellWindowId_OverlayContainer which is fine. // under kShellWindowId_OverlayContainer which is fine.
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() != ash::Config::MASH) {
aura::Window* overlay_container = ash::Shell::GetContainer( aura::Window* overlay_container = ash::Shell::GetContainer(
root_window, ash::kShellWindowId_OverlayContainer); root_window, ash::kShellWindowId_OverlayContainer);
if (overlay_container != nullptr) if (overlay_container != nullptr)
excluded_layers.insert(overlay_container->layer()); excluded_layers.insert(overlay_container->layer());
}
auto layer_tree_owner = ::wm::RecreateLayersWithClosure( auto layer_tree_owner = ::wm::RecreateLayersWithClosure(
root_window, base::BindRepeating( root_window, base::BindRepeating(
...@@ -249,6 +253,11 @@ void ArcVoiceInteractionFrameworkService::CaptureFullscreen( ...@@ -249,6 +253,11 @@ void ArcVoiceInteractionFrameworkService::CaptureFullscreen(
// Since ARC currently only runs in primary display, we restrict // Since ARC currently only runs in primary display, we restrict
// the screenshot to it. // the screenshot to it.
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() == ash::Config::MASH) {
std::move(callback).Run(std::vector<uint8_t>{});
return;
}
aura::Window* window = ash::Shell::GetPrimaryRootWindow(); aura::Window* window = ash::Shell::GetPrimaryRootWindow();
DCHECK(window); DCHECK(window);
...@@ -307,6 +316,9 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionState( ...@@ -307,6 +316,9 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionState(
highlighter_client_->Exit(); highlighter_client_->Exit();
state_ = state; state_ = state;
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() == ash::Config::MASH)
return;
ash::Shell::Get()->NotifyVoiceInteractionStatusChanged(state); ash::Shell::Get()->NotifyVoiceInteractionStatusChanged(state);
} }
...@@ -355,6 +367,8 @@ void ArcVoiceInteractionFrameworkService::OnSessionStateChanged() { ...@@ -355,6 +367,8 @@ void ArcVoiceInteractionFrameworkService::OnSessionStateChanged() {
// TODO(crbug.com/757012): Avoid using ash::Shell here so that it can work in // TODO(crbug.com/757012): Avoid using ash::Shell here so that it can work in
// mash. // mash.
if (chromeos::GetAshConfig() == ash::Config::MASH)
return;
PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs(); PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs();
bool enabled = prefs->GetBoolean(prefs::kVoiceInteractionEnabled); bool enabled = prefs->GetBoolean(prefs::kVoiceInteractionEnabled);
ash::Shell::Get()->NotifyVoiceInteractionEnabled(enabled); ash::Shell::Get()->NotifyVoiceInteractionEnabled(enabled);
...@@ -429,6 +443,8 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionEnabled( ...@@ -429,6 +443,8 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionEnabled(
VoiceInteractionSettingCompleteCallback callback) { VoiceInteractionSettingCompleteCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() != ash::Config::MASH)
ash::Shell::Get()->NotifyVoiceInteractionEnabled(enable); ash::Shell::Get()->NotifyVoiceInteractionEnabled(enable);
PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs(); PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs();
...@@ -453,6 +469,8 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionContextEnabled( ...@@ -453,6 +469,8 @@ void ArcVoiceInteractionFrameworkService::SetVoiceInteractionContextEnabled(
bool enable) { bool enable) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() != ash::Config::MASH)
ash::Shell::Get()->NotifyVoiceInteractionContextEnabled(enable); ash::Shell::Get()->NotifyVoiceInteractionContextEnabled(enable);
PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs(); PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs();
...@@ -572,9 +590,12 @@ bool ArcVoiceInteractionFrameworkService::InitiateUserInteraction( ...@@ -572,9 +590,12 @@ bool ArcVoiceInteractionFrameworkService::InitiateUserInteraction(
if (state_ == ash::VoiceInteractionState::NOT_READY) { if (state_ == ash::VoiceInteractionState::NOT_READY) {
// If the container side is not ready, we will be waiting for a while. // If the container side is not ready, we will be waiting for a while.
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() != ash::Config::MASH) {
ash::Shell::Get()->NotifyVoiceInteractionStatusChanged( ash::Shell::Get()->NotifyVoiceInteractionStatusChanged(
ash::VoiceInteractionState::NOT_READY); ash::VoiceInteractionState::NOT_READY);
} }
}
ArcBootPhaseMonitorBridge::RecordFirstAppLaunchDelayUMA(context_); ArcBootPhaseMonitorBridge::RecordFirstAppLaunchDelayUMA(context_);
if (!arc_bridge_service_->voice_interaction_framework()->has_instance()) { if (!arc_bridge_service_->voice_interaction_framework()->has_instance()) {
...@@ -595,11 +616,17 @@ void ArcVoiceInteractionFrameworkService:: ...@@ -595,11 +616,17 @@ void ArcVoiceInteractionFrameworkService::
PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs(); PrefService* prefs = Profile::FromBrowserContext(context_)->GetPrefs();
prefs->SetBoolean(prefs::kArcVoiceInteractionValuePropAccepted, completed); prefs->SetBoolean(prefs::kArcVoiceInteractionValuePropAccepted, completed);
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() == ash::Config::MASH)
return;
ash::Shell::Get()->NotifyVoiceInteractionSetupCompleted(completed); ash::Shell::Get()->NotifyVoiceInteractionSetupCompleted(completed);
} }
bool ArcVoiceInteractionFrameworkService::IsHomescreenActive() { bool ArcVoiceInteractionFrameworkService::IsHomescreenActive() {
// Homescreen is considered to be active if there are no active windows. // Homescreen is considered to be active if there are no active windows.
// TODO(crbug.com/757012): Mash support.
if (chromeos::GetAshConfig() == ash::Config::MASH)
return false;
return !ash::Shell::Get()->activation_client()->GetActiveWindow(); return !ash::Shell::Get()->activation_client()->GetActiveWindow();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment