| 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_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "extensions/common/api/system_display.h" | 12 #include "extensions/common/api/system_display.h" |
| 13 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 14 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 | 16 |
| 17 using ash::DisplayManager; | 17 using ash::DisplayManager; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 using core_api::system_display::Bounds; | 21 using core_api::system_display::Bounds; |
| 22 using core_api::system_display::DisplayUnitInfo; | 22 using core_api::system_display::DisplayUnitInfo; |
| 23 using core_api::system_display::DisplayProperties; | 23 using core_api::system_display::DisplayProperties; |
| 24 using core_api::system_display::Insets; | 24 using core_api::system_display::Insets; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // TODO(hshi): determine the DPI of the screen. | |
| 29 const float kDpi96 = 96.0; | |
| 30 // Maximum allowed bounds origin absolute value. | 28 // Maximum allowed bounds origin absolute value. |
| 31 const int kMaxBoundsOrigin = 200 * 1000; | 29 const int kMaxBoundsOrigin = 200 * 1000; |
| 32 | 30 |
| 33 // Checks if the given integer value is valid display rotation in degrees. | 31 // Checks if the given integer value is valid display rotation in degrees. |
| 34 bool IsValidRotationValue(int rotation) { | 32 bool IsValidRotationValue(int rotation) { |
| 35 return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; | 33 return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; |
| 36 } | 34 } |
| 37 | 35 |
| 38 // Converts integer integer value in degrees to Rotation enum value. | 36 // Converts integer integer value in degrees to Rotation enum value. |
| 39 gfx::Display::Rotation DegreesToRotation(int degrees) { | 37 gfx::Display::Rotation DegreesToRotation(int degrees) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 UpdateDisplayLayout( | 351 UpdateDisplayLayout( |
| 354 primary.bounds(), primary.id(), target_bounds, target.id()); | 352 primary.bounds(), primary.id(), target_bounds, target.id()); |
| 355 } | 353 } |
| 356 | 354 |
| 357 return true; | 355 return true; |
| 358 } | 356 } |
| 359 | 357 |
| 360 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 358 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( |
| 361 const gfx::Display& display, | 359 const gfx::Display& display, |
| 362 extensions::core_api::system_display::DisplayUnitInfo* unit) { | 360 extensions::core_api::system_display::DisplayUnitInfo* unit) { |
| 361 #if !defined(USE_ATHENA) |
| 362 // TODO(dpolukhin): put something reasonable to the unit without ash::Shell. |
| 363 ash::DisplayManager* display_manager = | 363 ash::DisplayManager* display_manager = |
| 364 ash::Shell::GetInstance()->display_manager(); | 364 ash::Shell::GetInstance()->display_manager(); |
| 365 unit->name = display_manager->GetDisplayNameForId(display.id()); | 365 unit->name = display_manager->GetDisplayNameForId(display.id()); |
| 366 if (display_manager->IsMirrored()) { | 366 if (display_manager->IsMirrored()) { |
| 367 unit->mirroring_source_id = | 367 unit->mirroring_source_id = |
| 368 base::Int64ToString(display_manager->mirrored_display_id()); | 368 base::Int64ToString(display_manager->mirrored_display_id()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 // TODO(hshi): determine the DPI of the screen. |
| 372 const float kDpi96 = 96.0; |
| 373 |
| 371 const float dpi = display.device_scale_factor() * kDpi96; | 374 const float dpi = display.device_scale_factor() * kDpi96; |
| 372 unit->dpi_x = dpi; | 375 unit->dpi_x = dpi; |
| 373 unit->dpi_y = dpi; | 376 unit->dpi_y = dpi; |
| 374 | 377 |
| 375 const gfx::Insets overscan_insets = | 378 const gfx::Insets overscan_insets = |
| 376 display_manager->GetOverscanInsets(display.id()); | 379 display_manager->GetOverscanInsets(display.id()); |
| 377 unit->overscan.left = overscan_insets.left(); | 380 unit->overscan.left = overscan_insets.left(); |
| 378 unit->overscan.top = overscan_insets.top(); | 381 unit->overscan.top = overscan_insets.top(); |
| 379 unit->overscan.right = overscan_insets.right(); | 382 unit->overscan.right = overscan_insets.right(); |
| 380 unit->overscan.bottom = overscan_insets.bottom(); | 383 unit->overscan.bottom = overscan_insets.bottom(); |
| 384 #endif |
| 381 } | 385 } |
| 382 | 386 |
| 383 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { | 387 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { |
| 384 return ash::Shell::GetScreen(); | 388 return ash::Shell::GetScreen(); |
| 385 } | 389 } |
| 386 | 390 |
| 387 // static | 391 // static |
| 388 DisplayInfoProvider* DisplayInfoProvider::Create() { | 392 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 389 return new DisplayInfoProviderChromeOS(); | 393 return new DisplayInfoProviderChromeOS(); |
| 390 } | 394 } |
| 391 | 395 |
| 392 } // namespace extensions | 396 } // namespace extensions |
| OLD | NEW |