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

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

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 4 years, 12 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/gfx/display.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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*
55 DisplayInfoProvider::CreateDisplayUnitInfo(const gfx::Display& display, 55 DisplayInfoProvider::CreateDisplayUnitInfo(const gfx::Display& display,
56 int64 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(); 58 new api::system_display::DisplayUnitInfo();
59 const gfx::Rect& bounds = display.bounds(); 59 const gfx::Rect& bounds = display.bounds();
60 const gfx::Rect& work_area = display.work_area(); 60 const gfx::Rect& work_area = display.work_area();
61 unit->id = base::Int64ToString(display.id()); 61 unit->id = base::Int64ToString(display.id());
62 unit->is_primary = (display.id() == primary_display_id); 62 unit->is_primary = (display.id() == primary_display_id);
63 unit->is_internal = display.IsInternal(); 63 unit->is_internal = display.IsInternal();
64 unit->is_enabled = true; 64 unit->is_enabled = true;
65 unit->rotation = RotationToDegrees(display.rotation()); 65 unit->rotation = RotationToDegrees(display.rotation());
66 unit->bounds.left = bounds.x(); 66 unit->bounds.left = bounds.x();
67 unit->bounds.top = bounds.y(); 67 unit->bounds.top = bounds.y();
68 unit->bounds.width = bounds.width(); 68 unit->bounds.width = bounds.width();
69 unit->bounds.height = bounds.height(); 69 unit->bounds.height = bounds.height();
70 unit->work_area.left = work_area.x(); 70 unit->work_area.left = work_area.x();
71 unit->work_area.top = work_area.y(); 71 unit->work_area.top = work_area.y();
72 unit->work_area.width = work_area.width(); 72 unit->work_area.width = work_area.width();
73 unit->work_area.height = work_area.height(); 73 unit->work_area.height = work_area.height();
74 return unit; 74 return unit;
75 } 75 }
76 76
77 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {} 77 void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {}
78 78
79 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { 79 DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() {
80 // TODO(scottmg): Native is wrong http://crbug.com/133312 80 // TODO(scottmg): Native is wrong http://crbug.com/133312
81 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 81 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
82 int64 primary_id = screen->GetPrimaryDisplay().id(); 82 int64_t primary_id = screen->GetPrimaryDisplay().id();
83 std::vector<gfx::Display> displays = screen->GetAllDisplays(); 83 std::vector<gfx::Display> displays = screen->GetAllDisplays();
84 DisplayInfo all_displays; 84 DisplayInfo all_displays;
85 for (const gfx::Display& display : displays) { 85 for (const gfx::Display& display : displays) {
86 linked_ptr<api::system_display::DisplayUnitInfo> unit( 86 linked_ptr<api::system_display::DisplayUnitInfo> unit(
87 CreateDisplayUnitInfo(display, primary_id)); 87 CreateDisplayUnitInfo(display, primary_id));
88 UpdateDisplayUnitInfoForPlatform(display, unit.get()); 88 UpdateDisplayUnitInfoForPlatform(display, unit.get());
89 all_displays.push_back(unit); 89 all_displays.push_back(unit);
90 } 90 }
91 return all_displays; 91 return all_displays;
92 } 92 }
93 93
94 DisplayInfoProvider::DisplayInfoProvider() { 94 DisplayInfoProvider::DisplayInfoProvider() {
95 } 95 }
96 96
97 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698