| 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 "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 const gfx::Display& display, | 359 const gfx::Display& display, |
| 360 extensions::api::system_display::DisplayUnitInfo* unit) { | 360 extensions::api::system_display::DisplayUnitInfo* unit) { |
| 361 ash::DisplayManager* display_manager = | 361 ash::DisplayManager* display_manager = |
| 362 ash::Shell::GetInstance()->display_manager(); | 362 ash::Shell::GetInstance()->display_manager(); |
| 363 unit->name = display_manager->GetDisplayNameForId(display.id()); | 363 unit->name = display_manager->GetDisplayNameForId(display.id()); |
| 364 if (display_manager->IsInMirrorMode()) { | 364 if (display_manager->IsInMirrorMode()) { |
| 365 unit->mirroring_source_id = | 365 unit->mirroring_source_id = |
| 366 base::Int64ToString(display_manager->mirroring_display_id()); | 366 base::Int64ToString(display_manager->mirroring_display_id()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 // TODO(hshi): determine the DPI of the screen. | 369 const ash::DisplayInfo& display_info = |
| 370 const float kDpi96 = 96.0; | 370 display_manager->GetDisplayInfo(display.id()); |
| 371 | 371 const float device_dpi = display_info.device_dpi(); |
| 372 const float dpi = display.device_scale_factor() * kDpi96; | 372 unit->dpi_x = device_dpi * display.size().width() / |
| 373 unit->dpi_x = dpi; | 373 display_info.bounds_in_native().width(); |
| 374 unit->dpi_y = dpi; | 374 unit->dpi_y = device_dpi * display.size().height() / |
| 375 display_info.bounds_in_native().height(); |
| 375 | 376 |
| 376 const gfx::Insets overscan_insets = | 377 const gfx::Insets overscan_insets = |
| 377 display_manager->GetOverscanInsets(display.id()); | 378 display_manager->GetOverscanInsets(display.id()); |
| 378 unit->overscan.left = overscan_insets.left(); | 379 unit->overscan.left = overscan_insets.left(); |
| 379 unit->overscan.top = overscan_insets.top(); | 380 unit->overscan.top = overscan_insets.top(); |
| 380 unit->overscan.right = overscan_insets.right(); | 381 unit->overscan.right = overscan_insets.right(); |
| 381 unit->overscan.bottom = overscan_insets.bottom(); | 382 unit->overscan.bottom = overscan_insets.bottom(); |
| 382 } | 383 } |
| 383 | 384 |
| 384 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { | 385 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { |
| 385 return ash::Shell::GetScreen(); | 386 return ash::Shell::GetScreen(); |
| 386 } | 387 } |
| 387 | 388 |
| 388 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { | 389 void DisplayInfoProviderChromeOS::EnableUnifiedDesktop(bool enable) { |
| 389 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( | 390 ash::Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( |
| 390 enable); | 391 enable); |
| 391 } | 392 } |
| 392 | 393 |
| 393 // static | 394 // static |
| 394 DisplayInfoProvider* DisplayInfoProvider::Create() { | 395 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 395 return new DisplayInfoProviderChromeOS(); | 396 return new DisplayInfoProviderChromeOS(); |
| 396 } | 397 } |
| 397 | 398 |
| 398 } // namespace extensions | 399 } // namespace extensions |
| OLD | NEW |