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_SET_REG_VALUE_WORK_ITEM_H__
6 #define CHROME_INSTALLER_UTIL_SET_REG_VALUE_WORK_ITEM_H__
13 #include "base/callback.h"
14 #include "chrome/installer/util/work_item.h"
16 // A WorkItem subclass that sets a registry value with REG_SZ, REG_DWORD, or
17 // REG_QWORD type at the specified path. The value is only set if the target key
19 class SetRegValueWorkItem
: public WorkItem
{
21 SetRegValueWorkItem(HKEY predefined_root
,
22 const std::wstring
& key_path
,
24 const std::wstring
& value_name
,
25 const std::wstring
& value_data
,
28 SetRegValueWorkItem(HKEY predefined_root
,
29 const std::wstring
& key_path
,
31 const std::wstring
& value_name
,
35 SetRegValueWorkItem(HKEY predefined_root
,
36 const std::wstring
& key_path
,
38 const std::wstring
& value_name
,
42 // Implies |overwrite_| and TYPE_SZ for now.
43 SetRegValueWorkItem(HKEY predefined_root
,
44 const std::wstring
& key_path
,
46 const std::wstring
& value_name
,
47 const GetValueFromExistingCallback
& get_value_callback
);
49 ~SetRegValueWorkItem() override
;
53 void Rollback() override
;
57 // The status before Do is called.
59 // One possible outcome after Do(). A new value is created under the key.
61 // One possible outcome after Do(). The previous value under the key has
64 // One possible outcome after Do(). No change is applied, either
65 // because we are not allowed to overwrite the previous value, or due to
66 // some errors like the key does not exist.
68 // The status after Do and Rollback is called.
72 // Root key of the target key under which the value is set. The root key can
73 // only be one of the predefined keys on Windows.
74 HKEY predefined_root_
;
76 // Path of the target key under which the value is set.
77 std::wstring key_path_
;
79 // Name of the value to be set.
80 std::wstring value_name_
;
82 // If this is set, it will be used to get the desired value to be set based on
83 // the existing value in the registry.
84 const GetValueFromExistingCallback get_value_callback_
;
86 // Whether to overwrite the existing value under the target key.
89 // Whether to force 32-bit or 64-bit view of the target key.
92 // Type of data to store
94 std::vector
<uint8
> value_
;
96 std::vector
<uint8
> previous_value_
;
98 SettingStatus status_
;
101 #endif // CHROME_INSTALLER_UTIL_SET_REG_VALUE_WORK_ITEM_H__