| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "extensions/common/api/system_display.h" | 8 #include "extensions/common/api/system_display.h" |
| 9 #include "ui/gfx/display.h" | 9 #include "ui/gfx/display.h" |
| 10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return 90; | 25 return 90; |
| 26 case gfx::Display::ROTATE_180: | 26 case gfx::Display::ROTATE_180: |
| 27 return 180; | 27 return 180; |
| 28 case gfx::Display::ROTATE_270: | 28 case gfx::Display::ROTATE_270: |
| 29 return 270; | 29 return 270; |
| 30 } | 30 } |
| 31 return 0; | 31 return 0; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Creates new DisplayUnitInfo struct for |display|. | 34 // Creates new DisplayUnitInfo struct for |display|. |
| 35 core_api::system_display::DisplayUnitInfo* CreateDisplayUnitInfo( | 35 api::system_display::DisplayUnitInfo* CreateDisplayUnitInfo( |
| 36 const gfx::Display& display, | 36 const gfx::Display& display, |
| 37 int64 primary_display_id) { | 37 int64 primary_display_id) { |
| 38 core_api::system_display::DisplayUnitInfo* unit = | 38 api::system_display::DisplayUnitInfo* unit = |
| 39 new core_api::system_display::DisplayUnitInfo(); | 39 new api::system_display::DisplayUnitInfo(); |
| 40 const gfx::Rect& bounds = display.bounds(); | 40 const gfx::Rect& bounds = display.bounds(); |
| 41 const gfx::Rect& work_area = display.work_area(); | 41 const gfx::Rect& work_area = display.work_area(); |
| 42 unit->id = base::Int64ToString(display.id()); | 42 unit->id = base::Int64ToString(display.id()); |
| 43 unit->is_primary = (display.id() == primary_display_id); | 43 unit->is_primary = (display.id() == primary_display_id); |
| 44 unit->is_internal = display.IsInternal(); | 44 unit->is_internal = display.IsInternal(); |
| 45 unit->is_enabled = true; | 45 unit->is_enabled = true; |
| 46 unit->rotation = RotationToDegrees(display.rotation()); | 46 unit->rotation = RotationToDegrees(display.rotation()); |
| 47 unit->bounds.left = bounds.x(); | 47 unit->bounds.left = bounds.x(); |
| 48 unit->bounds.top = bounds.y(); | 48 unit->bounds.top = bounds.y(); |
| 49 unit->bounds.width = bounds.width(); | 49 unit->bounds.width = bounds.width(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 74 g_display_info_provider = display_info_provider; | 74 g_display_info_provider = display_info_provider; |
| 75 } | 75 } |
| 76 | 76 |
| 77 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { | 77 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { |
| 78 // TODO(scottmg): Native is wrong http://crbug.com/133312 | 78 // TODO(scottmg): Native is wrong http://crbug.com/133312 |
| 79 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 79 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
| 80 int64 primary_id = screen->GetPrimaryDisplay().id(); | 80 int64 primary_id = screen->GetPrimaryDisplay().id(); |
| 81 std::vector<gfx::Display> displays = screen->GetAllDisplays(); | 81 std::vector<gfx::Display> displays = screen->GetAllDisplays(); |
| 82 DisplayInfo all_displays; | 82 DisplayInfo all_displays; |
| 83 for (const gfx::Display& display : displays) { | 83 for (const gfx::Display& display : displays) { |
| 84 linked_ptr<core_api::system_display::DisplayUnitInfo> unit( | 84 linked_ptr<api::system_display::DisplayUnitInfo> unit( |
| 85 CreateDisplayUnitInfo(display, primary_id)); | 85 CreateDisplayUnitInfo(display, primary_id)); |
| 86 UpdateDisplayUnitInfoForPlatform(display, unit.get()); | 86 UpdateDisplayUnitInfoForPlatform(display, unit.get()); |
| 87 all_displays.push_back(unit); | 87 all_displays.push_back(unit); |
| 88 } | 88 } |
| 89 return all_displays; | 89 return all_displays; |
| 90 } | 90 } |
| 91 | 91 |
| 92 DisplayInfoProvider::DisplayInfoProvider() { | 92 DisplayInfoProvider::DisplayInfoProvider() { |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace extensions | 95 } // namespace extensions |
| OLD | NEW |