| 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 "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
| 6 | 6 |
| 7 #include <aclapi.h> | 7 #include <aclapi.h> |
| 8 #include <shobjidl.h> // Must be before propkey. | 8 #include <shobjidl.h> // Must be before propkey. |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
| 11 #include <sddl.h> | 11 #include <sddl.h> |
| 12 #include <shlobj.h> | 12 #include <shlobj.h> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/win/registry.h" | 16 #include "base/win/registry.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
| 21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 namespace win { | 24 namespace win { |
| 25 | 25 |
| 26 static bool g_crash_on_process_detach = false; |
| 27 |
| 26 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ | 28 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ |
| 27 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) | 29 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) |
| 28 | 30 |
| 29 void GetNonClientMetrics(NONCLIENTMETRICS* metrics) { | 31 void GetNonClientMetrics(NONCLIENTMETRICS* metrics) { |
| 30 DCHECK(metrics); | 32 DCHECK(metrics); |
| 31 | 33 |
| 32 static const UINT SIZEOF_NONCLIENTMETRICS = | 34 static const UINT SIZEOF_NONCLIENTMETRICS = |
| 33 (base::win::GetVersion() >= base::win::VERSION_VISTA) ? | 35 (base::win::GetVersion() >= base::win::VERSION_VISTA) ? |
| 34 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; | 36 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; |
| 35 metrics->cbSize = SIZEOF_NONCLIENTMETRICS; | 37 metrics->cbSize = SIZEOF_NONCLIENTMETRICS; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return (autorun_key.DeleteValue(name.c_str()) == ERROR_SUCCESS); | 143 return (autorun_key.DeleteValue(name.c_str()) == ERROR_SUCCESS); |
| 142 } | 144 } |
| 143 | 145 |
| 144 bool ReadCommandFromAutoRun(HKEY root_key, | 146 bool ReadCommandFromAutoRun(HKEY root_key, |
| 145 const string16& name, | 147 const string16& name, |
| 146 string16* command) { | 148 string16* command) { |
| 147 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_QUERY_VALUE); | 149 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_QUERY_VALUE); |
| 148 return (autorun_key.ReadValue(name.c_str(), command) == ERROR_SUCCESS); | 150 return (autorun_key.ReadValue(name.c_str(), command) == ERROR_SUCCESS); |
| 149 } | 151 } |
| 150 | 152 |
| 153 void SetShouldCrashOnProcessDetach(bool crash) { |
| 154 g_crash_on_process_detach = crash; |
| 155 } |
| 156 |
| 157 bool ShouldCrashOnProcessDetach() { |
| 158 return g_crash_on_process_detach; |
| 159 } |
| 160 |
| 151 } // namespace win | 161 } // namespace win |
| 152 } // namespace base | 162 } // namespace base |
| 153 | 163 |
| 154 #ifdef _MSC_VER | 164 #ifdef _MSC_VER |
| 155 // | 165 // |
| 156 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1. | 166 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1. |
| 157 // | 167 // |
| 158 extern char VisualStudio2005ServicePack1Detection[10]; | 168 extern char VisualStudio2005ServicePack1Detection[10]; |
| 159 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*), | 169 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*), |
| 160 VS2005SP1Detect); | 170 VS2005SP1Detect); |
| 161 // | 171 // |
| 162 // Chrome requires at least Service Pack 1 for Visual Studio 2005. | 172 // Chrome requires at least Service Pack 1 for Visual Studio 2005. |
| 163 // | 173 // |
| 164 #endif // _MSC_VER | 174 #endif // _MSC_VER |
| 165 | 175 |
| 166 #ifndef COPY_FILE_COPY_SYMLINK | 176 #ifndef COPY_FILE_COPY_SYMLINK |
| 167 #error You must install the Windows 2008 or Vista Software Development Kit and \ | 177 #error You must install the Windows 2008 or Vista Software Development Kit and \ |
| 168 set it as your default include path to build this library. You can grab it by \ | 178 set it as your default include path to build this library. You can grab it by \ |
| 169 searching for "download windows sdk 2008" in your favorite web search engine. \ | 179 searching for "download windows sdk 2008" in your favorite web search engine. \ |
| 170 Also make sure you register the SDK with Visual Studio, by selecting \ | 180 Also make sure you register the SDK with Visual Studio, by selecting \ |
| 171 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ | 181 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ |
| 172 menu (see Start - All Programs - Microsoft Windows SDK - \ | 182 menu (see Start - All Programs - Microsoft Windows SDK - \ |
| 173 Visual Studio Registration). | 183 Visual Studio Registration). |
| 174 #endif | 184 #endif |
| OLD | NEW |