Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/installer/util/install_util.cc

Issue 1525042: Additional changes to support Chrome / CF installation wrapped in an MSI:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/master_preferences.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 NOTREACHED(); 129 NOTREACHED();
130 } 130 }
131 return true; 131 return true;
132 } 132 }
133 133
134 bool InstallUtil::IsChromeFrameProcess() { 134 bool InstallUtil::IsChromeFrameProcess() {
135 CommandLine* command_line = CommandLine::ForCurrentProcess(); 135 CommandLine* command_line = CommandLine::ForCurrentProcess();
136 DCHECK(command_line) 136 DCHECK(command_line)
137 << "IsChromeFrameProcess() called before ComamandLine::Init()"; 137 << "IsChromeFrameProcess() called before ComamandLine::Init()";
138 138
139 // Also assume this to be a ChromeFrame process if we are running inside
140 // the Chrome Frame DLL.
141 FilePath module_path; 139 FilePath module_path;
142 PathService::Get(base::FILE_MODULE, &module_path); 140 PathService::Get(base::FILE_MODULE, &module_path);
143 std::wstring module_name(module_path.BaseName().value()); 141 std::wstring module_name(module_path.BaseName().value());
144 142
145 return command_line->HasSwitch(installer_util::switches::kChromeFrame) || 143 scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences(
146 module_name == installer_util::kChromeFrameDll; 144 *command_line));
145 DCHECK(prefs.get());
146 bool is_cf = false;
147 installer_util::GetDistroBooleanPreference(prefs.get(),
148 installer_util::master_preferences::kChromeFrame, &is_cf);
149
150 // Also assume this to be a ChromeFrame process if we are running inside
151 // the Chrome Frame DLL.
152 return is_cf || module_name == installer_util::kChromeFrameDll;
147 } 153 }
148 154
149 bool InstallUtil::IsChromeSxSProcess() { 155 bool InstallUtil::IsChromeSxSProcess() {
150 CommandLine* command_line = CommandLine::ForCurrentProcess(); 156 CommandLine* command_line = CommandLine::ForCurrentProcess();
151 CHECK(command_line); 157 CHECK(command_line);
152 158
153 if (command_line->HasSwitch(installer_util::switches::kChromeSxS)) 159 if (command_line->HasSwitch(installer_util::switches::kChromeSxS))
154 return true; 160 return true;
155 161
156 // Also return true if we are running from Chrome SxS installed path. 162 // Also return true if we are running from Chrome SxS installed path.
157 FilePath exe_dir; 163 FilePath exe_dir;
158 PathService::Get(base::DIR_EXE, &exe_dir); 164 PathService::Get(base::DIR_EXE, &exe_dir);
159 std::wstring chrome_sxs_dir(installer_util::kGoogleChromeInstallSubDir2); 165 std::wstring chrome_sxs_dir(installer_util::kGoogleChromeInstallSubDir2);
160 chrome_sxs_dir.append(installer_util::kSxSSuffix); 166 chrome_sxs_dir.append(installer_util::kSxSSuffix);
161 return FilePath::CompareEqualIgnoreCase(exe_dir.BaseName().value(), 167 return FilePath::CompareEqualIgnoreCase(exe_dir.BaseName().value(),
162 installer_util::kInstallBinaryDir) && 168 installer_util::kInstallBinaryDir) &&
163 FilePath::CompareEqualIgnoreCase(exe_dir.DirName().BaseName().value(), 169 FilePath::CompareEqualIgnoreCase(exe_dir.DirName().BaseName().value(),
164 chrome_sxs_dir); 170 chrome_sxs_dir);
165 } 171 }
166 172
167 bool InstallUtil::IsMSIProcess() { 173 bool InstallUtil::IsMSIProcess(bool system_level) {
174 // Initialize the static msi flags.
175 static bool is_msi_ = false;
176 static bool msi_checked_ = false;
177
168 CommandLine* command_line = CommandLine::ForCurrentProcess(); 178 CommandLine* command_line = CommandLine::ForCurrentProcess();
169 CHECK(command_line); 179 CHECK(command_line);
170 180
171 scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences( 181 if (!msi_checked_) {
172 *command_line)); 182 msi_checked_ = true;
173 bool value = false; 183
174 return (installer_util::GetDistroBooleanPreference(prefs.get(), 184 scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences(
175 installer_util::master_preferences::kMsi, &value) && 185 *command_line));
176 value); 186 DCHECK(prefs.get());
187 bool is_msi = false;
188 installer_util::GetDistroBooleanPreference(prefs.get(),
189 installer_util::master_preferences::kMsi, &is_msi);
190
191 if (!is_msi) {
192 // We didn't find it in the preferences, try looking in the registry.
193 HKEY reg_root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
194 RegKey key;
195 DWORD msi_value;
196
197 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
198 DCHECK(dist);
199
200 bool success = false;
201 std::wstring reg_key(dist->GetStateKey());
202 if (key.Open(reg_root, reg_key.c_str(), KEY_READ | KEY_WRITE)) {
203 if (key.ReadValueDW(google_update::kRegMSIField, &msi_value)) {
204 is_msi = (msi_value == 1);
205 }
206 }
207 }
208
209 is_msi_ = is_msi;
210 }
211
212 return is_msi_;
177 } 213 }
178 214
215 bool InstallUtil::SetMSIMarker(bool system_level, bool set) {
216 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
217 DCHECK(dist);
218 std::wstring client_state_path(dist->GetStateKey());
219
220 bool success = false;
221 HKEY reg_root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
222 RegKey client_state_key;
223 if (client_state_key.Open(reg_root, client_state_path.c_str(),
224 KEY_READ | KEY_WRITE)) {
225 DWORD msi_value = set ? 1 : 0;
226 if (client_state_key.WriteValue(google_update::kRegMSIField, msi_value)) {
227 success = true;
228 } else {
229 LOG(ERROR) << "Could not write msi value to client state key.";
230 }
231 } else {
232 LOG(ERROR) << "Could not open client state key!";
233 }
234
235 return success;
236 }
237
238
179 bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path, 239 bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path,
180 const wchar_t** const dll_names, 240 const wchar_t** const dll_names,
181 int dll_names_count, 241 int dll_names_count,
182 bool do_register, 242 bool do_register,
183 WorkItemList* registration_list) { 243 WorkItemList* registration_list) {
184 DCHECK(NULL != registration_list); 244 DCHECK(NULL != registration_list);
185 bool success = true; 245 bool success = true;
186 for (int i = 0; i < dll_names_count; i++) { 246 for (int i = 0; i < dll_names_count; i++) {
187 std::wstring dll_file_path(install_path); 247 std::wstring dll_file_path(install_path);
188 file_util::AppendToPath(&dll_file_path, dll_names[i]); 248 file_util::AppendToPath(&dll_file_path, dll_names[i]);
189 success = registration_list->AddSelfRegWorkItem(dll_file_path, 249 success = registration_list->AddSelfRegWorkItem(dll_file_path,
190 do_register) && success; 250 do_register) && success;
191 } 251 }
192 return (dll_names_count > 0) && success; 252 return (dll_names_count > 0) && success;
193 } 253 }
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/master_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698