| 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 "chrome/common/extensions/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 api::system_display::Bounds; | 21 using core_api::system_display::Bounds; |
| 22 using api::system_display::DisplayUnitInfo; | 22 using core_api::system_display::DisplayUnitInfo; |
| 23 using api::system_display::DisplayProperties; | 23 using core_api::system_display::DisplayProperties; |
| 24 using 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. | 28 // TODO(hshi): determine the DPI of the screen. |
| 29 const float kDpi96 = 96.0; | 29 const float kDpi96 = 96.0; |
| 30 // Maximum allowed bounds origin absolute value. | 30 // Maximum allowed bounds origin absolute value. |
| 31 const int kMaxBoundsOrigin = 200 * 1000; | 31 const int kMaxBoundsOrigin = 200 * 1000; |
| 32 | 32 |
| 33 // Checks if the given integer value is valid display rotation in degrees. | 33 // Checks if the given integer value is valid display rotation in degrees. |
| 34 bool IsValidRotationValue(int rotation) { | 34 bool IsValidRotationValue(int rotation) { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 new_bounds_origin.y() - target.bounds().y()); | 352 new_bounds_origin.y() - target.bounds().y()); |
| 353 UpdateDisplayLayout( | 353 UpdateDisplayLayout( |
| 354 primary.bounds(), primary.id(), target_bounds, target.id()); | 354 primary.bounds(), primary.id(), target_bounds, target.id()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 return true; | 357 return true; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 360 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( |
| 361 const gfx::Display& display, | 361 const gfx::Display& display, |
| 362 extensions::api::system_display::DisplayUnitInfo* unit) { | 362 extensions::core_api::system_display::DisplayUnitInfo* unit) { |
| 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 const float dpi = display.device_scale_factor() * kDpi96; | 371 const float dpi = display.device_scale_factor() * kDpi96; |
| 372 unit->dpi_x = dpi; | 372 unit->dpi_x = dpi; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 383 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { | 383 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { |
| 384 return ash::Shell::GetScreen(); | 384 return ash::Shell::GetScreen(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 // static | 387 // static |
| 388 DisplayInfoProvider* DisplayInfoProvider::Create() { | 388 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 389 return new DisplayInfoProviderChromeOS(); | 389 return new DisplayInfoProviderChromeOS(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace extensions | 392 } // namespace extensions |
| OLD | NEW |