| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 MONITORINFOEX monitor_info; | 32 MONITORINFOEX monitor_info; |
| 33 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); | 33 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); |
| 34 monitor_info.cbSize = sizeof(monitor_info); | 34 monitor_info.cbSize = sizeof(monitor_info); |
| 35 GetMonitorInfo(monitor, &monitor_info); | 35 GetMonitorInfo(monitor, &monitor_info); |
| 36 | 36 |
| 37 DISPLAY_DEVICE device; | 37 DISPLAY_DEVICE device; |
| 38 device.cb = sizeof(device); | 38 device.cb = sizeof(device); |
| 39 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) | 39 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0)) |
| 40 return FALSE; | 40 return FALSE; |
| 41 | 41 |
| 42 gfx::Size dpi(gfx::GetDPI()); | |
| 43 unit->id = | 42 unit->id = |
| 44 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice))); | 43 base::Int64ToString(base::Hash(base::WideToUTF8(monitor_info.szDevice))); |
| 45 unit->name = base::WideToUTF8(device.DeviceString); | 44 unit->name = base::WideToUTF8(device.DeviceString); |
| 46 unit->dpi_x = dpi.width(); | |
| 47 unit->dpi_y = dpi.height(); | |
| 48 all_displays->push_back(unit); | 45 all_displays->push_back(unit); |
| 49 | 46 |
| 50 return TRUE; | 47 return TRUE; |
| 51 } | 48 } |
| 52 | 49 |
| 53 } // namespace | 50 } // namespace |
| 54 | 51 |
| 55 DisplayInfoProviderWin::DisplayInfoProviderWin() { | 52 DisplayInfoProviderWin::DisplayInfoProviderWin() { |
| 56 } | 53 } |
| 57 | 54 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 | 65 |
| 69 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform( | 66 void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform( |
| 70 const gfx::Display& display, | 67 const gfx::Display& display, |
| 71 extensions::api::system_display::DisplayUnitInfo* unit) { | 68 extensions::api::system_display::DisplayUnitInfo* unit) { |
| 72 DisplayInfo all_displays; | 69 DisplayInfo all_displays; |
| 73 EnumDisplayMonitors( | 70 EnumDisplayMonitors( |
| 74 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays)); | 71 NULL, NULL, EnumMonitorCallback, reinterpret_cast<LPARAM>(&all_displays)); |
| 75 for (size_t i = 0; i < all_displays.size(); ++i) { | 72 for (size_t i = 0; i < all_displays.size(); ++i) { |
| 76 if (unit->id == all_displays[i]->id) { | 73 if (unit->id == all_displays[i]->id) { |
| 77 unit->name = all_displays[i]->name; | 74 unit->name = all_displays[i]->name; |
| 78 unit->dpi_x = all_displays[i]->dpi_x; | 75 int dpi = gfx::GetDPIFromScalingFactor(display.device_scale_factor()); |
| 79 unit->dpi_y = all_displays[i]->dpi_y; | 76 unit->dpi_x = dpi; |
| 77 unit->dpi_y = dpi; |
| 80 break; | 78 break; |
| 81 } | 79 } |
| 82 } | 80 } |
| 83 } | 81 } |
| 84 | 82 |
| 85 gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() { | 83 gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() { |
| 86 // TODO(scottmg): native screen is wrong http://crbug.com/133312 | 84 // TODO(scottmg): native screen is wrong http://crbug.com/133312 |
| 87 return gfx::Screen::GetNativeScreen(); | 85 return gfx::Screen::GetNativeScreen(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 // static | 88 // static |
| 91 DisplayInfoProvider* DisplayInfoProvider::Create() { | 89 DisplayInfoProvider* DisplayInfoProvider::Create() { |
| 92 return new DisplayInfoProviderWin(); | 90 return new DisplayInfoProviderWin(); |
| 93 } | 91 } |
| 94 | 92 |
| 95 } // namespace extensions | 93 } // namespace extensions |
| OLD | NEW |