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

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

Issue 476103002: Make DisplayInfoProvider an interface (Closed) Base URL: git@github.com:tmpsantos/chromium.git@display_info
Patch Set: Fixed GN and Windows build Created 6 years, 4 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
James Cook 2014/08/15 19:58:42 Shouldn't this include display_info_provider.h?
5 #include "chrome/browser/extensions/api/system_display/display_info_provider.h"
6
7 #include "base/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "chrome/browser/extensions/display_info_provider_impl.h"
8 #include "ui/gfx/display.h" 7 #include "ui/gfx/display.h"
9 #include "ui/gfx/screen.h" 8 #include "ui/gfx/screen.h"
10 9
11 namespace extensions { 10 namespace extensions {
12 11
13 namespace { 12 namespace {
14 13
15 // Converts Rotation enum to integer. 14 // Converts Rotation enum to integer.
16 int RotationToDegrees(gfx::Display::Rotation rotation) { 15 int RotationToDegrees(gfx::Display::Rotation rotation) {
17 switch (rotation) { 16 switch (rotation) {
(...skipping 25 matching lines...) Expand all
43 unit->bounds.top = bounds.y(); 42 unit->bounds.top = bounds.y();
44 unit->bounds.width = bounds.width(); 43 unit->bounds.width = bounds.width();
45 unit->bounds.height = bounds.height(); 44 unit->bounds.height = bounds.height();
46 unit->work_area.left = work_area.x(); 45 unit->work_area.left = work_area.x();
47 unit->work_area.top = work_area.y(); 46 unit->work_area.top = work_area.y();
48 unit->work_area.width = work_area.width(); 47 unit->work_area.width = work_area.width();
49 unit->work_area.height = work_area.height(); 48 unit->work_area.height = work_area.height();
50 return unit; 49 return unit;
51 } 50 }
52 51
53 DisplayInfoProvider* g_display_info_provider = NULL;
54
55 } // namespace 52 } // namespace
56 53
57 54
58 DisplayInfoProvider::DisplayInfoProvider() {} 55 DisplayInfoProvider::DisplayInfoProvider() {}
59 56
60 DisplayInfoProvider::~DisplayInfoProvider() {} 57 DisplayInfoProvider::~DisplayInfoProvider() {}
61 58
62 DisplayInfoProvider* DisplayInfoProvider::Get() {
63 if (g_display_info_provider == NULL)
64 g_display_info_provider = new DisplayInfoProvider();
65 return g_display_info_provider;
66 }
67
68 void DisplayInfoProvider::InitializeForTesting(
69 DisplayInfoProvider* display_info_provider) {
70 DCHECK(display_info_provider);
71 g_display_info_provider = display_info_provider;
72 }
73
74 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { 59 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() {
75 // TODO(scottmg): Native is wrong http://crbug.com/133312 60 // TODO(scottmg): Native is wrong http://crbug.com/133312
76 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 61 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
77 int64 primary_id = screen->GetPrimaryDisplay().id(); 62 int64 primary_id = screen->GetPrimaryDisplay().id();
78 std::vector<gfx::Display> displays = screen->GetAllDisplays(); 63 std::vector<gfx::Display> displays = screen->GetAllDisplays();
79 DisplayInfo all_displays; 64 DisplayInfo all_displays;
80 for (int i = 0; i < screen->GetNumDisplays(); ++i) { 65 for (int i = 0; i < screen->GetNumDisplays(); ++i) {
81 linked_ptr<extensions::api::system_display::DisplayUnitInfo> unit( 66 linked_ptr<extensions::api::system_display::DisplayUnitInfo> unit(
82 CreateDisplayUnitInfo(displays[i], primary_id)); 67 CreateDisplayUnitInfo(displays[i], primary_id));
83 UpdateDisplayUnitInfoForPlatform(displays[i], unit.get()); 68 UpdateDisplayUnitInfoForPlatform(displays[i], unit.get());
84 all_displays.push_back(unit); 69 all_displays.push_back(unit);
85 } 70 }
86 return all_displays; 71 return all_displays;
87 } 72 }
88 73
89 } // namespace extensions 74 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698