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

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

Issue 1126933004: Allow switching between extended and unified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 <string> 7 #include <string>
8 8
9 #include "ash/ash_switches.h"
9 #include "ash/display/display_configurator_animation.h" 10 #include "ash/display/display_configurator_animation.h"
10 #include "ash/display/display_controller.h" 11 #include "ash/display/display_controller.h"
11 #include "ash/display/display_manager.h" 12 #include "ash/display/display_manager.h"
12 #include "ash/display/resolution_notification_controller.h" 13 #include "ash/display/resolution_notification_controller.h"
13 #include "ash/rotator/screen_rotation_animator.h" 14 #include "ash/rotator/screen_rotation_animator.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 localized_strings->SetString("orientation180", l10n_util::GetStringUTF16( 195 localized_strings->SetString("orientation180", l10n_util::GetStringUTF16(
195 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180)); 196 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180));
196 localized_strings->SetString("orientation270", l10n_util::GetStringUTF16( 197 localized_strings->SetString("orientation270", l10n_util::GetStringUTF16(
197 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270)); 198 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270));
198 localized_strings->SetString( 199 localized_strings->SetString(
199 "startCalibratingOverscan", l10n_util::GetStringUTF16( 200 "startCalibratingOverscan", l10n_util::GetStringUTF16(
200 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_CALIBRATING_OVERSCAN)); 201 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_CALIBRATING_OVERSCAN));
201 localized_strings->SetString( 202 localized_strings->SetString(
202 "selectedDisplayColorProfile", l10n_util::GetStringUTF16( 203 "selectedDisplayColorProfile", l10n_util::GetStringUTF16(
203 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_COLOR_PROFILE)); 204 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_COLOR_PROFILE));
205 localized_strings->SetString(
206 "enableUnifiedDesktop",
207 l10n_util::GetStringUTF16(
208 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_ENABLE_UNIFIED_DESKTOP));
204 } 209 }
205 210
206 void DisplayOptionsHandler::InitializePage() { 211 void DisplayOptionsHandler::InitializePage() {
207 DCHECK(web_ui()); 212 DCHECK(web_ui());
208 UpdateDisplaySettingsEnabled(); 213 UpdateDisplaySettingsEnabled();
209 } 214 }
210 215
211 void DisplayOptionsHandler::RegisterMessages() { 216 void DisplayOptionsHandler::RegisterMessages() {
212 web_ui()->RegisterMessageCallback( 217 web_ui()->RegisterMessageCallback(
213 "getDisplayInfo", 218 "getDisplayInfo",
(...skipping 16 matching lines...) Expand all
230 base::Bind(&DisplayOptionsHandler::HandleSetDisplayMode, 235 base::Bind(&DisplayOptionsHandler::HandleSetDisplayMode,
231 base::Unretained(this))); 236 base::Unretained(this)));
232 web_ui()->RegisterMessageCallback( 237 web_ui()->RegisterMessageCallback(
233 "setOrientation", 238 "setOrientation",
234 base::Bind(&DisplayOptionsHandler::HandleSetOrientation, 239 base::Bind(&DisplayOptionsHandler::HandleSetOrientation,
235 base::Unretained(this))); 240 base::Unretained(this)));
236 web_ui()->RegisterMessageCallback( 241 web_ui()->RegisterMessageCallback(
237 "setColorProfile", 242 "setColorProfile",
238 base::Bind(&DisplayOptionsHandler::HandleSetColorProfile, 243 base::Bind(&DisplayOptionsHandler::HandleSetColorProfile,
239 base::Unretained(this))); 244 base::Unretained(this)));
245 web_ui()->RegisterMessageCallback(
246 "setUnifiedDesktopEnabled",
247 base::Bind(&DisplayOptionsHandler::HandleSetUnifiedDesktopEnabled,
248 base::Unretained(this)));
240 } 249 }
241 250
242 void DisplayOptionsHandler::OnDisplayConfigurationChanging() { 251 void DisplayOptionsHandler::OnDisplayConfigurationChanging() {
243 } 252 }
244 253
245 void DisplayOptionsHandler::OnDisplayConfigurationChanged() { 254 void DisplayOptionsHandler::OnDisplayConfigurationChanged() {
246 UpdateDisplaySettingsEnabled(); 255 UpdateDisplaySettingsEnabled();
247 SendAllDisplayInfo(); 256 SendAllDisplayInfo();
248 } 257 }
249 258
250 void DisplayOptionsHandler::SendAllDisplayInfo() { 259 void DisplayOptionsHandler::SendAllDisplayInfo() {
251 DisplayManager* display_manager = GetDisplayManager(); 260 DisplayManager* display_manager = GetDisplayManager();
252 261
253 std::vector<gfx::Display> displays; 262 std::vector<gfx::Display> displays;
254 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 263 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
255 displays.push_back(display_manager->GetDisplayAt(i)); 264 displays.push_back(display_manager->GetDisplayAt(i));
256 } 265 }
257 SendDisplayInfo(displays); 266 SendDisplayInfo(displays);
258 } 267 }
259 268
260 void DisplayOptionsHandler::SendDisplayInfo( 269 void DisplayOptionsHandler::SendDisplayInfo(
261 const std::vector<gfx::Display>& displays) { 270 const std::vector<gfx::Display>& displays) {
262 DisplayManager* display_manager = GetDisplayManager(); 271 DisplayManager* display_manager = GetDisplayManager();
263 base::FundamentalValue mirroring(display_manager->IsInMirrorMode()); 272 base::StringValue mode(
273 display_manager->IsInMirrorMode() ? "mirror" :
274 (display_manager->IsInUnifiedMode() ? "unified" : "extended"));
Jun Mukai 2015/05/20 02:47:49 Just for safety, if (mode == "unified") DCHECK(ash
oshima 2015/05/20 06:40:01 This is actually guarded by ash::switch, and DCHEC
264 275
265 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); 276 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id();
266 base::ListValue js_displays; 277 base::ListValue js_displays;
267 for (const gfx::Display& display : displays) { 278 for (const gfx::Display& display : displays) {
268 const ash::DisplayInfo& display_info = 279 const ash::DisplayInfo& display_info =
269 display_manager->GetDisplayInfo(display.id()); 280 display_manager->GetDisplayInfo(display.id());
270 const gfx::Rect& bounds = display.bounds(); 281 const gfx::Rect& bounds = display.bounds();
271 base::DictionaryValue* js_display = new base::DictionaryValue(); 282 base::DictionaryValue* js_display = new base::DictionaryValue();
272 js_display->SetString("id", base::Int64ToString(display.id())); 283 js_display->SetString("id", base::Int64ToString(display.id()));
273 js_display->SetInteger("x", bounds.x()); 284 js_display->SetInteger("x", bounds.x());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 scoped_ptr<base::Value> offset_value = base::Value::CreateNullValue(); 318 scoped_ptr<base::Value> offset_value = base::Value::CreateNullValue();
308 if (display_manager->GetNumDisplays() > 1) { 319 if (display_manager->GetNumDisplays() > 1) {
309 const ash::DisplayLayout layout = 320 const ash::DisplayLayout layout =
310 display_manager->GetCurrentDisplayLayout(); 321 display_manager->GetCurrentDisplayLayout();
311 layout_value.reset(new base::FundamentalValue(layout.position)); 322 layout_value.reset(new base::FundamentalValue(layout.position));
312 offset_value.reset(new base::FundamentalValue(layout.offset)); 323 offset_value.reset(new base::FundamentalValue(layout.offset));
313 } 324 }
314 325
315 web_ui()->CallJavascriptFunction( 326 web_ui()->CallJavascriptFunction(
316 "options.DisplayOptions.setDisplayInfo", 327 "options.DisplayOptions.setDisplayInfo",
317 mirroring, js_displays, *layout_value.get(), *offset_value.get()); 328 mode, js_displays, *layout_value.get(), *offset_value.get());
318 } 329 }
319 330
320 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() { 331 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() {
321 bool enabled = GetDisplayManager()->num_connected_displays() <= 2; 332 bool enabled = GetDisplayManager()->num_connected_displays() <= 2;
333 bool show_unified_desktop = ash::switches::UnifiedDesktopEnabled();
334
322 web_ui()->CallJavascriptFunction( 335 web_ui()->CallJavascriptFunction(
323 "options.BrowserOptions.enableDisplaySettings", 336 "options.BrowserOptions.enableDisplaySettings",
324 base::FundamentalValue(enabled)); 337 base::FundamentalValue(enabled),
338 base::FundamentalValue(show_unified_desktop));
325 } 339 }
326 340
327 void DisplayOptionsHandler::OnFadeOutForMirroringFinished(bool is_mirroring) { 341 void DisplayOptionsHandler::OnFadeOutForMirroringFinished(bool is_mirroring) {
328 ash::Shell::GetInstance()->display_manager()->SetMirrorMode(is_mirroring); 342 ash::Shell::GetInstance()->display_manager()->SetMirrorMode(is_mirroring);
329 // Not necessary to start fade-in animation. DisplayConfigurator will do that. 343 // Not necessary to start fade-in animation. DisplayConfigurator will do that.
330 } 344 }
331 345
332 void DisplayOptionsHandler::OnFadeOutForDisplayLayoutFinished( 346 void DisplayOptionsHandler::OnFadeOutForDisplayLayoutFinished(
333 int position, int offset) { 347 int position, int offset) {
334 SetCurrentDisplayLayout( 348 SetCurrentDisplayLayout(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 profile_id > ui::COLOR_PROFILE_READING) { 478 profile_id > ui::COLOR_PROFILE_READING) {
465 LOG(ERROR) << "Invalid profile_id: " << profile_id; 479 LOG(ERROR) << "Invalid profile_id: " << profile_id;
466 return; 480 return;
467 } 481 }
468 482
469 GetDisplayManager()->SetColorCalibrationProfile( 483 GetDisplayManager()->SetColorCalibrationProfile(
470 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); 484 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id));
471 SendAllDisplayInfo(); 485 SendAllDisplayInfo();
472 } 486 }
473 487
488 void DisplayOptionsHandler::HandleSetUnifiedDesktopEnabled(
489 const base::ListValue* args) {
Jun Mukai 2015/05/20 02:47:49 Also DCHECK(ash::switches::UnifiedDesktopEnabled()
oshima 2015/05/20 06:40:01 Done.
490 bool enable = false;
491 if (args->GetBoolean(0, &enable)) {
492 GetDisplayManager()->SetDefaultMultiDisplayMode(
493 enable ? DisplayManager::UNIFIED : DisplayManager::EXTENDED);
494 GetDisplayManager()->ReconfigureDisplays();
495 }
496 }
497
474 } // namespace options 498 } // namespace options
475 } // namespace chromeos 499 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698