summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/DEPS1
-rw-r--r--chrome/browser/chrome_browser_main_win.cc3
-rw-r--r--chrome/browser/chrome_elf_init_unittest_win.cc111
-rw-r--r--chrome/browser/chrome_elf_init_win.cc103
-rw-r--r--chrome/browser/chrome_elf_init_win.h15
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome_elf/blacklist.gypi6
-rw-r--r--chrome_elf/blacklist/blacklist.cc74
-rw-r--r--chrome_elf/blacklist/blacklist.h32
-rw-r--r--chrome_elf/blacklist/test/blacklist_test.cc59
-rw-r--r--chrome_elf/chrome_elf.gyp1
-rw-r--r--chrome_elf/chrome_elf_main.cc2
-rw-r--r--tools/metrics/histograms/histograms.xml15
14 files changed, 382 insertions, 44 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index 8c6c296..b30f854 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -3,6 +3,7 @@ include_rules = [
"+ash",
"+chrome/app",
"+chrome/installer",
+ "+chrome_elf/blacklist",
"+chromeos",
"+components/autofill/content/browser",
"+components/autofill/content/common",
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc
index 9a19ceb..53745465 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -22,6 +22,7 @@
#include "base/win/windows_version.h"
#include "base/win/wrapped_window_proc.h"
#include "chrome/browser/browser_util_win.h"
+#include "chrome/browser/chrome_elf_init_win.h"
#include "chrome/browser/install_verification/win/install_verification.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
@@ -252,6 +253,8 @@ void ChromeBrowserMainPartsWin::PostBrowserStart() {
FROM_HERE,
base::Bind(&VerifyInstallation),
base::TimeDelta::FromSeconds(45));
+
+ InitializeChromeElf();
}
// static
diff --git a/chrome/browser/chrome_elf_init_unittest_win.cc b/chrome/browser/chrome_elf_init_unittest_win.cc
new file mode 100644
index 0000000..e08f69f
--- /dev/null
+++ b/chrome/browser/chrome_elf_init_unittest_win.cc
@@ -0,0 +1,111 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chrome_elf_init_win.h"
+
+#include "base/basictypes.h"
+#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/test/test_reg_util_win.h"
+#include "chrome/common/chrome_version_info.h"
+#include "chrome_elf/blacklist/blacklist.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class ChromeBlacklistTrialTest : public testing::Test {
+ protected:
+ ChromeBlacklistTrialTest() :
+ blacklist_registry_key_(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ KEY_QUERY_VALUE | KEY_SET_VALUE) {}
+
+ virtual void SetUp() OVERRIDE {
+ testing::Test::SetUp();
+
+ registry_util::RegistryOverrideManager override_manager;
+ override_manager.OverrideRegistry(HKEY_CURRENT_USER,
+ L"browser_blacklist_test");
+
+
+ }
+
+ DWORD GetBlacklistState() {
+ DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
+ blacklist_registry_key_.ReadValueDW(blacklist::kBeaconState,
+ &blacklist_state);
+
+ return blacklist_state;
+ }
+
+ base::string16 GetBlacklistVersion() {
+ base::string16 blacklist_version;
+ blacklist_registry_key_.ReadValue(blacklist::kBeaconVersion,
+ &blacklist_version);
+
+ return blacklist_version;
+ }
+
+ base::win::RegKey blacklist_registry_key_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialTest);
+};
+
+
+// Ensure that the default trial deletes any existing blacklist beacons.
+TEST_F(ChromeBlacklistTrialTest, DefaultRun) {
+ // Set some dummy values as beacons.
+ blacklist_registry_key_.WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_ENABLED);
+ blacklist_registry_key_.WriteValue(blacklist::kBeaconVersion, L"Data");
+
+ // This setup code should result in the default group, which should remove
+ // all the beacon values.
+ InitializeChromeElf();
+
+ // Ensure that invalid values are returned to indicate that the
+ // beacon values are gone.
+ ASSERT_EQ(blacklist::BLACKLIST_STATE_MAX, GetBlacklistState());
+ ASSERT_EQ(base::string16(), GetBlacklistVersion());
+}
+
+TEST_F(ChromeBlacklistTrialTest, VerifyFirstRun) {
+ BrowserBlacklistBeaconSetup();
+
+ // Verify the state is properly set after the first run.
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState());
+
+ chrome::VersionInfo version_info;
+ base::string16 version(base::UTF8ToUTF16(version_info.Version()));
+ ASSERT_EQ(version, GetBlacklistVersion());
+}
+
+TEST_F(ChromeBlacklistTrialTest, SetupFailed) {
+ // Set the registry to indicate that the blacklist setup is running,
+ // which means it failed to run correctly last time.
+ blacklist_registry_key_.WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_SETUP_RUNNING);
+
+ BrowserBlacklistBeaconSetup();
+
+ // Since the blacklist setup failed, it should now be disabled.
+ ASSERT_EQ(blacklist::BLACKLIST_DISABLED, GetBlacklistState());
+}
+
+TEST_F(ChromeBlacklistTrialTest, VersionChanged) {
+ // Mark the blacklist as disabled for an older version, so it should
+ // get enabled for this new version.
+ blacklist_registry_key_.WriteValue(blacklist::kBeaconVersion,
+ L"old_version");
+ blacklist_registry_key_.WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_DISABLED);
+
+ BrowserBlacklistBeaconSetup();
+
+ // The beacon should now be marked as enabled for the current version.
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState());
+
+ chrome::VersionInfo version_info;
+ base::string16 expected_version(base::UTF8ToUTF16(version_info.Version()));
+ ASSERT_EQ(expected_version, GetBlacklistVersion());
+}
diff --git a/chrome/browser/chrome_elf_init_win.cc b/chrome/browser/chrome_elf_init_win.cc
new file mode 100644
index 0000000..672b0a3
--- /dev/null
+++ b/chrome/browser/chrome_elf_init_win.cc
@@ -0,0 +1,103 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/win/registry.h"
+#include "chrome/browser/chrome_elf_init_win.h"
+#include "chrome_elf/blacklist/blacklist.h"
+#include "version.h" // NOLINT
+
+namespace {
+
+const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
+const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
+
+// This enum is used to define the buckets for an enumerated UMA histogram.
+// Hence,
+// (a) existing enumerated constants should never be deleted or reordered, and
+// (b) new constants should only be appended in front of
+// BLACKLIST_SETUP_EVENT_MAX.
+enum BlacklistSetupEventType {
+ // The blacklist beacon has placed to enable the browser blacklisting.
+ BLACKLIST_SETUP_ENABLED = 0,
+
+ // The blacklist was successfully enabled.
+ BLACKLIST_SETUP_RAN_SUCCESSFULLY,
+
+ // The blacklist setup code failed to execute.
+ BLACKLIST_SETUP_FAILED,
+
+ // Always keep this at the end.
+ BLACKLIST_SETUP_EVENT_MAX,
+};
+
+void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) {
+ UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
+ blacklist_setup_event,
+ BLACKLIST_SETUP_EVENT_MAX);
+}
+
+} // namespace
+
+void InitializeChromeElf() {
+ if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) ==
+ kBrowserBlacklistTrialEnabledGroupName) {
+ BrowserBlacklistBeaconSetup();
+ } else {
+ // Disable the blacklist for all future runs by removing the beacon.
+ base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER);
+ blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath);
+ }
+}
+
+void BrowserBlacklistBeaconSetup() {
+ base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ KEY_QUERY_VALUE | KEY_SET_VALUE);
+
+ // Find the last recorded blacklist version.
+ base::string16 blacklist_version;
+ blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
+ &blacklist_version);
+
+ if (blacklist_version != TEXT(CHROME_VERSION_STRING)) {
+ // The blacklist hasn't run for this version yet, so enable it.
+ LONG set_version = blacklist_registry_key.WriteValue(
+ blacklist::kBeaconVersion,
+ TEXT(CHROME_VERSION_STRING));
+
+ LONG set_state = blacklist_registry_key.WriteValue(
+ blacklist::kBeaconState,
+ blacklist::BLACKLIST_ENABLED);
+
+ // Only report the blacklist as getting setup when both registry writes
+ // succeed, since otherwise the blacklist wasn't properly setup.
+ if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
+ RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
+
+ // Don't try to record if the blacklist setup succeeded or failed in the
+ // run since it could have been from either this version or the previous
+ // version (since crashes occur before we set the version in the registry).
+ } else {
+ // The blacklist version didn't change, so record the results of the
+ // latest setup.
+ DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
+ blacklist_registry_key.ReadValueDW(blacklist::kBeaconState,
+ &blacklist_state);
+
+ // Record the results of the latest blacklist setup.
+ if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
+ RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY);
+ } else if (blacklist_state == blacklist::BLACKLIST_SETUP_RUNNING) {
+ RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED);
+
+ // Since the setup failed, mark the blacklist as disabled so we don't
+ // try it again for this version.
+ blacklist_registry_key.WriteValue(blacklist::kBeaconState,
+ blacklist::BLACKLIST_DISABLED);
+ }
+ }
+}
diff --git a/chrome/browser/chrome_elf_init_win.h b/chrome/browser/chrome_elf_init_win.h
new file mode 100644
index 0000000..850a608
--- /dev/null
+++ b/chrome/browser/chrome_elf_init_win.h
@@ -0,0 +1,15 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROME_ELF_INIT_WIN_H_
+#define CHROME_BROWSER_CHROME_ELF_INIT_WIN_H_
+
+// Prepare any initialization code for Chrome Elf's setup (This will generally
+// only affect future runs since Chrome Elf is already setup by this point).
+void InitializeChromeElf();
+
+// Set the required state for an enabled browser blacklist.
+void BrowserBlacklistBeaconSetup();
+
+#endif // CHROME_BROWSER_CHROME_ELF_INIT_WIN_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 218cf0b..afb6687 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -418,6 +418,8 @@
'browser/chrome_browser_main_win.h',
'browser/chrome_content_browser_client.cc',
'browser/chrome_content_browser_client.h',
+ 'browser/chrome_elf_init_win.cc',
+ 'browser/chrome_elf_init_win.h',
'browser/chrome_notification_types.h',
'browser/chrome_page_zoom.cc',
'browser/chrome_page_zoom.h',
@@ -3315,6 +3317,7 @@
'dependencies': [
'chrome_process_finder',
'installer_util_strings',
+ '../chrome_elf/chrome_elf.gyp:blacklist',
'../google_update/google_update.gyp:google_update',
'../third_party/iaccessible2/iaccessible2.gyp:iaccessible2',
'../third_party/isimpledom/isimpledom.gyp:isimpledom',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index f948753..9dfe997 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -591,6 +591,7 @@
'browser/captive_portal/testing_utils.cc',
'browser/captive_portal/testing_utils.h',
'browser/chrome_browser_application_mac_unittest.mm',
+ 'browser/chrome_elf_init_unittest_win.cc',
'browser/chrome_page_zoom_unittest.cc',
'browser/chrome_process_singleton_win_unittest.cc',
'browser/chromeos/accessibility/magnification_manager_unittest.cc',
diff --git a/chrome_elf/blacklist.gypi b/chrome_elf/blacklist.gypi
index ab5597d..2db4941 100644
--- a/chrome_elf/blacklist.gypi
+++ b/chrome_elf/blacklist.gypi
@@ -6,6 +6,9 @@
{
'target_name': 'blacklist',
'type': 'static_library',
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
'sources': [
'blacklist/blacklist.cc',
'blacklist/blacklist.h',
@@ -17,7 +20,8 @@
# as that would risk pulling in base's link-time dependencies which
# chrome_elf cannot do.
'../base/base.gyp:base_static',
- '../sandbox/sandbox.gyp:sandbox',
+ '../chrome/chrome.gyp:chrome_version_header',
+ '../sandbox/sandbox.gyp:sandbox',
],
},
{
diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc
index c7d1a5d..4c742e7 100644
--- a/chrome_elf/blacklist/blacklist.cc
+++ b/chrome_elf/blacklist/blacklist.cc
@@ -12,6 +12,7 @@
#include "sandbox/win/src/internal_types.h"
#include "sandbox/win/src/sandbox_utils.h"
#include "sandbox/win/src/service_resolver.h"
+#include "version.h" // NOLINT
// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
extern "C" IMAGE_DOS_HEADER __ImageBase;
@@ -22,6 +23,8 @@ const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {};
int g_troublesome_dlls_cur_index = 0;
const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon";
+const wchar_t kBeaconVersion[] = L"version";
+const wchar_t kBeaconState[] = L"state";
} // namespace blacklist
@@ -140,27 +143,58 @@ bool IsNonBrowserProcess() {
namespace blacklist {
-bool CreateBeacon() {
- HKEY beacon_key = NULL;
- DWORD disposition = 0;
- LONG result = ::RegCreateKeyEx(HKEY_CURRENT_USER,
- kRegistryBeaconPath,
- 0,
- NULL,
- 0,
- KEY_WRITE,
- NULL,
- &beacon_key,
- &disposition);
- bool success = (result == ERROR_SUCCESS &&
- disposition != REG_OPENED_EXISTING_KEY);
- if (result == ERROR_SUCCESS)
- ::RegCloseKey(beacon_key);
- return success;
+bool LeaveSetupBeacon() {
+ DWORD blacklist_state = BLACKLIST_DISABLED;
+ DWORD blacklist_state_size = sizeof(blacklist_state);
+ LONG result = ::RegGetValue(HKEY_CURRENT_USER,
+ kRegistryBeaconPath,
+ kBeaconState,
+ RRF_RT_REG_DWORD,
+ NULL,
+ &blacklist_state,
+ &blacklist_state_size);
+
+ if (blacklist_state != BLACKLIST_ENABLED ||
+ result != ERROR_SUCCESS)
+ return false;
+
+ // If the blacklist wasn't set as enabled for this version, don't
+ // use it.
+ wchar_t key_data[255] = {};
+ DWORD key_data_size = sizeof(key_data);
+ result = ::RegGetValue(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ blacklist::kBeaconVersion,
+ RRF_RT_REG_SZ,
+ NULL,
+ key_data,
+ &key_data_size);
+ if (wcscmp(key_data, TEXT(CHROME_VERSION_STRING)) != 0 ||
+ result != ERROR_SUCCESS)
+ return false;
+
+ // Mark the blacklist setup code as running so if it crashes the blacklist
+ // won't be enabled for the next run.
+ blacklist_state = BLACKLIST_SETUP_RUNNING;
+ result = ::RegSetKeyValue(HKEY_CURRENT_USER,
+ kRegistryBeaconPath,
+ kBeaconState,
+ REG_DWORD,
+ &blacklist_state,
+ sizeof(blacklist_state));
+
+ return (result == ERROR_SUCCESS);
}
-bool ClearBeacon() {
- LONG result = ::RegDeleteKey(HKEY_CURRENT_USER, kRegistryBeaconPath);
+bool ResetBeacon() {
+ DWORD blacklist_state = BLACKLIST_ENABLED;
+ LONG result = ::RegSetKeyValue(HKEY_CURRENT_USER,
+ kRegistryBeaconPath,
+ kBeaconState,
+ REG_DWORD,
+ &blacklist_state,
+ sizeof(blacklist_state));
+
return (result == ERROR_SUCCESS);
}
@@ -212,7 +246,7 @@ bool Initialize(bool force) {
return false;
// Check to see if a beacon is present, abort if so.
- if (!force && !CreateBeacon())
+ if (!force && !LeaveSetupBeacon())
return false;
// Don't try blacklisting on unsupported OS versions.
diff --git a/chrome_elf/blacklist/blacklist.h b/chrome_elf/blacklist/blacklist.h
index 5787ddd..08ca572 100644
--- a/chrome_elf/blacklist/blacklist.h
+++ b/chrome_elf/blacklist/blacklist.h
@@ -16,20 +16,36 @@ extern const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount];
// Cursor to the current last element in the blacklist.
extern int g_troublesome_dlls_cur_index;
-// The registry path of the blacklist beacon. Exposed here for testing.
+// The registry path of the blacklist beacon.
extern const wchar_t kRegistryBeaconPath[];
-// Attempts to create a beacon in the current user's registry hive.
-// If the beacon already exists or any other error occurs when creating the
-// beacon, returns false. Otherwise returns true.
+// The properties for the blacklist beacon.
+extern const wchar_t kBeaconVersion[];
+extern const wchar_t kBeaconState[];
+
+// The states for the blacklist setup code.
+enum BlacklistState {
+ BLACKLIST_DISABLED = 0,
+ BLACKLIST_ENABLED,
+ // The blacklist setup code is running. If this is still set at startup,
+ // it means the last setup crashed.
+ BLACKLIST_SETUP_RUNNING,
+ // Always keep this at the end.
+ BLACKLIST_STATE_MAX,
+};
+
+// Attempts to leave a beacon in the current user's registry hive.
+// If the blacklist beacon doesn't say it is enabled or there are any other
+// errors when creating the beacon, returns false. Otherwise returns true.
// The intent of the beacon is to act as an extra failure mode protection
// whereby if Chrome for some reason fails to start during blacklist setup,
// it will skip blacklisting on the subsequent run.
-bool CreateBeacon();
+bool LeaveSetupBeacon();
-// Looks for the beacon that CreateBeacon() creates and attempts to delete it.
-// Returns true if the beacon was found and deleted.
-bool ClearBeacon();
+// Looks for the beacon that LeaveSetupBeacon() creates and resets it to
+// to show the setup was successful.
+// Returns true if the beacon was successfully set to BLACKLIST_ENABLED.
+bool ResetBeacon();
// Adds the given dll name to the blacklist. Returns true if the dll name is in
// the blacklist when this returns, false on error. Note that this will copy
diff --git a/chrome_elf/blacklist/test/blacklist_test.cc b/chrome_elf/blacklist/test/blacklist_test.cc
index dbb662f..8666a81 100644
--- a/chrome_elf/blacklist/test/blacklist_test.cc
+++ b/chrome_elf/blacklist/test/blacklist_test.cc
@@ -14,6 +14,7 @@
#include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/blacklist/test/blacklist_test_main_dll.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "version.h" // NOLINT
const wchar_t kTestDllName1[] = L"blacklist_test_dll_1.dll";
const wchar_t kTestDllName2[] = L"blacklist_test_dll_2.dll";
@@ -37,9 +38,6 @@ class BlacklistTest : public testing::Test {
virtual void SetUp() {
// Force an import from blacklist_test_main_dll.
InitBlacklistTestDll();
-
- // Ensure that the beacon state starts off cleared.
- blacklist::ClearBeacon();
}
virtual void TearDown() {
@@ -52,17 +50,50 @@ TEST_F(BlacklistTest, Beacon) {
registry_util::RegistryOverrideManager override_manager;
override_manager.OverrideRegistry(HKEY_CURRENT_USER, L"beacon_test");
- // First call should succeed as the beacon is newly created.
- EXPECT_TRUE(blacklist::CreateBeacon());
-
- // Second call should fail indicating the beacon already existed.
- EXPECT_FALSE(blacklist::CreateBeacon());
-
- // First call should find the beacon and delete it.
- EXPECT_TRUE(blacklist::ClearBeacon());
-
- // Second call should fail to find the beacon and delete it.
- EXPECT_FALSE(blacklist::ClearBeacon());
+ // Ensure that the beacon state starts off enabled for this version.
+ DWORD blacklist_state = blacklist::BLACKLIST_ENABLED;
+ LONG result = ::RegSetKeyValue(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ blacklist::kBeaconState,
+ REG_DWORD,
+ &blacklist_state,
+ sizeof(blacklist_state));
+ ASSERT_EQ(result, ERROR_SUCCESS);
+
+ result = ::RegSetKeyValue(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ blacklist::kBeaconVersion,
+ REG_SZ,
+ TEXT(CHROME_VERSION_STRING),
+ sizeof(TEXT(CHROME_VERSION_STRING)));
+ ASSERT_EQ(result, ERROR_SUCCESS);
+
+ // First call should find the beacon and reset it.
+ EXPECT_TRUE(blacklist::ResetBeacon());
+
+ // First call should succeed as the beacon is enabled.
+ EXPECT_TRUE(blacklist::LeaveSetupBeacon());
+
+ // Second call should fail indicating the beacon wasn't set as enabled.
+ EXPECT_FALSE(blacklist::LeaveSetupBeacon());
+
+ // Resetting the beacon should work when setup beacon is present.
+ EXPECT_TRUE(blacklist::ResetBeacon());
+
+ // Change the version and ensure that the setup fails due to the version
+ // mismatch.
+ base::string16 different_version(L"other_version");
+ ASSERT_NE(different_version, TEXT(CHROME_VERSION_STRING));
+
+ result = ::RegSetKeyValue(HKEY_CURRENT_USER,
+ blacklist::kRegistryBeaconPath,
+ blacklist::kBeaconVersion,
+ REG_SZ,
+ different_version.c_str(),
+ sizeof(different_version));
+ ASSERT_EQ(result, ERROR_SUCCESS);
+
+ EXPECT_FALSE(blacklist::LeaveSetupBeacon());
}
TEST_F(BlacklistTest, AddAndRemoveModules) {
diff --git a/chrome_elf/chrome_elf.gyp b/chrome_elf/chrome_elf.gyp
index 7227fe6..8a4e87e 100644
--- a/chrome_elf/chrome_elf.gyp
+++ b/chrome_elf/chrome_elf.gyp
@@ -49,6 +49,7 @@
],
'include_dirs': [
'..',
+ '<(SHARED_INTERMEDIATE_DIR)',
],
'dependencies': [
'chrome_elf_lib',
diff --git a/chrome_elf/chrome_elf_main.cc b/chrome_elf/chrome_elf_main.cc
index 9ad8299..772c906 100644
--- a/chrome_elf/chrome_elf_main.cc
+++ b/chrome_elf/chrome_elf_main.cc
@@ -10,7 +10,7 @@
#include "chrome_elf/ntdll_cache.h"
void SignalChromeElf() {
- blacklist::ClearBeacon();
+ blacklist::ResetBeacon();
}
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 5bb638c..fac7bea 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -1268,6 +1268,15 @@ other types of suffix sets.
</summary>
</histogram>
+<histogram name="Blacklist.Setup" enum="BlacklistSetup">
+ <summary>
+ Records the successes and failures when running the browser blacklist setup
+ code. Used to determine if the blacklist is working as intended during
+ startup(since the blacklist runs before crash reporting is set up). This
+ only occurs on Windows.
+ </summary>
+</histogram>
+
<histogram name="Bluetooth.ConnectedDeviceCount" units="devices">
<summary>
Counts the number of simulataneously connected Bluetooth devices. Used to
@@ -22187,6 +22196,12 @@ other types of suffix sets.
<int value="2" label="Bad"/>
</enum>
+<enum name="BlacklistSetup" type="int">
+ <int value="0" label="Blacklist enabled"/>
+ <int value="1" label="Blacklist ran successfully."/>
+ <int value="2" label="Blacklist failed."/>
+</enum>
+
<enum name="BluetoothPairingMethod" type="int">
<int value="0" label="No user interaction required"/>
<int value="1" label="PIN Code requested from user"/>