| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <malloc.h> | 6 #include <malloc.h> |
| 7 #include <shellscalingapi.h> | 7 #include <shellscalingapi.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <tchar.h> | 9 #include <tchar.h> |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID); | 120 typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID); |
| 121 SetProcessDPIAwarePtr set_process_dpi_aware_func = | 121 SetProcessDPIAwarePtr set_process_dpi_aware_func = |
| 122 reinterpret_cast<SetProcessDPIAwarePtr>( | 122 reinterpret_cast<SetProcessDPIAwarePtr>( |
| 123 GetProcAddress(GetModuleHandleA("user32.dll"), | 123 GetProcAddress(GetModuleHandleA("user32.dll"), |
| 124 "SetProcessDPIAware")); | 124 "SetProcessDPIAware")); |
| 125 return set_process_dpi_aware_func && | 125 return set_process_dpi_aware_func && |
| 126 set_process_dpi_aware_func(); | 126 set_process_dpi_aware_func(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void EnableHighDPISupport() { | 129 void EnableHighDPISupport() { |
| 130 if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) { | 130 // Enable per-monitor DPI for Win10 or above instead of Win8.1 since Win8.1 |
| 131 // does not have EnableChildWindowDpiMessage, necessary for correct non-client |
| 132 // area scaling across monitors. |
| 133 bool allowed_platform = base::win::GetVersion() >= base::win::VERSION_WIN10; |
| 134 const base::CommandLine* command_line = |
| 135 base::CommandLine::ForCurrentProcess(); |
| 136 bool per_monitor_dpi_switch = |
| 137 command_line->HasSwitch(switches::kEnablePerMonitorDpi) && |
| 138 !command_line->HasSwitch(switches::kDisablePerMonitorDpi); |
| 139 PROCESS_DPI_AWARENESS process_dpi_awareness = |
| 140 allowed_platform && per_monitor_dpi_switch |
| 141 ? PROCESS_PER_MONITOR_DPI_AWARE |
| 142 : PROCESS_SYSTEM_DPI_AWARE; |
| 143 if (!SetProcessDpiAwarenessWrapper(process_dpi_awareness)) { |
| 131 SetProcessDPIAwareWrapper(); | 144 SetProcessDPIAwareWrapper(); |
| 132 } | 145 } |
| 133 } | 146 } |
| 134 | 147 |
| 135 // Returns true if |command_line| contains a /prefetch:# argument where # is in | 148 // Returns true if |command_line| contains a /prefetch:# argument where # is in |
| 136 // [1, 8]. | 149 // [1, 8]. |
| 137 bool HasValidWindowsPrefetchArgument(const base::CommandLine& command_line) { | 150 bool HasValidWindowsPrefetchArgument(const base::CommandLine& command_line) { |
| 138 const base::char16 kPrefetchArgumentPrefix[] = L"/prefetch:"; | 151 const base::char16 kPrefetchArgumentPrefix[] = L"/prefetch:"; |
| 139 | 152 |
| 140 for (const auto& arg : command_line.argv()) { | 153 for (const auto& arg : command_line.argv()) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 RemoveAppCompatFlagsEntry(); | 270 RemoveAppCompatFlagsEntry(); |
| 258 | 271 |
| 259 // Load and launch the chrome dll. *Everything* happens inside. | 272 // Load and launch the chrome dll. *Everything* happens inside. |
| 260 VLOG(1) << "About to load main DLL."; | 273 VLOG(1) << "About to load main DLL."; |
| 261 MainDllLoader* loader = MakeMainDllLoader(); | 274 MainDllLoader* loader = MakeMainDllLoader(); |
| 262 int rc = loader->Launch(instance); | 275 int rc = loader->Launch(instance); |
| 263 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 276 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 264 delete loader; | 277 delete loader; |
| 265 return rc; | 278 return rc; |
| 266 } | 279 } |
| OLD | NEW |