Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ | |
| 6 #define CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <windows.h> | |
| 10 | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 | |
| 16 namespace base { | |
| 17 namespace win { | |
| 18 class RegKey; | |
| 19 } | |
|
erikwright (departed)
2011/09/15 18:38:57
} // namespace win
} // namespace base
grt (UTC plus 2)
2011/09/16 17:45:45
Done.
| |
| 20 } | |
| 21 | |
| 22 // A container for a registry key, its values, and its subkeys. We don't use | |
| 23 // more obvious methods for various reasons: | |
| 24 // - RegCopyTree isn't supported pre-Vista, so we'd have to do something | |
| 25 // different for XP anyway. | |
| 26 // - SHCopyKey can't copy subkeys into a volatile destination, so we'd have to | |
| 27 // worry about polluting the registry. | |
| 28 // We don't persist security attributes since we only delete keys that we own, | |
| 29 // and we don't set custom attributes on them anyway. | |
| 30 class RegistryKeyBackup { | |
| 31 public: | |
| 32 RegistryKeyBackup(); | |
| 33 ~RegistryKeyBackup(); | |
| 34 | |
| 35 // Backs up |key| into this instance. Returns true if the backup was | |
| 36 // successful; false otherwise, in which case the state of this instance is | |
| 37 // not modified. | |
| 38 bool Initialize(const base::win::RegKey& key); | |
| 39 | |
| 40 // Writes the contents of this instance into |key|. | |
| 41 bool WriteTo(base::win::RegKey* key) const; | |
| 42 | |
| 43 private: | |
| 44 class RegistryValueBackup; | |
| 45 | |
| 46 scoped_array<RegistryValueBackup> values_; | |
| 47 scoped_array<std::wstring> subkey_names_; | |
| 48 scoped_array<RegistryKeyBackup> subkeys_; | |
| 49 DWORD num_values_; | |
| 50 DWORD num_subkeys_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(RegistryKeyBackup); | |
| 53 }; | |
| 54 | |
| 55 #endif // CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_ | |
| OLD | NEW |