OLD | NEW |
| (Empty) |
1 // Copyright 2014 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. | |
4 | |
5 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h" | |
6 | |
7 #include "base/metrics/field_trial.h" | |
8 #include "base/win/registry.h" | |
9 #include "chrome/common/chrome_constants.h" | |
10 #include "chrome/common/chrome_version_info.h" | |
11 | |
12 #if defined(OS_WIN) | |
13 #if defined(GOOGLE_CHROME_BUILD) | |
14 #define PRODUCT_STRING_PATH L"Google\\Chrome" | |
15 #elif defined(CHROMIUM_BUILD) | |
16 #define PRODUCT_STRING_PATH L"Chromium" | |
17 #else | |
18 #error Unknown branding | |
19 #endif | |
20 #endif // defined(OS_WIN) | |
21 | |
22 namespace { | |
23 | |
24 wchar_t* GetBeaconKeyPath() { | |
25 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
26 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | |
27 return L"SOFTWARE\\" PRODUCT_STRING_PATH | |
28 L"\\DisableTerminateOnProcessHeapCorruptionSxs"; | |
29 } | |
30 return L"SOFTWARE\\" PRODUCT_STRING_PATH | |
31 L"\\DisableTerminateOnProcessHeapCorruption"; | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 bool ShouldExperimentallyDisableTerminateOnHeapCorruption() { | |
37 base::win::RegKey regkey( | |
38 HKEY_CURRENT_USER, GetBeaconKeyPath(), KEY_QUERY_VALUE); | |
39 return regkey.Valid(); | |
40 } | |
41 | |
42 void InitializeDisableTerminateOnHeapCorruptionExperiment() { | |
43 base::win::RegKey regkey(HKEY_CURRENT_USER); | |
44 | |
45 if (base::FieldTrialList::FindFullName("TerminateOnProcessHeapCorruption") == | |
46 "Disabled") { | |
47 regkey.CreateKey(GetBeaconKeyPath(), KEY_SET_VALUE); | |
48 } else { | |
49 regkey.DeleteKey(GetBeaconKeyPath()); | |
50 } | |
51 } | |
OLD | NEW |