OLD | NEW |
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/display/win/dpi.h" |
15 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/win/dpi.h" | |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 using api::system_display::DisplayUnitInfo; | 20 using api::system_display::DisplayUnitInfo; |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 BOOL CALLBACK | 24 BOOL CALLBACK |
25 EnumMonitorCallback(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) { | 25 EnumMonitorCallback(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) { |
26 DisplayInfo* all_displays = reinterpret_cast<DisplayInfo*>(data); | 26 DisplayInfo* all_displays = reinterpret_cast<DisplayInfo*>(data); |
27 DCHECK(all_displays); | 27 DCHECK(all_displays); |
28 | 28 |
29 DisplayUnitInfo unit; | 29 DisplayUnitInfo unit; |
30 | 30 |
31 MONITORINFOEX monitor_info; | 31 MONITORINFOEX monitor_info; |
32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); | 32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); |
33 monitor_info.cbSize = sizeof(monitor_info); | 33 monitor_info.cbSize = sizeof(monitor_info); |
34 GetMonitorInfo(monitor, &monitor_info); | 34 GetMonitorInfo(monitor, &monitor_info); |
35 | 35 |
36 DISPLAY_DEVICE device; | 36 DISPLAY_DEVICE device; |
37 device.cb = sizeof(device); | 37 device.cb = sizeof(device); |
38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) | 38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) |
39 return FALSE; | 39 return FALSE; |
40 | 40 |
41 gfx::Size dpi(gfx::GetDPI()); | 41 gfx::Size dpi(display::win::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(); | 45 unit.dpi_x = dpi.width(); |
46 unit.dpi_y = dpi.height(); | 46 unit.dpi_y = dpi.height(); |
47 all_displays->push_back(std::move(unit)); | 47 all_displays->push_back(std::move(unit)); |
48 | 48 |
49 return TRUE; | 49 return TRUE; |
50 } | 50 } |
51 | 51 |
(...skipping 28 matching lines...) Expand all Loading... |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 // static | 84 // static |
85 DisplayInfoProvider* DisplayInfoProvider::Create() { | 85 DisplayInfoProvider* DisplayInfoProvider::Create() { |
86 return new DisplayInfoProviderWin(); | 86 return new DisplayInfoProviderWin(); |
87 } | 87 } |
88 | 88 |
89 } // namespace extensions | 89 } // namespace extensions |
OLD | NEW |