Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: base/test/test_reg_util_win.cc

Issue 7669061: Tommi: I need an owner review for the chrome frame changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixing license issue from presubmit check Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/test_reg_util_win.h ('k') | chrome/installer/util/install_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_reg_util_win.cc
===================================================================
--- base/test/test_reg_util_win.cc (revision 0)
+++ base/test/test_reg_util_win.cc (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (c) 2011 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/test/test_reg_util_win.h"
+
+#include "base/logging.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace registry_util {
+
+const wchar_t RegistryOverrideManager::kTempTestKeyPath[] =
+ L"Software\\Chromium\\TempTestKeys";
+
+RegistryOverrideManager::ScopedRegistryKeyOverride::ScopedRegistryKeyOverride(
+ HKEY override,
+ const std::wstring& temp_name)
+ : override_(override),
+ temp_name_(temp_name) {
+ DCHECK(!temp_name_.empty());
+ std::wstring key_path(RegistryOverrideManager::kTempTestKeyPath);
+ key_path += L"\\" + temp_name_;
+ EXPECT_EQ(ERROR_SUCCESS,
+ temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS));
+ EXPECT_EQ(ERROR_SUCCESS,
+ ::RegOverridePredefKey(override_, temp_key_.Handle()));
+}
+
+RegistryOverrideManager::
+ ScopedRegistryKeyOverride::~ScopedRegistryKeyOverride() {
+ ::RegOverridePredefKey(override_, NULL);
+ // The temp key will be deleted via a call to DeleteAllTempKeys().
+}
+
+RegistryOverrideManager::RegistryOverrideManager() {
+ DeleteAllTempKeys();
+}
+
+RegistryOverrideManager::~RegistryOverrideManager() {
+ RemoveAllOverrides();
+}
+
+void RegistryOverrideManager::OverrideRegistry(HKEY override,
+ const std::wstring& temp_name) {
+ overrides_.push_back(new ScopedRegistryKeyOverride(override, temp_name));
+}
+
+void RegistryOverrideManager::RemoveAllOverrides() {
+ while (!overrides_.empty()) {
+ delete overrides_.back();
+ overrides_.pop_back();
+ }
+
+ DeleteAllTempKeys();
+}
+
+// static
+void RegistryOverrideManager::DeleteAllTempKeys() {
+ base::win::RegKey key;
+ if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS) == ERROR_SUCCESS) {
+ key.DeleteKey(kTempTestKeyPath);
+ }
+}
+
+} // namespace registry_util
Property changes on: base\test\test_reg_util_win.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « base/test/test_reg_util_win.h ('k') | chrome/installer/util/install_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698