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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc

Issue 2341783005: mash: Fix Chrome crash accessing chrome://settings. (Closed)
Patch Set: Avoid PowerStatus access; not init in Chrome. Created 4 years, 3 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 | « no previous file | chrome/browser/ui/webui/options/chromeos/power_handler.cc » ('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/webui/options/chromeos/display_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/display_options_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "ash/common/strings/grit/ash_strings.h" 12 #include "ash/common/strings/grit/ash_strings.h"
13 #include "ash/display/display_configuration_controller.h" 13 #include "ash/display/display_configuration_controller.h"
14 #include "ash/display/display_manager.h" 14 #include "ash/display/display_manager.h"
15 #include "ash/display/resolution_notification_controller.h" 15 #include "ash/display/resolution_notification_controller.h"
16 #include "ash/display/window_tree_host_manager.h" 16 #include "ash/display/window_tree_host_manager.h"
17 #include "ash/screen_util.h" 17 #include "ash/screen_util.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "chrome/browser/chromeos/display/display_preferences.h" 25 #include "chrome/browser/chromeos/display/display_preferences.h"
26 #include "chrome/browser/ui/ash/ash_util.h"
26 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
27 #include "chromeos/chromeos_switches.h" 28 #include "chromeos/chromeos_switches.h"
28 #include "content/public/browser/user_metrics.h" 29 #include "content/public/browser/user_metrics.h"
29 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
30 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/display/display.h" 32 #include "ui/display/display.h"
32 #include "ui/display/manager/display_layout.h" 33 #include "ui/display/manager/display_layout.h"
33 #include "ui/display/manager/display_layout_builder.h" 34 #include "ui/display/manager/display_layout_builder.h"
34 #include "ui/display/screen.h" 35 #include "ui/display/screen.h"
35 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 result->SetInteger("left", bounds.x()); 185 result->SetInteger("left", bounds.x());
185 result->SetInteger("top", bounds.y()); 186 result->SetInteger("top", bounds.y());
186 result->SetInteger("width", bounds.width()); 187 result->SetInteger("width", bounds.width());
187 result->SetInteger("height", bounds.height()); 188 result->SetInteger("height", bounds.height());
188 return result; 189 return result;
189 } 190 }
190 191
191 } // namespace 192 } // namespace
192 193
193 DisplayOptionsHandler::DisplayOptionsHandler() { 194 DisplayOptionsHandler::DisplayOptionsHandler() {
194 // ash::Shell doesn't exist in Athena. 195 // TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
195 // See: http://crbug.com/416961 196 if (!chrome::IsRunningInMash())
196 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); 197 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
197 } 198 }
198 199
199 DisplayOptionsHandler::~DisplayOptionsHandler() { 200 DisplayOptionsHandler::~DisplayOptionsHandler() {
200 // ash::Shell doesn't exist in Athena. 201 // TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
201 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 202 if (!chrome::IsRunningInMash())
203 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
202 } 204 }
203 205
204 void DisplayOptionsHandler::GetLocalizedValues( 206 void DisplayOptionsHandler::GetLocalizedValues(
205 base::DictionaryValue* localized_strings) { 207 base::DictionaryValue* localized_strings) {
206 DCHECK(localized_strings); 208 DCHECK(localized_strings);
207 RegisterTitle(localized_strings, "displayOptionsPage", 209 RegisterTitle(localized_strings, "displayOptionsPage",
208 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_TAB_TITLE); 210 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_TAB_TITLE);
209 211
210 localized_strings->SetString( 212 localized_strings->SetString(
211 "selectedDisplayTitleOptions", l10n_util::GetStringUTF16( 213 "selectedDisplayTitleOptions", l10n_util::GetStringUTF16(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 368 }
367 369
368 js_displays->Append(js_display); 370 js_displays->Append(js_display);
369 } 371 }
370 372
371 web_ui()->CallJavascriptFunctionUnsafe( 373 web_ui()->CallJavascriptFunctionUnsafe(
372 "options.DisplayOptions.setDisplayInfo", mode, *js_displays); 374 "options.DisplayOptions.setDisplayInfo", mode, *js_displays);
373 } 375 }
374 376
375 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() { 377 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() {
378 // TODO(mash) Support Chrome display settings in Mash. crbug.com/548429
379 if (chrome::IsRunningInMash())
380 return;
381
376 ash::DisplayManager* display_manager = GetDisplayManager(); 382 ash::DisplayManager* display_manager = GetDisplayManager();
377 bool disable_multi_display_layout = 383 bool disable_multi_display_layout =
378 base::CommandLine::ForCurrentProcess()->HasSwitch( 384 base::CommandLine::ForCurrentProcess()->HasSwitch(
379 chromeos::switches::kDisableMultiDisplayLayout); 385 chromeos::switches::kDisableMultiDisplayLayout);
380 bool ui_enabled = display_manager->num_connected_displays() <= 2 || 386 bool ui_enabled = display_manager->num_connected_displays() <= 2 ||
381 !disable_multi_display_layout; 387 !disable_multi_display_layout;
382 bool unified_enabled = display_manager->unified_desktop_enabled(); 388 bool unified_enabled = display_manager->unified_desktop_enabled();
383 bool mirrored_enabled = display_manager->num_connected_displays() == 2; 389 bool mirrored_enabled = display_manager->num_connected_displays() == 2;
384 390
385 web_ui()->CallJavascriptFunctionUnsafe( 391 web_ui()->CallJavascriptFunctionUnsafe(
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 bool enable = false; 576 bool enable = false;
571 if (!args->GetBoolean(0, &enable)) 577 if (!args->GetBoolean(0, &enable))
572 NOTREACHED(); 578 NOTREACHED();
573 579
574 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( 580 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays(
575 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED); 581 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED);
576 } 582 }
577 583
578 } // namespace options 584 } // namespace options
579 } // namespace chromeos 585 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/power_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698