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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "extensions/common/api/system_display.h" | 11 #include "extensions/common/api/system_display.h" |
12 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
13 #include "ui/gfx/geometry/point.h" | 13 #include "ui/gfx/geometry/point.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 | 15 |
16 using ash::DisplayManager; | 16 using ash::DisplayManager; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 using core_api::system_display::Bounds; | 20 using api::system_display::Bounds; |
21 using core_api::system_display::DisplayUnitInfo; | 21 using api::system_display::DisplayUnitInfo; |
22 using core_api::system_display::DisplayProperties; | 22 using api::system_display::DisplayProperties; |
23 using core_api::system_display::Insets; | 23 using api::system_display::Insets; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Maximum allowed bounds origin absolute value. | 27 // Maximum allowed bounds origin absolute value. |
28 const int kMaxBoundsOrigin = 200 * 1000; | 28 const int kMaxBoundsOrigin = 200 * 1000; |
29 | 29 |
30 // Checks if the given integer value is valid display rotation in degrees. | 30 // Checks if the given integer value is valid display rotation in degrees. |
31 bool IsValidRotationValue(int rotation) { | 31 bool IsValidRotationValue(int rotation) { |
32 return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; | 32 return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; |
33 } | 33 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 new_bounds_origin.y() - target.bounds().y()); | 350 new_bounds_origin.y() - target.bounds().y()); |
351 UpdateDisplayLayout( | 351 UpdateDisplayLayout( |
352 primary.bounds(), primary.id(), target_bounds, target.id()); | 352 primary.bounds(), primary.id(), target_bounds, target.id()); |
353 } | 353 } |
354 | 354 |
355 return true; | 355 return true; |
356 } | 356 } |
357 | 357 |
358 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( | 358 void DisplayInfoProviderChromeOS::UpdateDisplayUnitInfoForPlatform( |
359 const gfx::Display& display, | 359 const gfx::Display& display, |
360 extensions::core_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 // TODO(hshi): determine the DPI of the screen. |
370 const float kDpi96 = 96.0; | 370 const float kDpi96 = 96.0; |
(...skipping 13 matching lines...) Expand all Loading... |
384 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { | 384 gfx::Screen* DisplayInfoProviderChromeOS::GetActiveScreen() { |
385 return ash::Shell::GetScreen(); | 385 return ash::Shell::GetScreen(); |
386 } | 386 } |
387 | 387 |
388 // static | 388 // static |
389 DisplayInfoProvider* DisplayInfoProvider::Create() { | 389 DisplayInfoProvider* DisplayInfoProvider::Create() { |
390 return new DisplayInfoProviderChromeOS(); | 390 return new DisplayInfoProviderChromeOS(); |
391 } | 391 } |
392 | 392 |
393 } // namespace extensions | 393 } // namespace extensions |
OLD | NEW |