OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ui/base/layout.h" | 5 #include "ui/base/layout.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/mac/mac_util.h" | 23 #include "base/mac/mac_util.h" |
24 #endif | 24 #endif |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "base/win/metro.h" | 27 #include "base/win/metro.h" |
28 #include <Windows.h> | 28 #include <Windows.h> |
29 #endif // defined(OS_WIN) | 29 #endif // defined(OS_WIN) |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
| 33 #if defined(OS_WIN) || defined(USE_ASH) |
33 // Helper function that determines whether we want to optimize the UI for touch. | 34 // Helper function that determines whether we want to optimize the UI for touch. |
34 bool UseTouchOptimizedUI() { | 35 bool UseTouchOptimizedUI() { |
35 // If --touch-optimized-ui is specified and not set to "auto", then override | 36 // If --touch-optimized-ui is specified and not set to "auto", then override |
36 // the hardware-determined setting (eg. for testing purposes). | 37 // the hardware-determined setting (eg. for testing purposes). |
37 static bool has_touch_optimized_ui = CommandLine::ForCurrentProcess()-> | 38 static bool has_touch_optimized_ui = CommandLine::ForCurrentProcess()-> |
38 HasSwitch(switches::kTouchOptimizedUI); | 39 HasSwitch(switches::kTouchOptimizedUI); |
39 if (has_touch_optimized_ui) { | 40 if (has_touch_optimized_ui) { |
40 const std::string switch_value = CommandLine::ForCurrentProcess()-> | 41 const std::string switch_value = CommandLine::ForCurrentProcess()-> |
41 GetSwitchValueASCII(switches::kTouchOptimizedUI); | 42 GetSwitchValueASCII(switches::kTouchOptimizedUI); |
42 | 43 |
43 // Note that simply specifying the switch is the same as enabled. | 44 // Note that simply specifying the switch is the same as enabled. |
44 if (switch_value.empty() || | 45 if (switch_value.empty() || |
45 switch_value == switches::kTouchOptimizedUIEnabled) { | 46 switch_value == switches::kTouchOptimizedUIEnabled) { |
46 return true; | 47 return true; |
47 } else if (switch_value == switches::kTouchOptimizedUIDisabled) { | 48 } else if (switch_value == switches::kTouchOptimizedUIDisabled) { |
48 return false; | 49 return false; |
49 } else if (switch_value != switches::kTouchOptimizedUIAuto) { | 50 } else if (switch_value != switches::kTouchOptimizedUIAuto) { |
50 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value; | 51 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value; |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
54 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
55 // On Windows, we use the touch layout only when we are running in | 56 // On Windows, we use the touch layout only when we are running in |
56 // Metro mode. | 57 // Metro mode. |
57 return base::win::IsMetroProcess() && base::win::IsTouchEnabled(); | 58 return base::win::IsMetroProcess() && base::win::IsTouchEnabled(); |
58 #else | 59 #else |
59 return false; | 60 return false; |
60 #endif | 61 #endif |
61 } | 62 } |
| 63 #endif // defined(OS_WIN) || defined(USE_ASH) |
62 | 64 |
63 const float kScaleFactorScales[] = {1.0f, 1.4f, 1.8f, 2.0f}; | 65 const float kScaleFactorScales[] = {1.0f, 1.4f, 1.8f, 2.0f}; |
64 COMPILE_ASSERT(ui::NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), | 66 COMPILE_ASSERT(ui::NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), |
65 kScaleFactorScales_incorrect_size); | 67 kScaleFactorScales_incorrect_size); |
66 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); | 68 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); |
67 | 69 |
68 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { | 70 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { |
69 static std::vector<ui::ScaleFactor>* supported_scale_factors = | 71 static std::vector<ui::ScaleFactor>* supported_scale_factors = |
70 new std::vector<ui::ScaleFactor>(); | 72 new std::vector<ui::ScaleFactor>(); |
71 if (supported_scale_factors->empty()) { | 73 if (supported_scale_factors->empty()) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return GetScaleFactorFromScale( | 162 return GetScaleFactorFromScale( |
161 root_window->compositor()->device_scale_factor()); | 163 root_window->compositor()->device_scale_factor()); |
162 #else | 164 #else |
163 NOTIMPLEMENTED(); | 165 NOTIMPLEMENTED(); |
164 return SCALE_FACTOR_NONE; | 166 return SCALE_FACTOR_NONE; |
165 #endif | 167 #endif |
166 } | 168 } |
167 #endif // !defined(OS_MACOSX) | 169 #endif // !defined(OS_MACOSX) |
168 | 170 |
169 } // namespace ui | 171 } // namespace ui |
OLD | NEW |