| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 void DisplayInfoProvider::InitializeForTesting( | 46 void DisplayInfoProvider::InitializeForTesting( |
| 47 DisplayInfoProvider* display_info_provider) { | 47 DisplayInfoProvider* display_info_provider) { |
| 48 DCHECK(display_info_provider); | 48 DCHECK(display_info_provider); |
| 49 g_display_info_provider = display_info_provider; | 49 g_display_info_provider = display_info_provider; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 // Creates new DisplayUnitInfo struct for |display|. | 53 // Creates new DisplayUnitInfo struct for |display|. |
| 54 api::system_display::DisplayUnitInfo* | 54 api::system_display::DisplayUnitInfo DisplayInfoProvider::CreateDisplayUnitInfo( |
| 55 DisplayInfoProvider::CreateDisplayUnitInfo(const gfx::Display& display, | 55 const gfx::Display& display, |
| 56 int64_t primary_display_id) { | 56 int64_t primary_display_id) { |
| 57 api::system_display::DisplayUnitInfo* unit = | 57 api::system_display::DisplayUnitInfo unit; |
| 58 new api::system_display::DisplayUnitInfo(); | |
| 59 const gfx::Rect& bounds = display.bounds(); | 58 const gfx::Rect& bounds = display.bounds(); |
| 60 const gfx::Rect& work_area = display.work_area(); | 59 const gfx::Rect& work_area = display.work_area(); |
| 61 unit->id = base::Int64ToString(display.id()); | 60 unit.id = base::Int64ToString(display.id()); |
| 62 unit->is_primary = (display.id() == primary_display_id); | 61 unit.is_primary = (display.id() == primary_display_id); |
| 63 unit->is_internal = display.IsInternal(); | 62 unit.is_internal = display.IsInternal(); |
| 64 unit->is_enabled = true; | 63 unit.is_enabled = true; |
| 65 unit->rotation = RotationToDegrees(display.rotation()); | 64 unit.rotation = RotationToDegrees(display.rotation()); |
| 66 unit->bounds.left = bounds.x(); | 65 unit.bounds.left = bounds.x(); |
| 67 unit->bounds.top = bounds.y(); | 66 unit.bounds.top = bounds.y(); |
| 68 unit->bounds.width = bounds.width(); | 67 unit.bounds.width = bounds.width(); |
| 69 unit->bounds.height = bounds.height(); | 68 unit.bounds.height = bounds.height(); |
| 70 unit->work_area.left = work_area.x(); | 69 unit.work_area.left = work_area.x(); |
| 71 unit->work_area.top = work_area.y(); | 70 unit.work_area.top = work_area.y(); |
| 72 unit->work_area.width = work_area.width(); | 71 unit.work_area.width = work_area.width(); |
| 73 unit->work_area.height = work_area.height(); | 72 unit.work_area.height = work_area.height(); |
| 74 return unit; | 73 return unit; |
| 75 } | 74 } |
| 76 | 75 |
| 77 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {} | 76 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {} |
| 78 | 77 |
| 79 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { | 78 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { |
| 80 gfx::Screen* screen = gfx::Screen::GetScreen(); | 79 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 81 int64_t primary_id = screen->GetPrimaryDisplay().id(); | 80 int64_t primary_id = screen->GetPrimaryDisplay().id(); |
| 82 std::vector<gfx::Display> displays = screen->GetAllDisplays(); | 81 std::vector<gfx::Display> displays = screen->GetAllDisplays(); |
| 83 DisplayInfo all_displays; | 82 DisplayInfo all_displays; |
| 84 for (const gfx::Display& display : displays) { | 83 for (const gfx::Display& display : displays) { |
| 85 linked_ptr<api::system_display::DisplayUnitInfo> unit( | 84 api::system_display::DisplayUnitInfo unit = |
| 86 CreateDisplayUnitInfo(display, primary_id)); | 85 CreateDisplayUnitInfo(display, primary_id); |
| 87 UpdateDisplayUnitInfoForPlatform(display, unit.get()); | 86 UpdateDisplayUnitInfoForPlatform(display, &unit); |
| 88 all_displays.push_back(unit); | 87 all_displays.push_back(std::move(unit)); |
| 89 } | 88 } |
| 90 return all_displays; | 89 return all_displays; |
| 91 } | 90 } |
| 92 | 91 |
| 93 DisplayInfoProvider::DisplayInfoProvider() { | 92 DisplayInfoProvider::DisplayInfoProvider() { |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace extensions | 95 } // namespace extensions |
| OLD | NEW |