OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/display_info_provider_chromeos.h" | 5 #include "chrome/browser/extensions/display_info_provider_chromeos.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "ash/display/display_configuration_controller.h" | 9 #include "ash/display/display_configuration_controller.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) { | 312 if ((info.overscan->top + info.overscan->bottom) * 2 > screen_height) { |
313 *error = "Vertical overscan is more than half of the screen height."; | 313 *error = "Vertical overscan is more than half of the screen height."; |
314 return false; | 314 return false; |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 // Set the display mode. | 318 // Set the display mode. |
319 if (info.display_mode) { | 319 if (info.display_mode) { |
320 scoped_refptr<ash::ManagedDisplayMode> current_mode = | 320 scoped_refptr<display::ManagedDisplayMode> current_mode = |
321 display_manager->GetActiveModeForDisplayId(id); | 321 display_manager->GetActiveModeForDisplayId(id); |
322 // Copy properties not set in the UI from the current mode. | 322 // Copy properties not set in the UI from the current mode. |
323 gfx::Size size(info.display_mode->width_in_native_pixels, | 323 gfx::Size size(info.display_mode->width_in_native_pixels, |
324 info.display_mode->height_in_native_pixels); | 324 info.display_mode->height_in_native_pixels); |
325 | 325 |
326 // NB: info.display_mode is neither an ash::DisplayMode or a | 326 // NB: info.display_mode is neither an ash::DisplayMode or a |
327 // ui::DisplayMode. | 327 // ui::DisplayMode. |
328 scoped_refptr<ash::ManagedDisplayMode> new_mode(new ash::ManagedDisplayMode( | 328 scoped_refptr<display::ManagedDisplayMode> new_mode( |
329 size, current_mode->refresh_rate(), current_mode->is_interlaced(), | 329 new display::ManagedDisplayMode( |
330 info.display_mode->is_native, info.display_mode->ui_scale, | 330 size, current_mode->refresh_rate(), current_mode->is_interlaced(), |
331 info.display_mode->device_scale_factor)); | 331 info.display_mode->is_native, info.display_mode->ui_scale, |
| 332 info.display_mode->device_scale_factor)); |
332 | 333 |
333 if (new_mode->IsEquivalent(current_mode)) { | 334 if (new_mode->IsEquivalent(current_mode)) { |
334 *error = "Display mode matches current mode."; | 335 *error = "Display mode matches current mode."; |
335 return false; | 336 return false; |
336 } | 337 } |
337 | 338 |
338 if (!display_manager->SetDisplayMode(id, new_mode)) { | 339 if (!display_manager->SetDisplayMode(id, new_mode)) { |
339 *error = "Unable to set the display mode."; | 340 *error = "Unable to set the display mode."; |
340 return false; | 341 return false; |
341 } | 342 } |
342 | 343 |
343 if (!display::Display::IsInternalDisplayId(id)) { | 344 if (!display::Display::IsInternalDisplayId(id)) { |
344 // For external displays, show a notification confirming the resolution | 345 // For external displays, show a notification confirming the resolution |
345 // change. | 346 // change. |
346 ash::Shell::GetInstance() | 347 ash::Shell::GetInstance() |
347 ->resolution_notification_controller() | 348 ->resolution_notification_controller() |
348 ->PrepareNotification(id, current_mode, new_mode, | 349 ->PrepareNotification(id, current_mode, new_mode, |
349 base::Bind(&chromeos::StoreDisplayPrefs)); | 350 base::Bind(&chromeos::StoreDisplayPrefs)); |
350 } | 351 } |
351 } | 352 } |
352 return true; | 353 return true; |
353 } | 354 } |
354 | 355 |
355 system_display::DisplayMode GetDisplayMode( | 356 system_display::DisplayMode GetDisplayMode( |
356 ash::DisplayManager* display_manager, | 357 ash::DisplayManager* display_manager, |
357 const ash::DisplayInfo& display_info, | 358 const display::ManagedDisplayInfo& display_info, |
358 const scoped_refptr<ash::ManagedDisplayMode>& display_mode) { | 359 const scoped_refptr<display::ManagedDisplayMode>& display_mode) { |
359 system_display::DisplayMode result; | 360 system_display::DisplayMode result; |
360 | 361 |
361 bool is_internal = display::Display::HasInternalDisplay() && | 362 bool is_internal = display::Display::HasInternalDisplay() && |
362 display::Display::InternalDisplayId() == display_info.id(); | 363 display::Display::InternalDisplayId() == display_info.id(); |
363 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal); | 364 gfx::Size size_dip = display_mode->GetSizeInDIP(is_internal); |
364 result.width = size_dip.width(); | 365 result.width = size_dip.width(); |
365 result.height = size_dip.height(); | 366 result.height = size_dip.height(); |
366 result.width_in_native_pixels = display_mode->size().width(); | 367 result.width_in_native_pixels = display_mode->size().width(); |
367 result.height_in_native_pixels = display_mode->size().height(); | 368 result.height_in_native_pixels = display_mode->size().height(); |
368 result.ui_scale = display_mode->ui_scale(); | 369 result.ui_scale = display_mode->ui_scale(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const display::Display& display, | 495 const display::Display& display, |
495 system_display::DisplayUnitInfo* unit) { | 496 system_display::DisplayUnitInfo* unit) { |
496 ash::DisplayManager* display_manager = | 497 ash::DisplayManager* display_manager = |
497 ash::Shell::GetInstance()->display_manager(); | 498 ash::Shell::GetInstance()->display_manager(); |
498 unit->name = display_manager->GetDisplayNameForId(display.id()); | 499 unit->name = display_manager->GetDisplayNameForId(display.id()); |
499 if (display_manager->IsInMirrorMode()) { | 500 if (display_manager->IsInMirrorMode()) { |
500 unit->mirroring_source_id = | 501 unit->mirroring_source_id = |
501 base::Int64ToString(display_manager->mirroring_display_id()); | 502 base::Int64ToString(display_manager->mirroring_display_id()); |
502 } | 503 } |
503 | 504 |
504 const ash::DisplayInfo& display_info = | 505 const display::ManagedDisplayInfo& display_info = |
505 display_manager->GetDisplayInfo(display.id()); | 506 display_manager->GetDisplayInfo(display.id()); |
506 const float device_dpi = display_info.device_dpi(); | 507 const float device_dpi = display_info.device_dpi(); |
507 unit->dpi_x = device_dpi * display.size().width() / | 508 unit->dpi_x = device_dpi * display.size().width() / |
508 display_info.bounds_in_native().width(); | 509 display_info.bounds_in_native().width(); |
509 unit->dpi_y = device_dpi * display.size().height() / | 510 unit->dpi_y = device_dpi * display.size().height() / |
510 display_info.bounds_in_native().height(); | 511 display_info.bounds_in_native().height(); |
511 | 512 |
512 const gfx::Insets overscan_insets = | 513 const gfx::Insets overscan_insets = |
513 display_manager->GetOverscanInsets(display.id()); | 514 display_manager->GetOverscanInsets(display.id()); |
514 unit->overscan.left = overscan_insets.left(); | 515 unit->overscan.left = overscan_insets.left(); |
515 unit->overscan.top = overscan_insets.top(); | 516 unit->overscan.top = overscan_insets.top(); |
516 unit->overscan.right = overscan_insets.right(); | 517 unit->overscan.right = overscan_insets.right(); |
517 unit->overscan.bottom = overscan_insets.bottom(); | 518 unit->overscan.bottom = overscan_insets.bottom(); |
518 | 519 |
519 for (const scoped_refptr<ash::ManagedDisplayMode>& display_mode : | 520 for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : |
520 display_info.display_modes()) { | 521 display_info.display_modes()) { |
521 unit->modes.push_back( | 522 unit->modes.push_back( |
522 GetDisplayMode(display_manager, display_info, display_mode)); | 523 GetDisplayMode(display_manager, display_info, display_mode)); |
523 } | 524 } |
524 } | 525 } |
525 | 526 |
526 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 527 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { |
527 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 528 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( |
528 enable); | 529 enable); |
529 } | 530 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 return nullptr; | 635 return nullptr; |
635 return iter->second.get(); | 636 return iter->second.get(); |
636 } | 637 } |
637 | 638 |
638 // static | 639 // static |
639 DisplayInfoProvider* DisplayInfoProvider::Create() { | 640 DisplayInfoProvider* DisplayInfoProvider::Create() { |
640 return new DisplayInfoProviderChromeOS(); | 641 return new DisplayInfoProviderChromeOS(); |
641 } | 642 } |
642 | 643 |
643 } // namespace extensions | 644 } // namespace extensions |
OLD | NEW |