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 // mini_installer.exe is the first exe that is run when chrome is being | 5 // mini_installer.exe is the first exe that is run when chrome is being |
6 // installed or upgraded. It is designed to be extremely small (~5KB with no | 6 // installed or upgraded. It is designed to be extremely small (~5KB with no |
7 // extra resources linked) and it has two main jobs: | 7 // extra resources linked) and it has two main jobs: |
8 // 1) unpack the resources (possibly decompressing some) | 8 // 1) unpack the resources (possibly decompressing some) |
9 // 2) run the real installer (setup.exe) with appropriate flags. | 9 // 2) run the real installer (setup.exe) with appropriate flags. |
10 // | 10 // |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // of resource callbacks. | 52 // of resource callbacks. |
53 struct Context { | 53 struct Context { |
54 // Input to the call back method. Specifies the dir to save resources. | 54 // Input to the call back method. Specifies the dir to save resources. |
55 const wchar_t* base_path; | 55 const wchar_t* base_path; |
56 // First output from call back method. Full path of Chrome archive. | 56 // First output from call back method. Full path of Chrome archive. |
57 PathString* chrome_resource_path; | 57 PathString* chrome_resource_path; |
58 // Second output from call back method. Full path of Setup archive/exe. | 58 // Second output from call back method. Full path of Setup archive/exe. |
59 PathString* setup_resource_path; | 59 PathString* setup_resource_path; |
60 }; | 60 }; |
61 | 61 |
62 // TODO(grt): Frame this in terms of whether or not the brand supports | |
63 // integation with Omaha, where Google Update is the Google-specific fork of | |
64 // the open-source Omaha project. | |
62 #if defined(GOOGLE_CHROME_BUILD) | 65 #if defined(GOOGLE_CHROME_BUILD) |
63 // Opens the Google Update ClientState key. If |binaries| is false, opens the | 66 // Opens the Google Update ClientState key. If |binaries| is false, opens the |
64 // key for Google Chrome or Chrome SxS (canary). If |binaries| is true and an | 67 // key for Google Chrome or Chrome SxS (canary). If |binaries| is true and an |
65 // existing multi-install Chrome is being updated, opens the key for the | 68 // existing multi-install Chrome is being updated, opens the key for the |
66 // binaries; otherwise, returns false. | 69 // multi-install binaries; otherwise, returns false. |
67 bool OpenInstallStateKey(const Configuration& configuration, | 70 bool OpenInstallStateKey(const Configuration& configuration, |
68 bool binaries, | 71 bool binaries, |
69 RegKey* key) { | 72 RegKey* key) { |
70 if (binaries && !configuration.is_updating_multi_chrome()) | 73 if (binaries && !configuration.is_updating_multi_chrome()) |
71 return false; | 74 return false; |
72 const HKEY root_key = | 75 const HKEY root_key = |
73 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 76 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
74 const wchar_t* app_guid = binaries ? google_update::kMultiInstallAppGuid | 77 const wchar_t* app_guid = binaries ? google_update::kMultiInstallAppGuid |
75 : configuration.chrome_app_guid(); | 78 : configuration.chrome_app_guid(); |
76 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; | 79 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; |
77 | 80 |
78 return OpenClientStateKey(root_key, app_guid, key_access, key) == | 81 return OpenClientStateKey(root_key, app_guid, key_access, key) == |
79 ERROR_SUCCESS; | 82 ERROR_SUCCESS; |
80 } | 83 } |
81 | 84 |
82 // Writes install results into the registry where it is read by Google Update. | 85 // Writes install results into the registry where it is read by Google Update. |
83 // Don't write anything if there is already a result present, likely | 86 // Don't write anything if there is already a result present, likely |
84 // written by setup.exe. | 87 // written by setup.exe. |
85 void WriteInstallResults(const Configuration& configuration, | 88 void WriteInstallResults(const Configuration& configuration, |
86 ProcessExitResult result) { | 89 ProcessExitResult result) { |
87 // Calls to setup.exe will write a "success" result if everything was good | 90 // Calls to setup.exe will write a "success" result if everything was good |
88 // so we don't need to write anything from here. | 91 // so we don't need to write anything from here. |
89 if (result.IsSuccess()) | 92 if (result.IsSuccess()) |
90 return; | 93 return; |
91 | 94 |
92 // Write the value in Chrome ClientState key and in the binaries' if an | 95 // Write the value in Chrome ClientState key and in the binaries' if an |
93 // existing multi-install Chrome is being updated. | 96 // existing multi-install Chrome is being updated. |
94 for (int i = 0; i < 2; ++i) { | 97 static constexpr bool kValues[] = {false, true}; |
98 for (bool binaries : kValues) { | |
grt (UTC plus 2)
2017/02/02 08:16:48
i get this compile error:
mini_installer.cc(122):
huangs
2017/02/02 16:06:03
Ah interesting. It seems this requires
#include <
grt (UTC plus 2)
2017/02/03 07:45:47
Sweet! Thanks for the tip!
| |
95 RegKey key; | 99 RegKey key; |
96 DWORD value; | 100 DWORD value; |
97 if (OpenInstallStateKey(configuration, i != 0, &key)) { | 101 if (OpenInstallStateKey(configuration, binaries, &key)) { |
98 if (key.ReadDWValue(kInstallerResultRegistryValue, &value) != | 102 if (key.ReadDWValue(kInstallerResultRegistryValue, &value) != |
99 ERROR_SUCCESS || | 103 ERROR_SUCCESS || |
100 value == 0) { | 104 value == 0) { |
101 key.WriteDWValue(kInstallerResultRegistryValue, | 105 key.WriteDWValue(kInstallerResultRegistryValue, |
102 result.exit_code ? 1 /* FAILED_CUSTOM_ERROR */ | 106 result.exit_code ? 1 /* FAILED_CUSTOM_ERROR */ |
103 : 0 /* SUCCESS */); | 107 : 0 /* SUCCESS */); |
104 key.WriteDWValue(kInstallerErrorRegistryValue, result.exit_code); | 108 key.WriteDWValue(kInstallerErrorRegistryValue, result.exit_code); |
105 key.WriteDWValue(kInstallerExtraCode1RegistryValue, | 109 key.WriteDWValue(kInstallerExtraCode1RegistryValue, |
106 result.windows_error); | 110 result.windows_error); |
107 } | 111 } |
108 } | 112 } |
109 } | 113 } |
110 } | 114 } |
111 | 115 |
112 // This function sets the flag in registry to indicate that Google Update | 116 // This function sets the flag in registry to indicate that Google Update |
113 // should try full installer next time. If the current installer works, this | 117 // should try full installer next time. If the current installer works, this |
114 // flag is cleared by setup.exe at the end of install. | 118 // flag is cleared by setup.exe at the end of install. |
115 void SetInstallerFlags(const Configuration& configuration) { | 119 void SetInstallerFlags(const Configuration& configuration) { |
116 StackString<128> value; | 120 StackString<128> value; |
117 | 121 |
118 for (int i = 0; i < 2; ++i) { | 122 static constexpr bool kValues[] = {false, true}; |
123 for (bool binaries : kValues) { | |
119 RegKey key; | 124 RegKey key; |
120 if (!OpenInstallStateKey(configuration, i != 0, &key)) | 125 if (!OpenInstallStateKey(configuration, binaries, &key)) |
121 continue; | 126 continue; |
122 | 127 |
123 LONG ret = key.ReadSZValue(kApRegistryValue, value.get(), value.capacity()); | 128 LONG ret = key.ReadSZValue(kApRegistryValue, value.get(), value.capacity()); |
124 | 129 |
125 // The conditions below are handling two cases: | 130 // The conditions below are handling two cases: |
126 // 1. When ap value is present, we want to add the required tag only if it | 131 // 1. When ap value is present, we want to add the required tag only if it |
127 // is not present. | 132 // is not present. |
128 // 2. When ap value is missing, we are going to create it with the required | 133 // 2. When ap value is missing, we are going to create it with the required |
129 // tag. | 134 // tag. |
130 if ((ret == ERROR_SUCCESS) || (ret == ERROR_FILE_NOT_FOUND)) { | 135 if ((ret == ERROR_SUCCESS) || (ret == ERROR_FILE_NOT_FOUND)) { |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 DeleteExtractedFiles(base_path.get(), archive_path.get(), setup_path.get()); | 859 DeleteExtractedFiles(base_path.get(), archive_path.get(), setup_path.get()); |
855 | 860 |
856 #if defined(GOOGLE_CHROME_BUILD) | 861 #if defined(GOOGLE_CHROME_BUILD) |
857 WriteInstallResults(configuration, exit_code); | 862 WriteInstallResults(configuration, exit_code); |
858 #endif | 863 #endif |
859 | 864 |
860 return exit_code; | 865 return exit_code; |
861 } | 866 } |
862 | 867 |
863 } // namespace mini_installer | 868 } // namespace mini_installer |
OLD | NEW |