Chromium Code Reviews| Index: chrome/installer/util/registry_key_backup.h |
| diff --git a/chrome/installer/util/registry_key_backup.h b/chrome/installer/util/registry_key_backup.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..df46fa16120056080def7d1dd11607e5bb246c47 |
| --- /dev/null |
| +++ b/chrome/installer/util/registry_key_backup.h |
| @@ -0,0 +1,55 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ |
| +#define CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ |
| +#pragma once |
| + |
| +#include <windows.h> |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace base { |
| +namespace win { |
| +class RegKey; |
| +} |
|
erikwright (departed)
2011/09/15 18:38:57
} // namespace win
} // namespace base
grt (UTC plus 2)
2011/09/16 17:45:45
Done.
|
| +} |
| + |
| +// A container for a registry key, its values, and its subkeys. We don't use |
| +// more obvious methods for various reasons: |
| +// - RegCopyTree isn't supported pre-Vista, so we'd have to do something |
| +// different for XP anyway. |
| +// - SHCopyKey can't copy subkeys into a volatile destination, so we'd have to |
| +// worry about polluting the registry. |
| +// We don't persist security attributes since we only delete keys that we own, |
| +// and we don't set custom attributes on them anyway. |
| +class RegistryKeyBackup { |
| + public: |
| + RegistryKeyBackup(); |
| + ~RegistryKeyBackup(); |
| + |
| + // Backs up |key| into this instance. Returns true if the backup was |
| + // successful; false otherwise, in which case the state of this instance is |
| + // not modified. |
| + bool Initialize(const base::win::RegKey& key); |
| + |
| + // Writes the contents of this instance into |key|. |
| + bool WriteTo(base::win::RegKey* key) const; |
| + |
| + private: |
| + class RegistryValueBackup; |
| + |
| + scoped_array<RegistryValueBackup> values_; |
| + scoped_array<std::wstring> subkey_names_; |
| + scoped_array<RegistryKeyBackup> subkeys_; |
| + DWORD num_values_; |
| + DWORD num_subkeys_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RegistryKeyBackup); |
| +}; |
| + |
| +#endif // CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ |