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

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

Issue 23441032: [SystemInfo API] Rewrite DisplayInfoProvider without SystemInfoProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 "chrome/browser/extensions/api/system_display/display_info_provider.h" 5 #include "chrome/browser/extensions/api/system_display/display_info_provider.h"
6 6
7 #include <windows.h>
8
9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/base/win/dpi.h"
11 #include "ui/gfx/display.h"
12 #include "ui/gfx/size.h"
13
14 namespace extensions { 7 namespace extensions {
15 8
16 using api::system_display::Bounds; 9 bool DisplayInfoProvider::SetInfo(const std::string& display_id,
17 using api::system_display::DisplayUnitInfo;
18
19 namespace {
20
21 BOOL CALLBACK EnumMonitorCallback(HMONITOR monitor,
22 HDC hdc,
23 LPRECT rect,
24 LPARAM data) {
25 DisplayInfo* display_info =
26 reinterpret_cast<DisplayInfo*>(data);
27 DCHECK(display_info);
28
29 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo);
30
31 MONITORINFOEX monitor_info;
32 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX));
33 monitor_info.cbSize = sizeof(monitor_info);
34 GetMonitorInfo(monitor, &monitor_info);
35
36 DISPLAY_DEVICE device;
37 device.cb = sizeof(device);
38 if (!EnumDisplayDevices(monitor_info.szDevice, 0, &device, 0))
39 return FALSE;
40
41 gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor));
42 display.set_work_area(gfx::Rect(monitor_info.rcWork));
43
44 gfx::Size dpi(ui::GetDPI());
45 unit->id = WideToUTF8(device.DeviceID);
46 unit->name = WideToUTF8(device.DeviceString);
47 unit->is_primary = monitor_info.dwFlags & MONITORINFOF_PRIMARY ? true : false;
48
49 // TODO(hongbo): Figure out how to determine whether the display monitor is
50 // internal or not.
51 unit->is_internal = false;
52 unit->is_enabled = device.StateFlags & DISPLAY_DEVICE_ACTIVE ? true : false;
53 unit->dpi_x = dpi.width();
54 unit->dpi_y = dpi.height();
55 unit->bounds.left = display.bounds().x();
56 unit->bounds.top = display.bounds().y();
57 unit->bounds.width = display.bounds().width();
58 unit->bounds.height = display.bounds().height();
59 unit->work_area.left = display.work_area().x();
60 unit->work_area.top = display.work_area().y();
61 unit->work_area.width = display.work_area().width();
62 unit->work_area.height = display.work_area().height();
63 display_info->push_back(unit);
64
65 return TRUE;
66 }
67
68 } // namespace
69
70 void DisplayInfoProvider::SetInfo(
71 const std::string& display_id,
72 const api::system_display::DisplayProperties& info, 10 const api::system_display::DisplayProperties& info,
73 const SetInfoCallback& callback) { 11 std::string* error) {
74 base::MessageLoopProxy::current()->PostTask( 12 *error = "Not implemented";
75 FROM_HERE,
76 base::Bind(callback, false, "Not implemented"));
77 }
78
79 // TODO(hongbo): consolidate implementation using gfx::Display/gfx::Screen.
80 bool DisplayInfoProvider::QueryInfo() {
81 info_.clear();
82
83 if (EnumDisplayMonitors(NULL, NULL, EnumMonitorCallback,
84 reinterpret_cast<LPARAM>(&info_)))
85 return true;
86 return false; 13 return false;
87 } 14 }
88 15
89 void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform( 16 void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform(
90 const gfx::Display& display, 17 const gfx::Display& display,
91 extensions::api::system_display::DisplayUnitInfo* unit) { 18 extensions::api::system_display::DisplayUnitInfo* unit) {
92 NOTIMPLEMENTED(); 19 NOTIMPLEMENTED();
93 } 20 }
94 21
95 } // namespace extensions 22 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698