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

Side by Side Diff: chrome/browser/extensions/display_info_provider_win.cc

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback EXCEPT rect_util Rename Created 4 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/display_info_provider_win.h" 5 #include "chrome/browser/extensions/display_info_provider_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/hash.h" 10 #include "base/hash.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/win/win_util.h" 13 #include "base/win/win_util.h"
14 #include "extensions/common/api/system_display.h" 14 #include "extensions/common/api/system_display.h"
15 #include "ui/gfx/display.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/win/dpi.h" 17 #include "ui/gfx/win/dpi.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 using api::system_display::DisplayUnitInfo; 21 using api::system_display::DisplayUnitInfo;
21 22
22 namespace { 23 namespace {
23 24
24 BOOL CALLBACK 25 BOOL CALLBACK
25 EnumMonitorCallback(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) { 26 EnumMonitorCallback(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) {
26 DisplayInfo* all_displays = reinterpret_cast<DisplayInfo*>(data); 27 DisplayInfo* all_displays = reinterpret_cast<DisplayInfo*>(data);
27 DCHECK(all_displays); 28 DCHECK(all_displays);
28 29
29 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo); 30 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo);
30 31
31 MONITORINFOEX monitor_info; 32 MONITORINFOEX monitor_info;
32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); 33 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX));
33 monitor_info.cbSize = sizeof(monitor_info); 34 monitor_info.cbSize = sizeof(monitor_info);
34 GetMonitorInfo(monitor, &monitor_info); 35 GetMonitorInfo(monitor, &monitor_info);
35 36
36 DISPLAY_DEVICE device; 37 DISPLAY_DEVICE device;
37 device.cb = sizeof(device); 38 device.cb = sizeof(device);
38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) 39 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0))
39 return FALSE; 40 return FALSE;
40 41
41 gfx::Size dpi(gfx::GetDPI());
42 unit->id = 42 unit->id =
43 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice))); 43 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice)));
44 unit->name = base::WideToUTF8(device.DeviceString); 44 unit->name = base::WideToUTF8(device.DeviceString);
45 unit->dpi_x = dpi.width();
46 unit->dpi_y = dpi.height();
47 all_displays->push_back(unit); 45 all_displays->push_back(unit);
48 46
49 return TRUE; 47 return TRUE;
50 } 48 }
51 49
52 } // namespace 50 } // namespace
53 51
54 DisplayInfoProviderWin::DisplayInfoProviderWin() { 52 DisplayInfoProviderWin::DisplayInfoProviderWin() {
55 } 53 }
56 54
(...skipping 10 matching lines...) Expand all
67 65
68 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform( 66 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform(
69 const gfx::Display& display, 67 const gfx::Display& display,
70 extensions::api::system_display::DisplayUnitInfo* unit) { 68 extensions::api::system_display::DisplayUnitInfo* unit) {
71 DisplayInfo all_displays; 69 DisplayInfo all_displays;
72 EnumDisplayMonitors( 70 EnumDisplayMonitors(
73 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays)); 71 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays));
74 for (size_t i = 0; i < all_displays.size(); ++i) { 72 for (size_t i = 0; i < all_displays.size(); ++i) {
75 if (unit->id == all_displays[i]->id) { 73 if (unit->id == all_displays[i]->id) {
76 unit->name = all_displays[i]->name; 74 unit->name = all_displays[i]->name;
77 unit->dpi_x = all_displays[i]->dpi_x; 75 int dpi = gfx::GetDPIFromScalingFactor(display.device_scale_factor());
78 unit->dpi_y = all_displays[i]->dpi_y; 76 unit->dpi_x = dpi;
77 unit->dpi_y = dpi;
79 break; 78 break;
80 } 79 }
81 } 80 }
82 } 81 }
83 82
84 // static 83 // static
85 DisplayInfoProvider* DisplayInfoProvider::Create() { 84 DisplayInfoProvider* DisplayInfoProvider::Create() {
86 return new DisplayInfoProviderWin(); 85 return new DisplayInfoProviderWin();
87 } 86 }
88 87
89 } // namespace extensions 88 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698