Commit bc32dfbb authored by msw's avatar msw Committed by Commit bot

mash: Fix Chrome crash accessing chrome://settings.

Avoid Shell and PowerStatus access for display/power options.

BUG=646558,548429,644348
TEST=No crash accessing chrome://settings in chrome --mash.
R=stevenjb@chromium.org

Review-Url: https://codereview.chromium.org/2341783005
Cr-Commit-Position: refs/heads/master@{#418731}
parent 7eaa2e7f
......@@ -23,6 +23,7 @@
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/user_metrics.h"
......@@ -191,14 +192,15 @@ base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) {
} // namespace
DisplayOptionsHandler::DisplayOptionsHandler() {
// ash::Shell doesn't exist in Athena.
// See: http://crbug.com/416961
ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
// TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
if (!chrome::IsRunningInMash())
ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
}
DisplayOptionsHandler::~DisplayOptionsHandler() {
// ash::Shell doesn't exist in Athena.
ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
// TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
if (!chrome::IsRunningInMash())
ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
}
void DisplayOptionsHandler::GetLocalizedValues(
......@@ -373,6 +375,10 @@ void DisplayOptionsHandler::SendAllDisplayInfo() {
}
void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() {
// TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
if (chrome::IsRunningInMash())
return;
ash::DisplayManager* display_manager = GetDisplayManager();
bool disable_multi_display_layout =
base::CommandLine::ForCurrentProcess()->HasSwitch(
......
......@@ -10,6 +10,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
......@@ -24,9 +25,11 @@ namespace chromeos {
namespace options {
PowerHandler::PowerHandler() {
this->show_power_status_ = switches::PowerOverlayEnabled() ||
(PowerStatus::Get()->IsBatteryPresent() &&
PowerStatus::Get()->SupportsDualRoleDevices());
// TODO(mash): Support Chrome power settings in Mash. crbug.com/644348
this->show_power_status_ = !chrome::IsRunningInMash() &&
(switches::PowerOverlayEnabled() ||
(PowerStatus::Get()->IsBatteryPresent() &&
PowerStatus::Get()->SupportsDualRoleDevices()));
}
PowerHandler::~PowerHandler() {
......
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