| Index: ui/base/scale.cc
|
| diff --git a/ui/base/scale.cc b/ui/base/scale.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c8ccb084a684ca50d3f37923a3b4d1af20ac6144
|
| --- /dev/null
|
| +++ b/ui/base/scale.cc
|
| @@ -0,0 +1,54 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/base/scale.h"
|
| +
|
| +#include "base/basictypes.h"
|
| +
|
| +#if defined(OS_WIN)
|
| +#include "ui/base/win/dpi.h"
|
| +#include "ui/base/win/metro.h"
|
| +#include <Windows.h>
|
| +#endif // defined(OS_WIN)
|
| +
|
| +namespace {
|
| +
|
| +#if defined(OS_WIN)
|
| +
|
| +void GetScaleImplWin(bool* use_metro, bool* use_hidpi) {
|
| +#if defined(ENABLE_METRO)
|
| + *use_metro = ui::IsInMetroMode();
|
| +#endif // defined(ENABLE_METRO)
|
| +#if defined(ENABLE_HIDPI)
|
| + *use_hidpi = ui::GetDPIScale() > 1.5;
|
| +#endif // defined(ENABLE_HIDPI)
|
| +}
|
| +
|
| +#endif // defined(OS_WIN)
|
| +
|
| +} // namespace
|
| +
|
| +namespace ui {
|
| +
|
| +const DisplayScale GetDisplayScale() {
|
| +#if defined(USE_ASH)
|
| + return DS_ASH;
|
| +#elif !defined(OS_WIN)
|
| + return DS_DESKTOP_100;
|
| +#else // On Windows.
|
| + bool use_metro = false;
|
| + bool use_hidpi = false;
|
| + GetScaleImplWin(&use_metro, &use_hidpi);
|
| + if (use_metro) {
|
| + // TODO(joi): Other Metro scales.
|
| + return DS_METRO_100;
|
| + } else if (use_hidpi) {
|
| + return DS_DESKTOP_200;
|
| + } else {
|
| + return DS_DESKTOP_100;
|
| + }
|
| +#endif // On Windows.
|
| +}
|
| +
|
| +} // namespace ui
|
|
|