| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <shlwapi.h> // For SHDeleteKey. | 6 #include <shlwapi.h> // For SHDeleteKey. |
| 7 | 7 |
| 8 #include "base/registry.h" | 8 #include "base/registry.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/installer/util/browser_distribution.h" | 10 #include "chrome/installer/util/browser_distribution.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 virtual void SetUp() { | 30 virtual void SetUp() { |
| 31 // Wipe the keys we redirect to. | 31 // Wipe the keys we redirect to. |
| 32 // This gives us a stable run, even in the presence of previous | 32 // This gives us a stable run, even in the presence of previous |
| 33 // crashes or failures. | 33 // crashes or failures. |
| 34 LSTATUS err = SHDeleteKey(HKEY_CURRENT_USER, kHKCUReplacement); | 34 LSTATUS err = SHDeleteKey(HKEY_CURRENT_USER, kHKCUReplacement); |
| 35 EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); | 35 EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); |
| 36 err = SHDeleteKey(HKEY_CURRENT_USER, kHKLMReplacement); | 36 err = SHDeleteKey(HKEY_CURRENT_USER, kHKLMReplacement); |
| 37 EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); | 37 EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); |
| 38 | 38 |
| 39 // Create the keys we're redirecting HKCU and HKLM to. | 39 // Create the keys we're redirecting HKCU and HKLM to. |
| 40 ASSERT_TRUE(hkcu_.Create(HKEY_CURRENT_USER, kHKCUReplacement)); | 40 ASSERT_TRUE(hkcu_.Create(HKEY_CURRENT_USER, kHKCUReplacement, KEY_READ)); |
| 41 ASSERT_TRUE(hklm_.Create(HKEY_CURRENT_USER, kHKLMReplacement)); | 41 ASSERT_TRUE(hklm_.Create(HKEY_CURRENT_USER, kHKLMReplacement, KEY_READ)); |
| 42 | 42 |
| 43 // And do the switcharoo. | 43 // And do the switcharoo. |
| 44 ASSERT_EQ(ERROR_SUCCESS, | 44 ASSERT_EQ(ERROR_SUCCESS, |
| 45 ::RegOverridePredefKey(HKEY_CURRENT_USER, hkcu_.Handle())); | 45 ::RegOverridePredefKey(HKEY_CURRENT_USER, hkcu_.Handle())); |
| 46 ASSERT_EQ(ERROR_SUCCESS, | 46 ASSERT_EQ(ERROR_SUCCESS, |
| 47 ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, hklm_.Handle())); | 47 ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, hklm_.Handle())); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void TearDown() { | 50 virtual void TearDown() { |
| 51 // Undo the redirection. | 51 // Undo the redirection. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // - Finally restore the original value of ap key. | 343 // - Finally restore the original value of ap key. |
| 344 key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS); | 344 key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS); |
| 345 key.DeleteValue(google_update::kRegApField); | 345 key.DeleteValue(google_update::kRegApField); |
| 346 work_item_list->Rollback(); | 346 work_item_list->Rollback(); |
| 347 if (ap_key_deleted) { | 347 if (ap_key_deleted) { |
| 348 work_item_list.reset(WorkItem::CreateWorkItemList()); | 348 work_item_list.reset(WorkItem::CreateWorkItemList()); |
| 349 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value)) | 349 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value)) |
| 350 << "Failed to restore ap key."; | 350 << "Failed to restore ap key."; |
| 351 } | 351 } |
| 352 } | 352 } |
| OLD | NEW |