Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: extensions/browser/api/system_display/display_info_provider.cc

Issue 1924133002: Rename gfx::Display/Screen to display::Display/Screen in extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/display/display.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/display/screen.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 namespace { 14 namespace {
15 15
16 // Created on demand and will leak when the process exits. 16 // Created on demand and will leak when the process exits.
17 DisplayInfoProvider* g_display_info_provider = NULL; 17 DisplayInfoProvider* g_display_info_provider = NULL;
18 18
19 // Converts Rotation enum to integer. 19 // Converts Rotation enum to integer.
20 int RotationToDegrees(gfx::Display::Rotation rotation) { 20 int RotationToDegrees(display::Display::Rotation rotation) {
21 switch (rotation) { 21 switch (rotation) {
22 case gfx::Display::ROTATE_0: 22 case display::Display::ROTATE_0:
23 return 0; 23 return 0;
24 case gfx::Display::ROTATE_90: 24 case display::Display::ROTATE_90:
25 return 90; 25 return 90;
26 case gfx::Display::ROTATE_180: 26 case display::Display::ROTATE_180:
27 return 180; 27 return 180;
28 case gfx::Display::ROTATE_270: 28 case display::Display::ROTATE_270:
29 return 270; 29 return 270;
30 } 30 }
31 return 0; 31 return 0;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 DisplayInfoProvider::~DisplayInfoProvider() {} 36 DisplayInfoProvider::~DisplayInfoProvider() {}
37 37
38 // static 38 // static
39 DisplayInfoProvider* DisplayInfoProvider::Get() { 39 DisplayInfoProvider* DisplayInfoProvider::Get() {
40 if (g_display_info_provider == NULL) 40 if (g_display_info_provider == NULL)
41 g_display_info_provider = DisplayInfoProvider::Create(); 41 g_display_info_provider = DisplayInfoProvider::Create();
42 return g_display_info_provider; 42 return g_display_info_provider;
43 } 43 }
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 DisplayInfoProvider::CreateDisplayUnitInfo( 54 api::system_display::DisplayUnitInfo DisplayInfoProvider::CreateDisplayUnitInfo(
55 const gfx::Display& display, 55 const display::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 const gfx::Rect& bounds = display.bounds(); 58 const gfx::Rect& bounds = display.bounds();
59 const gfx::Rect& work_area = display.work_area(); 59 const gfx::Rect& work_area = display.work_area();
60 unit.id = base::Int64ToString(display.id()); 60 unit.id = base::Int64ToString(display.id());
61 unit.is_primary = (display.id() == primary_display_id); 61 unit.is_primary = (display.id() == primary_display_id);
62 unit.is_internal = display.IsInternal(); 62 unit.is_internal = display.IsInternal();
63 unit.is_enabled = true; 63 unit.is_enabled = true;
64 unit.rotation = RotationToDegrees(display.rotation()); 64 unit.rotation = RotationToDegrees(display.rotation());
65 unit.bounds.left = bounds.x(); 65 unit.bounds.left = bounds.x();
66 unit.bounds.top = bounds.y(); 66 unit.bounds.top = bounds.y();
67 unit.bounds.width = bounds.width(); 67 unit.bounds.width = bounds.width();
68 unit.bounds.height = bounds.height(); 68 unit.bounds.height = bounds.height();
69 unit.work_area.left = work_area.x(); 69 unit.work_area.left = work_area.x();
70 unit.work_area.top = work_area.y(); 70 unit.work_area.top = work_area.y();
71 unit.work_area.width = work_area.width(); 71 unit.work_area.width = work_area.width();
72 unit.work_area.height = work_area.height(); 72 unit.work_area.height = work_area.height();
73 return unit; 73 return unit;
74 } 74 }
75 75
76 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {} 76 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {}
77 77
78 DisplayUnitInfoList DisplayInfoProvider::GetAllDisplaysInfo() { 78 DisplayUnitInfoList DisplayInfoProvider::GetAllDisplaysInfo() {
79 gfx::Screen* screen = gfx::Screen::GetScreen(); 79 display::Screen* screen = display::Screen::GetScreen();
80 int64_t primary_id = screen->GetPrimaryDisplay().id(); 80 int64_t primary_id = screen->GetPrimaryDisplay().id();
81 std::vector<gfx::Display> displays = screen->GetAllDisplays(); 81 std::vector<display::Display> displays = screen->GetAllDisplays();
82 DisplayUnitInfoList all_displays; 82 DisplayUnitInfoList all_displays;
83 for (const gfx::Display& display : displays) { 83 for (const display::Display& display : displays) {
84 api::system_display::DisplayUnitInfo unit = 84 api::system_display::DisplayUnitInfo unit =
85 CreateDisplayUnitInfo(display, primary_id); 85 CreateDisplayUnitInfo(display, primary_id);
86 UpdateDisplayUnitInfoForPlatform(display, &unit); 86 UpdateDisplayUnitInfoForPlatform(display, &unit);
87 all_displays.push_back(std::move(unit)); 87 all_displays.push_back(std::move(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698