OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/win/registry.h" | 8 #include "base/win/registry.h" |
9 #include "chrome/browser/chrome_elf_init_win.h" | 9 #include "chrome/browser/chrome_elf_init_win.h" |
10 #include "chrome_elf/blacklist/blacklist.h" | 10 #include "chrome_elf/chrome_elf_constants.h" |
11 #include "version.h" // NOLINT | 11 #include "version.h" // NOLINT |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; | 15 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; |
16 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; | 16 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; |
17 | 17 |
18 // This enum is used to define the buckets for an enumerated UMA histogram. | 18 // This enum is used to define the buckets for an enumerated UMA histogram. |
19 // Hence, | 19 // Hence, |
20 // (a) existing enumerated constants should never be deleted or reordered, and | 20 // (a) existing enumerated constants should never be deleted or reordered, and |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER); | 57 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER); |
58 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath); | 58 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void BrowserBlacklistBeaconSetup() { | 62 void BrowserBlacklistBeaconSetup() { |
63 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, | 63 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, |
64 blacklist::kRegistryBeaconPath, | 64 blacklist::kRegistryBeaconPath, |
65 KEY_QUERY_VALUE | KEY_SET_VALUE); | 65 KEY_QUERY_VALUE | KEY_SET_VALUE); |
66 | 66 |
| 67 // No point in trying to continue if the registry key isn't valid. |
| 68 if (!blacklist_registry_key.Valid()) |
| 69 return; |
| 70 |
67 // Find the last recorded blacklist version. | 71 // Find the last recorded blacklist version. |
68 base::string16 blacklist_version; | 72 base::string16 blacklist_version; |
69 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion, | 73 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion, |
70 &blacklist_version); | 74 &blacklist_version); |
71 | 75 |
72 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) { | 76 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) { |
73 // The blacklist hasn't run for this version yet, so enable it. | 77 // The blacklist hasn't run for this version yet, so enable it. |
74 LONG set_version = blacklist_registry_key.WriteValue( | 78 LONG set_version = blacklist_registry_key.WriteValue( |
75 blacklist::kBeaconVersion, | 79 blacklist::kBeaconVersion, |
76 TEXT(CHROME_VERSION_STRING)); | 80 TEXT(CHROME_VERSION_STRING)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 116 |
113 // Since some part of the blacklist failed, ensure it is now disabled | 117 // Since some part of the blacklist failed, ensure it is now disabled |
114 // for this version. | 118 // for this version. |
115 if (blacklist_state != blacklist::BLACKLIST_DISABLED) { | 119 if (blacklist_state != blacklist::BLACKLIST_DISABLED) { |
116 blacklist_registry_key.WriteValue(blacklist::kBeaconState, | 120 blacklist_registry_key.WriteValue(blacklist::kBeaconState, |
117 blacklist::BLACKLIST_DISABLED); | 121 blacklist::BLACKLIST_DISABLED); |
118 } | 122 } |
119 } | 123 } |
120 } | 124 } |
121 } | 125 } |
OLD | NEW |