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

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
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.h ('k') | no next file » | 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 <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::FundamentalValue mode(
273 display_manager->IsInMirrorMode() ? DisplayManager::MIRRORING :
274 (display_manager->IsInUnifiedMode() ? DisplayManager::UNIFIED :
275 DisplayManager::EXTENDED));
264 276
265 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); 277 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id();
266 base::ListValue js_displays; 278 base::ListValue js_displays;
267 for (const gfx::Display& display : displays) { 279 for (const gfx::Display& display : displays) {
268 const ash::DisplayInfo& display_info = 280 const ash::DisplayInfo& display_info =
269 display_manager->GetDisplayInfo(display.id()); 281 display_manager->GetDisplayInfo(display.id());
270 const gfx::Rect& bounds = display.bounds(); 282 const gfx::Rect& bounds = display.bounds();
271 base::DictionaryValue* js_display = new base::DictionaryValue(); 283 base::DictionaryValue* js_display = new base::DictionaryValue();
272 js_display->SetString("id", base::Int64ToString(display.id())); 284 js_display->SetString("id", base::Int64ToString(display.id()));
273 js_display->SetInteger("x", bounds.x()); 285 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(); 319 scoped_ptr<base::Value> offset_value = base::Value::CreateNullValue();
308 if (display_manager->GetNumDisplays() > 1) { 320 if (display_manager->GetNumDisplays() > 1) {
309 const ash::DisplayLayout layout = 321 const ash::DisplayLayout layout =
310 display_manager->GetCurrentDisplayLayout(); 322 display_manager->GetCurrentDisplayLayout();
311 layout_value.reset(new base::FundamentalValue(layout.position)); 323 layout_value.reset(new base::FundamentalValue(layout.position));
312 offset_value.reset(new base::FundamentalValue(layout.offset)); 324 offset_value.reset(new base::FundamentalValue(layout.offset));
313 } 325 }
314 326
315 web_ui()->CallJavascriptFunction( 327 web_ui()->CallJavascriptFunction(
316 "options.DisplayOptions.setDisplayInfo", 328 "options.DisplayOptions.setDisplayInfo",
317 mirroring, js_displays, *layout_value.get(), *offset_value.get()); 329 mode, js_displays, *layout_value.get(), *offset_value.get());
318 } 330 }
319 331
320 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() { 332 void DisplayOptionsHandler::UpdateDisplaySettingsEnabled() {
321 bool enabled = GetDisplayManager()->num_connected_displays() <= 2; 333 bool enabled = GetDisplayManager()->num_connected_displays() <= 2;
334 bool show_unified_desktop = ash::switches::UnifiedDesktopEnabled();
335
322 web_ui()->CallJavascriptFunction( 336 web_ui()->CallJavascriptFunction(
323 "options.BrowserOptions.enableDisplaySettings", 337 "options.BrowserOptions.enableDisplaySettings",
324 base::FundamentalValue(enabled)); 338 base::FundamentalValue(enabled),
339 base::FundamentalValue(show_unified_desktop));
325 } 340 }
326 341
327 void DisplayOptionsHandler::OnFadeOutForMirroringFinished(bool is_mirroring) { 342 void DisplayOptionsHandler::OnFadeOutForMirroringFinished(bool is_mirroring) {
328 ash::Shell::GetInstance()->display_manager()->SetMirrorMode(is_mirroring); 343 ash::Shell::GetInstance()->display_manager()->SetMirrorMode(is_mirroring);
329 // Not necessary to start fade-in animation. DisplayConfigurator will do that. 344 // Not necessary to start fade-in animation. DisplayConfigurator will do that.
330 } 345 }
331 346
332 void DisplayOptionsHandler::OnFadeOutForDisplayLayoutFinished( 347 void DisplayOptionsHandler::OnFadeOutForDisplayLayoutFinished(
333 int position, int offset) { 348 int position, int offset) {
334 SetCurrentDisplayLayout( 349 SetCurrentDisplayLayout(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 profile_id > ui::COLOR_PROFILE_READING) { 479 profile_id > ui::COLOR_PROFILE_READING) {
465 LOG(ERROR) << "Invalid profile_id: " << profile_id; 480 LOG(ERROR) << "Invalid profile_id: " << profile_id;
466 return; 481 return;
467 } 482 }
468 483
469 GetDisplayManager()->SetColorCalibrationProfile( 484 GetDisplayManager()->SetColorCalibrationProfile(
470 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id)); 485 display_id, static_cast<ui::ColorCalibrationProfile>(profile_id));
471 SendAllDisplayInfo(); 486 SendAllDisplayInfo();
472 } 487 }
473 488
489 void DisplayOptionsHandler::HandleSetUnifiedDesktopEnabled(
490 const base::ListValue* args) {
491 DCHECK(ash::switches::UnifiedDesktopEnabled());
492 bool enable = false;
493 if (args->GetBoolean(0, &enable)) {
494 GetDisplayManager()->SetDefaultMultiDisplayMode(
495 enable ? DisplayManager::UNIFIED : DisplayManager::EXTENDED);
496 GetDisplayManager()->ReconfigureDisplays();
497 }
498 }
499
474 } // namespace options 500 } // namespace options
475 } // namespace chromeos 501 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698