OLD | NEW |
| (Empty) |
1 // Copyright 2007-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #ifndef OMAHA_SETUP_SETUP_FILES_H__ | |
17 #define OMAHA_SETUP_SETUP_FILES_H__ | |
18 | |
19 #include <windows.h> | |
20 #include <atlstr.h> | |
21 #include <vector> | |
22 #include "base/basictypes.h" | |
23 | |
24 namespace omaha { | |
25 | |
26 struct Files { | |
27 const TCHAR* file_name; | |
28 }; | |
29 | |
30 class SetupFiles { | |
31 public: | |
32 explicit SetupFiles(bool is_machine); | |
33 ~SetupFiles(); | |
34 | |
35 HRESULT Init(); | |
36 | |
37 // Returns whether the same version of Google Update should be over-installed. | |
38 bool ShouldOverinstallSameVersion(); | |
39 | |
40 // Installs Google Update files but does not register or install any other | |
41 // applications. Returns whether Google Update was installed. | |
42 HRESULT Install(); | |
43 | |
44 // Rolls back the changes made during Install(). Call when Setup fails. | |
45 // Returns S_OK if there is nothing to do. | |
46 HRESULT RollBack(); | |
47 | |
48 // Uninstalls Google Update files installed by Install(). | |
49 void Uninstall(); | |
50 | |
51 int extra_code1() const { return extra_code1_; } | |
52 | |
53 private: | |
54 // Copies the shell to the version-independent location if needed. | |
55 HRESULT CopyShell(); | |
56 | |
57 // Determines whether to copy the shell to the version-independent location. | |
58 HRESULT ShouldCopyShell(const CString& shell_dir, | |
59 bool* should_copy, | |
60 bool* already_exists) const; | |
61 | |
62 // Saves the previous version of the shell in case we need to roll it back. | |
63 HRESULT SaveShellForRollback(const CString& shell_install_path); | |
64 | |
65 // Creates the lists of files that belong to Google Update. | |
66 HRESULT BuildFileLists(); | |
67 | |
68 // Copies file_names from the current directory to the destination directory. | |
69 HRESULT CopyInstallFiles(const std::vector<CString>& file_names, | |
70 const CString& destination_dir, | |
71 bool overwrite); | |
72 | |
73 // Copies each file from the source path to its corresponding destination | |
74 // path. Verifies the signature of the file on each side of the copy. | |
75 // If overwrite is true, files are moved to .old and scheduled for delete | |
76 // after reboot, which only works for elevated admins. | |
77 HRESULT CopyAndValidateFiles( | |
78 const std::vector<CString>& source_file_paths, | |
79 const std::vector<CString>& destination_file_paths, | |
80 bool overwrite); | |
81 | |
82 // Verifies the file is signed with the Google Certificate. | |
83 // Returns true if filepath is properly signed. | |
84 // Only verifies files if they are being installed to a secure location. | |
85 // If not an official build, allows the Google Test Certificate. | |
86 // Only checks certain extensions since not all extensions can be signed. | |
87 HRESULT VerifyFileSignature(const CString& filepath); | |
88 | |
89 // Returns whether an older shell version is compatible. | |
90 static bool IsOlderShellVersionCompatible(ULONGLONG version); | |
91 | |
92 const bool is_machine_; | |
93 CString saved_shell_path_; // Path of the previous shell saved for roll back. | |
94 std::vector<CString> core_program_files_; | |
95 std::vector<CString> optional_files_; | |
96 | |
97 int extra_code1_; | |
98 | |
99 friend class SetupFilesTest; | |
100 | |
101 DISALLOW_EVIL_CONSTRUCTORS(SetupFiles); | |
102 }; | |
103 | |
104 } // namespace omaha | |
105 | |
106 #endif // OMAHA_SETUP_SETUP_FILES_H__ | |
107 | |
OLD | NEW |