Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / installer / util / set_reg_value_work_item.h
blobb5b3439a52dcec04439970c94a6fea22e5a165ab
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__
8 #include <windows.h>
10 #include <string>
11 #include <vector>
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
18 // exists.
19 class SetRegValueWorkItem : public WorkItem {
20 public:
21 SetRegValueWorkItem(HKEY predefined_root,
22 const std::wstring& key_path,
23 REGSAM wow64_access,
24 const std::wstring& value_name,
25 const std::wstring& value_data,
26 bool overwrite);
28 SetRegValueWorkItem(HKEY predefined_root,
29 const std::wstring& key_path,
30 REGSAM wow64_access,
31 const std::wstring& value_name,
32 DWORD value_data,
33 bool overwrite);
35 SetRegValueWorkItem(HKEY predefined_root,
36 const std::wstring& key_path,
37 REGSAM wow64_access,
38 const std::wstring& value_name,
39 int64 value_data,
40 bool overwrite);
42 // Implies |overwrite_| and TYPE_SZ for now.
43 SetRegValueWorkItem(HKEY predefined_root,
44 const std::wstring& key_path,
45 REGSAM wow64_access,
46 const std::wstring& value_name,
47 const GetValueFromExistingCallback& get_value_callback);
49 ~SetRegValueWorkItem() override;
51 bool Do() override;
53 void Rollback() override;
55 private:
56 enum SettingStatus {
57 // The status before Do is called.
58 SET_VALUE,
59 // One possible outcome after Do(). A new value is created under the key.
60 NEW_VALUE_CREATED,
61 // One possible outcome after Do(). The previous value under the key has
62 // been overwritten.
63 VALUE_OVERWRITTEN,
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.
67 VALUE_UNCHANGED,
68 // The status after Do and Rollback is called.
69 VALUE_ROLL_BACK
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.
87 bool overwrite_;
89 // Whether to force 32-bit or 64-bit view of the target key.
90 REGSAM wow64_access_;
92 // Type of data to store
93 DWORD type_;
94 std::vector<uint8> value_;
95 DWORD previous_type_;
96 std::vector<uint8> previous_value_;
98 SettingStatus status_;
101 #endif // CHROME_INSTALLER_UTIL_SET_REG_VALUE_WORK_ITEM_H__