| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
| 11 #include "chrome/browser/chrome_elf_init_win.h" | 11 #include "chrome/browser/chrome_elf_init_win.h" |
| 12 #include "chrome_elf/blacklist/blacklist.h" | 12 #include "chrome_elf/blacklist/blacklist.h" |
| 13 #include "chrome_elf/chrome_elf_constants.h" | 13 #include "chrome_elf/chrome_elf_constants.h" |
| 14 #include "chrome_elf/dll_hash/dll_hash.h" | 14 #include "chrome_elf/dll_hash/dll_hash.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "version.h" // NOLINT | 16 #include "version.h" // NOLINT |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; | 20 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; |
| 21 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; | 21 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; |
| 22 | 22 |
| 23 // How long to wait, in seconds, before reporting for the second (and last | 23 // How long to wait, in seconds, before reporting for the second (and last |
| 24 // time), what dlls were blocked from the browser process. | 24 // time), what dlls were blocked from the browser process. |
| 25 const int kBlacklistReportingDelaySec = 600; | 25 const int kBlacklistReportingDelaySec = 600; |
| 26 | 26 |
| 27 // This enum is used to define the buckets for an enumerated UMA histogram. | 27 // This enum is used to define the buckets for an enumerated UMA histogram. |
| 28 // Hence, | 28 // Hence, |
| 29 // (a) existing enumerated constants should never be deleted or reordered, and | 29 // (a) existing enumerated constants should never be deleted or reordered, and |
| 30 // (b) new constants should only be appended in front of | 30 // (b) new constants should only be appended in front of |
| 31 // BLACKLIST_SETUP_EVENT_MAX. | 31 // BLACKLIST_SETUP_EVENT_MAX. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 int uma_hash = DllNameToHash(dll_name_utf8); | 75 int uma_hash = DllNameToHash(dll_name_utf8); |
| 76 | 76 |
| 77 UMA_HISTOGRAM_SPARSE_SLOWLY("Blacklist.Blocked", uma_hash); | 77 UMA_HISTOGRAM_SPARSE_SLOWLY("Blacklist.Blocked", uma_hash); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 void InitializeChromeElf() { | 83 void InitializeChromeElf() { |
| 84 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) == | 84 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) == |
| 85 kBrowserBlacklistTrialEnabledGroupName) { | 85 kBrowserBlacklistTrialDisabledGroupName) { |
| 86 BrowserBlacklistBeaconSetup(); | |
| 87 } else { | |
| 88 // Disable the blacklist for all future runs by removing the beacon. | 86 // Disable the blacklist for all future runs by removing the beacon. |
| 89 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER); | 87 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER); |
| 90 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath); | 88 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath); |
| 89 } else { |
| 90 BrowserBlacklistBeaconSetup(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Report all successful blacklist interceptions. | 93 // Report all successful blacklist interceptions. |
| 94 ReportSuccessfulBlocks(); | 94 ReportSuccessfulBlocks(); |
| 95 | 95 |
| 96 // Schedule another task to report all sucessful interceptions later. | 96 // Schedule another task to report all sucessful interceptions later. |
| 97 // This time delay should be long enough to catch any dlls that attempt to | 97 // This time delay should be long enough to catch any dlls that attempt to |
| 98 // inject after Chrome has started up. | 98 // inject after Chrome has started up. |
| 99 content::BrowserThread::PostDelayedTask( | 99 content::BrowserThread::PostDelayedTask( |
| 100 content::BrowserThread::UI, | 100 content::BrowserThread::UI, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 LONG set_state = blacklist_registry_key.WriteValue( | 153 LONG set_state = blacklist_registry_key.WriteValue( |
| 154 blacklist::kBeaconState, | 154 blacklist::kBeaconState, |
| 155 blacklist::BLACKLIST_ENABLED); | 155 blacklist::BLACKLIST_ENABLED); |
| 156 | 156 |
| 157 // Only report the blacklist as getting setup when both registry writes | 157 // Only report the blacklist as getting setup when both registry writes |
| 158 // succeed, since otherwise the blacklist wasn't properly setup. | 158 // succeed, since otherwise the blacklist wasn't properly setup. |
| 159 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 159 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
| 160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
| 161 } | 161 } |
| 162 } | 162 } |
| OLD | NEW |