Chromium Code Reviews| Index: ui/display/win/screen_win.cc |
| diff --git a/ui/display/win/screen_win.cc b/ui/display/win/screen_win.cc |
| index a4ef468fa5d8a3cf6fd7a0decd940dfb1704fac2..2277ad50f37f101bad4efc26699f3d4d74d578ce 100644 |
| --- a/ui/display/win/screen_win.cc |
| +++ b/ui/display/win/screen_win.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| +#include "base/metrics/sparse_histogram.h" |
| #include "base/win/win_util.h" |
| #include "ui/display/display.h" |
| #include "ui/display/manager/display_layout.h" |
| @@ -411,6 +412,7 @@ void ScreenWin::Initialize() { |
| new gfx::SingletonHwndObserver( |
| base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); |
| UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); |
| + RecordDisplayScaleFactors(); |
| } |
| MONITORINFOEX ScreenWin::MonitorInfoFromScreenPoint( |
| @@ -548,5 +550,22 @@ ScreenWinDisplay ScreenWin::GetScreenWinDisplayVia(Getter getter, |
| return (g_screen_win_instance->*getter)(value); |
| } |
| +void ScreenWin::RecordDisplayScaleFactors() const { |
| + std::vector<int> unique_scale_factors; |
| + for (const auto& screen_win_display : screen_win_displays_) { |
| + const float scale_factor = |
| + screen_win_display.display().device_scale_factor(); |
| + // Clamp the reported value so that if it's wildly out-of-band we won't send |
| + // it to the backend. |
|
robliao
2016/07/20 19:56:59
Comment that we multiply by 100 due to the percent
Bret
2016/07/20 21:03:22
Added comment. Raw DPI is a lot less intuitive I t
|
| + const int reported_scale = std::min( |
| + std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); |
| + if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), |
| + reported_scale) == unique_scale_factors.end()) { |
| + unique_scale_factors.push_back(reported_scale); |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); |
| + } |
| + } |
| +} |
| + |
| } // namespace win |
| } // namespace display |