OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file declares util functions for setup project. It also declares a | 5 // This file declares util functions for setup project. It also declares a |
6 // few functions that the Chrome component updater uses for patching binary | 6 // few functions that the Chrome component updater uses for patching binary |
7 // deltas. | 7 // deltas. |
8 | 8 |
9 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 9 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
10 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 10 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
11 | 11 |
12 #include <windows.h> | |
13 #include <stdint.h> | 12 #include <stdint.h> |
14 | 13 |
15 #include <memory> | 14 #include <memory> |
16 #include <vector> | 15 #include <vector> |
17 | 16 |
18 #include "base/macros.h" | |
19 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
20 #include "base/time/time.h" | 18 #include "base/time/time.h" |
21 #include "base/win/scoped_handle.h" | |
22 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
23 #include "chrome/installer/util/lzma_util.h" | 20 #include "chrome/installer/util/lzma_util.h" |
24 #include "chrome/installer/util/util_constants.h" | 21 #include "chrome/installer/util/util_constants.h" |
25 | 22 |
26 class AppRegistrationData; | 23 class AppRegistrationData; |
27 | 24 |
28 namespace base { | 25 namespace base { |
29 class CommandLine; | 26 class CommandLine; |
30 class FilePath; | 27 class FilePath; |
31 class Version; | 28 class Version; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool AreBinariesInstalled(const InstallerState& installer_state); | 144 bool AreBinariesInstalled(const InstallerState& installer_state); |
148 | 145 |
149 // Removes leftover bits from features that have been removed from the product. | 146 // Removes leftover bits from features that have been removed from the product. |
150 void DoLegacyCleanups(const InstallerState& installer_state, | 147 void DoLegacyCleanups(const InstallerState& installer_state, |
151 InstallStatus install_status); | 148 InstallStatus install_status); |
152 | 149 |
153 // Returns the time of the start of the console user's Windows logon session, or | 150 // Returns the time of the start of the console user's Windows logon session, or |
154 // a null time in case of error. | 151 // a null time in case of error. |
155 base::Time GetConsoleSessionStartTime(); | 152 base::Time GetConsoleSessionStartTime(); |
156 | 153 |
157 // This class will enable the privilege defined by |privilege_name| on the | |
158 // current process' token. The privilege will be disabled upon the | |
159 // ScopedTokenPrivilege's destruction (unless it was already enabled when the | |
160 // ScopedTokenPrivilege object was constructed). | |
161 // Some privileges might require admin rights to be enabled (check is_enabled() | |
162 // to know whether |privilege_name| was successfully enabled). | |
163 class ScopedTokenPrivilege { | |
164 public: | |
165 explicit ScopedTokenPrivilege(const wchar_t* privilege_name); | |
166 ~ScopedTokenPrivilege(); | |
167 | |
168 // Always returns true unless the privilege could not be enabled. | |
169 bool is_enabled() const { return is_enabled_; } | |
170 | |
171 private: | |
172 // Always true unless the privilege could not be enabled. | |
173 bool is_enabled_; | |
174 | |
175 // A scoped handle to the current process' token. This will be closed | |
176 // preemptively should enabling the privilege fail in the constructor. | |
177 base::win::ScopedHandle token_; | |
178 | |
179 // The previous state of the privilege this object is responsible for. As set | |
180 // by AdjustTokenPrivileges() upon construction. | |
181 TOKEN_PRIVILEGES previous_privileges_; | |
182 | |
183 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTokenPrivilege); | |
184 }; | |
185 | |
186 } // namespace installer | 154 } // namespace installer |
187 | 155 |
188 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 156 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
OLD | NEW |