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. | 5 // This file declares util functions for setup project. |
6 | 6 |
7 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 7 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
8 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 8 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
16 #include "chrome/installer/util/util_constants.h" | 16 #include "chrome/installer/util/util_constants.h" |
17 | 17 |
18 class CommandLine; | 18 class CommandLine; |
| 19 class Version; |
| 20 |
| 21 namespace base { |
19 class FilePath; | 22 class FilePath; |
20 class Version; | 23 } |
21 | 24 |
22 namespace installer { | 25 namespace installer { |
23 | 26 |
24 class InstallationState; | 27 class InstallationState; |
25 class InstallerState; | 28 class InstallerState; |
26 class ProductState; | 29 class ProductState; |
27 | 30 |
28 // Apply a diff patch to source file. First tries to apply it using courgette | 31 // Apply a diff patch to source file. First tries to apply it using courgette |
29 // since it checks for courgette header and fails quickly. If that fails | 32 // since it checks for courgette header and fails quickly. If that fails |
30 // tries to apply the patch using regular bsdiff. Returns status code. | 33 // tries to apply the patch using regular bsdiff. Returns status code. |
31 // The installer stage is updated if |installer_state| is non-NULL. | 34 // The installer stage is updated if |installer_state| is non-NULL. |
32 int ApplyDiffPatch(const FilePath& src, | 35 int ApplyDiffPatch(const base::FilePath& src, |
33 const FilePath& patch, | 36 const base::FilePath& patch, |
34 const FilePath& dest, | 37 const base::FilePath& dest, |
35 const InstallerState* installer_state); | 38 const InstallerState* installer_state); |
36 | 39 |
37 // Find the version of Chrome from an install source directory. | 40 // Find the version of Chrome from an install source directory. |
38 // Chrome_path should contain at least one version folder. | 41 // Chrome_path should contain at least one version folder. |
39 // Returns the maximum version found or NULL if no version is found. | 42 // Returns the maximum version found or NULL if no version is found. |
40 Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path); | 43 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path); |
41 | 44 |
42 // Spawns a new process that waits for a specified amount of time before | 45 // Spawns a new process that waits for a specified amount of time before |
43 // attempting to delete |path|. This is useful for setup to delete the | 46 // attempting to delete |path|. This is useful for setup to delete the |
44 // currently running executable or a file that we cannot close right away but | 47 // currently running executable or a file that we cannot close right away but |
45 // estimate that it will be possible after some period of time. | 48 // estimate that it will be possible after some period of time. |
46 // Returns true if a new process was started, false otherwise. Note that | 49 // Returns true if a new process was started, false otherwise. Note that |
47 // given the nature of this function, it is not possible to know if the | 50 // given the nature of this function, it is not possible to know if the |
48 // delete operation itself succeeded. | 51 // delete operation itself succeeded. |
49 bool DeleteFileFromTempProcess(const FilePath& path, | 52 bool DeleteFileFromTempProcess(const base::FilePath& path, |
50 uint32 delay_before_delete_ms); | 53 uint32 delay_before_delete_ms); |
51 | 54 |
52 // Returns true and populates |setup_exe| with the path to an existing product | 55 // Returns true and populates |setup_exe| with the path to an existing product |
53 // installer if one is found that is newer than the currently running installer | 56 // installer if one is found that is newer than the currently running installer |
54 // (|installer_version|). | 57 // (|installer_version|). |
55 bool GetExistingHigherInstaller(const InstallationState& original_state, | 58 bool GetExistingHigherInstaller(const InstallationState& original_state, |
56 bool system_install, | 59 bool system_install, |
57 const Version& installer_version, | 60 const Version& installer_version, |
58 FilePath* setup_exe); | 61 base::FilePath* setup_exe); |
59 | 62 |
60 // Invokes the pre-existing |setup_exe| to handle the current operation (as | 63 // Invokes the pre-existing |setup_exe| to handle the current operation (as |
61 // dictated by |command_line|). An installerdata file, if specified, is first | 64 // dictated by |command_line|). An installerdata file, if specified, is first |
62 // unconditionally copied into place so that it will be in effect in case the | 65 // unconditionally copied into place so that it will be in effect in case the |
63 // invoked |setup_exe| runs the newly installed product prior to exiting. | 66 // invoked |setup_exe| runs the newly installed product prior to exiting. |
64 // Returns true if |setup_exe| was launched, false otherwise. | 67 // Returns true if |setup_exe| was launched, false otherwise. |
65 bool DeferToExistingInstall(const FilePath& setup_exe, | 68 bool DeferToExistingInstall(const base::FilePath& setup_exe, |
66 const CommandLine& command_line, | 69 const CommandLine& command_line, |
67 const InstallerState& installer_state, | 70 const InstallerState& installer_state, |
68 const FilePath& temp_path, | 71 const base::FilePath& temp_path, |
69 InstallStatus* install_status); | 72 InstallStatus* install_status); |
70 | 73 |
71 // This class will enable the privilege defined by |privilege_name| on the | 74 // This class will enable the privilege defined by |privilege_name| on the |
72 // current process' token. The privilege will be disabled upon the | 75 // current process' token. The privilege will be disabled upon the |
73 // ScopedTokenPrivilege's destruction (unless it was already enabled when the | 76 // ScopedTokenPrivilege's destruction (unless it was already enabled when the |
74 // ScopedTokenPrivilege object was constructed). | 77 // ScopedTokenPrivilege object was constructed). |
75 // Some privileges might require admin rights to be enabled (check is_enabled() | 78 // Some privileges might require admin rights to be enabled (check is_enabled() |
76 // to know whether |privilege_name| was successfully enabled). | 79 // to know whether |privilege_name| was successfully enabled). |
77 class ScopedTokenPrivilege { | 80 class ScopedTokenPrivilege { |
78 public: | 81 public: |
(...skipping 14 matching lines...) Expand all Loading... |
93 // The previous state of the privilege this object is responsible for. As set | 96 // The previous state of the privilege this object is responsible for. As set |
94 // by AdjustTokenPrivileges() upon construction. | 97 // by AdjustTokenPrivileges() upon construction. |
95 TOKEN_PRIVILEGES previous_privileges_; | 98 TOKEN_PRIVILEGES previous_privileges_; |
96 | 99 |
97 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTokenPrivilege); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTokenPrivilege); |
98 }; | 101 }; |
99 | 102 |
100 } // namespace installer | 103 } // namespace installer |
101 | 104 |
102 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 105 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
OLD | NEW |