Remove profile-based per-host & default zoom level migration code.
[chromium-blink-merge.git] / ui / base / layout.h
blobc0ca3cb65e4b08b546d4b43c1f5d454082e791db
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_BASE_LAYOUT_H_
6 #define UI_BASE_LAYOUT_H_
8 #include <vector>
10 #include "build/build_config.h"
11 #include "ui/base/ui_base_export.h"
12 #include "ui/gfx/native_widget_types.h"
14 namespace ui {
16 // Supported UI scale factors for the platform. This is used as an index
17 // into the array |kScaleFactorScales| which maps the enum value to a float.
18 // SCALE_FACTOR_NONE is used for density independent resources such as
19 // string, html/js files or an image that can be used for any scale factors
20 // (such as wallpapers).
21 enum ScaleFactor : int {
22 SCALE_FACTOR_NONE = 0,
23 SCALE_FACTOR_100P,
24 SCALE_FACTOR_125P,
25 SCALE_FACTOR_133P,
26 SCALE_FACTOR_140P,
27 SCALE_FACTOR_150P,
28 SCALE_FACTOR_180P,
29 SCALE_FACTOR_200P,
30 SCALE_FACTOR_250P,
31 SCALE_FACTOR_300P,
33 NUM_SCALE_FACTORS // This always appears last.
36 // Changes the value of GetSupportedScaleFactors() to |scale_factors|.
37 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
38 // state of other tests.
39 UI_BASE_EXPORT void SetSupportedScaleFactors(
40 const std::vector<ScaleFactor>& scale_factors);
42 // Returns a vector with the scale factors which are supported by this
43 // platform, in ascending order.
44 UI_BASE_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors();
46 // Returns the supported ScaleFactor which most closely matches |scale|.
47 // Converting from float to ScaleFactor is inefficient and should be done as
48 // little as possible.
49 UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale);
51 // Returns the ScaleFactor used by |view|.
52 UI_BASE_EXPORT float GetScaleFactorForNativeView(gfx::NativeView view);
54 // Returns the image scale for the scale factor passed in.
55 UI_BASE_EXPORT float GetScaleForScaleFactor(ScaleFactor scale_factor);
57 // Returns true if the scale passed in is the list of supported scales for
58 // the platform.
59 UI_BASE_EXPORT bool IsSupportedScale(float scale);
61 namespace test {
62 // Class which changes the value of GetSupportedScaleFactors() to
63 // |new_scale_factors| for the duration of its lifetime.
64 class UI_BASE_EXPORT ScopedSetSupportedScaleFactors {
65 public:
66 explicit ScopedSetSupportedScaleFactors(
67 const std::vector<ui::ScaleFactor>& new_scale_factors);
68 ~ScopedSetSupportedScaleFactors();
70 private:
71 std::vector<ui::ScaleFactor>* original_scale_factors_;
73 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors);
76 } // namespace test
78 } // namespace ui
80 #endif // UI_BASE_LAYOUT_H_