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.
5 #ifndef CHROME_INSTALLER_UTIL_COPY_REG_KEY_WORK_ITEM_H_
6 #define CHROME_INSTALLER_UTIL_COPY_REG_KEY_WORK_ITEM_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/installer/util/registry_key_backup.h"
13 #include "chrome/installer/util/work_item.h"
15 // A WorkItem subclass that replaces the contents of one registry key with that
16 // of another (i.e., the destination is erased prior to the copy). Be aware
17 // that in the event of rollback the destination key's values and subkeys are
18 // restored but the key and its subkeys take on their default security
20 class CopyRegKeyWorkItem
: public WorkItem
{
22 virtual ~CopyRegKeyWorkItem();
23 virtual bool Do() OVERRIDE
;
24 virtual void Rollback() OVERRIDE
;
27 // Grant WorkItem access to the ctor (required by the existing WorkItem
29 friend class WorkItem
;
31 // Neither |source_key_path| nor |dest_key_path| may be empty.
32 // Only ALWAYS and IF_NOT_PRESENT are supported for |overwrite_option|.
33 CopyRegKeyWorkItem(HKEY predefined_key
,
34 const std::wstring
& source_key_path
,
35 const std::wstring
& dest_key_path
,
36 CopyOverWriteOption overwrite_option
);
38 // Root key in which we operate. The root key must be one of the predefined
40 HKEY predefined_root_
;
42 // Path of the key to be copied.
43 std::wstring source_key_path_
;
45 // Path of the destination key.
46 std::wstring dest_key_path_
;
48 // WorkItem::ALWAYS or WorkItem::IF_NOT_PRESENT.
49 CopyOverWriteOption overwrite_option_
;
51 // Backup of the destination key.
52 RegistryKeyBackup backup_
;
54 // Set to true after the destination is cleared for the copy.
55 bool cleared_destination_
;
57 DISALLOW_COPY_AND_ASSIGN(CopyRegKeyWorkItem
);
60 #endif // CHROME_INSTALLER_UTIL_COPY_REG_KEY_WORK_ITEM_H_