OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace { | 37 namespace { |
38 | 38 |
39 using installer::Products; | 39 using installer::Products; |
40 using installer::Product; | 40 using installer::Product; |
41 using installer::Package; | 41 using installer::Package; |
42 using installer::Version; | 42 using installer::Version; |
43 | 43 |
44 void AddChromeToMediaPlayerList() { | 44 void AddChromeToMediaPlayerList() { |
45 std::wstring reg_path(installer::kMediaPlayerRegPath); | 45 std::wstring reg_path(installer::kMediaPlayerRegPath); |
46 // registry paths can also be appended like file system path | 46 // registry paths can also be appended like file system path |
47 file_util::AppendToPath(®_path, installer::kChromeExe); | 47 file_util::AppendToPath(®_path, installer_util::kChromeExe); |
48 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 48 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
49 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 49 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
50 HKEY_LOCAL_MACHINE, reg_path)); | 50 HKEY_LOCAL_MACHINE, reg_path)); |
51 | 51 |
52 // if the operation fails we log the error but still continue | 52 // if the operation fails we log the error but still continue |
53 if (!work_item.get()->Do()) | 53 if (!work_item.get()->Do()) |
54 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; | 54 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; |
55 } | 55 } |
56 | 56 |
57 void AddInstallerCopyTasks(const FilePath& setup_path, | 57 void AddInstallerCopyTasks(const FilePath& setup_path, |
(...skipping 17 matching lines...) Expand all Loading... |
75 } else { | 75 } else { |
76 install_list->AddMoveTreeWorkItem(archive_path.value(), archive_dst.value(), | 76 install_list->AddMoveTreeWorkItem(archive_path.value(), archive_dst.value(), |
77 temp_path.value()); | 77 temp_path.value()); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd, | 81 void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd, |
82 const Product& product) { | 82 const Product& product) { |
83 DCHECK(uninstall_cmd); | 83 DCHECK(uninstall_cmd); |
84 | 84 |
85 uninstall_cmd->AppendSwitch(installer::switches::kUninstall); | 85 uninstall_cmd->AppendSwitch(installer_util::switches::kUninstall); |
86 | 86 |
87 // Append the product-specific uninstall flags. | 87 // Append the product-specific uninstall flags. |
88 product.distribution()->AppendUninstallCommandLineFlags(uninstall_cmd); | 88 product.distribution()->AppendUninstallCommandLineFlags(uninstall_cmd); |
89 if (product.IsMsi()) | 89 if (product.IsMsi()) |
90 uninstall_cmd->AppendSwitch(installer::switches::kMsi); | 90 uninstall_cmd->AppendSwitch(installer_util::switches::kMsi); |
91 if (product.system_level()) | 91 if (product.system_level()) |
92 uninstall_cmd->AppendSwitch(installer::switches::kSystemLevel); | 92 uninstall_cmd->AppendSwitch(installer_util::switches::kSystemLevel); |
93 | 93 |
94 // Propagate switches obtained from preferences as well. | 94 // Propagate switches obtained from preferences as well. |
95 const installer::MasterPreferences& prefs = | 95 const installer_util::MasterPreferences& prefs = |
96 installer::MasterPreferences::ForCurrentProcess(); | 96 installer_util::MasterPreferences::ForCurrentProcess(); |
97 if (prefs.is_multi_install()) { | 97 if (prefs.is_multi_install()) { |
98 uninstall_cmd->AppendSwitch(installer::switches::kMultiInstall); | 98 uninstall_cmd->AppendSwitch(installer_util::switches::kMultiInstall); |
99 } | 99 } |
100 bool value = false; | 100 bool value = false; |
101 if (prefs.GetBool(installer::master_preferences::kVerboseLogging, | 101 if (prefs.GetBool(installer_util::master_preferences::kVerboseLogging, |
102 &value) && value) | 102 &value) && value) |
103 uninstall_cmd->AppendSwitch(installer::switches::kVerboseLogging); | 103 uninstall_cmd->AppendSwitch(installer_util::switches::kVerboseLogging); |
104 } | 104 } |
105 | 105 |
106 // This method adds work items to create (or update) Chrome uninstall entry in | 106 // This method adds work items to create (or update) Chrome uninstall entry in |
107 // either the Control Panel->Add/Remove Programs list or in the Omaha client | 107 // either the Control Panel->Add/Remove Programs list or in the Omaha client |
108 // state key if running under an MSI installer. | 108 // state key if running under an MSI installer. |
109 void AddUninstallShortcutWorkItems(const FilePath& setup_path, | 109 void AddUninstallShortcutWorkItems(const FilePath& setup_path, |
110 const Version& new_version, | 110 const Version& new_version, |
111 WorkItemList* install_list, | 111 WorkItemList* install_list, |
112 const Product& product) { | 112 const Product& product) { |
113 HKEY reg_root = product.system_level() ? HKEY_LOCAL_MACHINE : | 113 HKEY reg_root = product.system_level() ? HKEY_LOCAL_MACHINE : |
(...skipping 11 matching lines...) Expand all Loading... |
125 FilePath installer_path( | 125 FilePath installer_path( |
126 product.package().GetInstallerDirectory(new_version)); | 126 product.package().GetInstallerDirectory(new_version)); |
127 installer_path = installer_path.Append(setup_path.BaseName()); | 127 installer_path = installer_path.Append(setup_path.BaseName()); |
128 | 128 |
129 CommandLine uninstall_arguments(CommandLine::NO_PROGRAM); | 129 CommandLine uninstall_arguments(CommandLine::NO_PROGRAM); |
130 AppendUninstallCommandLineFlags(&uninstall_arguments, product); | 130 AppendUninstallCommandLineFlags(&uninstall_arguments, product); |
131 | 131 |
132 std::wstring update_state_key(browser_dist->GetStateKey()); | 132 std::wstring update_state_key(browser_dist->GetStateKey()); |
133 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key); | 133 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key); |
134 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, | 134 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, |
135 installer::kUninstallStringField, installer_path.value(), true); | 135 installer_util::kUninstallStringField, installer_path.value(), true); |
136 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, | 136 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, |
137 installer::kUninstallArgumentsField, | 137 installer_util::kUninstallArgumentsField, |
138 uninstall_arguments.command_line_string(), true); | 138 uninstall_arguments.command_line_string(), true); |
139 | 139 |
140 // MSI installations will manage their own uninstall shortcuts. | 140 // MSI installations will manage their own uninstall shortcuts. |
141 if (!product.IsMsi()) { | 141 if (!product.IsMsi()) { |
142 // We need to quote the command line for the Add/Remove Programs dialog. | 142 // We need to quote the command line for the Add/Remove Programs dialog. |
143 CommandLine quoted_uninstall_cmd(installer_path); | 143 CommandLine quoted_uninstall_cmd(installer_path); |
144 DCHECK_EQ(quoted_uninstall_cmd.command_line_string()[0], '"'); | 144 DCHECK_EQ(quoted_uninstall_cmd.command_line_string()[0], '"'); |
145 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); | 145 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); |
146 | 146 |
147 std::wstring uninstall_reg = browser_dist->GetUninstallRegPath(); | 147 std::wstring uninstall_reg = browser_dist->GetUninstallRegPath(); |
148 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); | 148 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); |
149 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 149 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
150 installer::kUninstallDisplayNameField, | 150 installer_util::kUninstallDisplayNameField, |
151 browser_dist->GetAppShortCutName(), true); | 151 browser_dist->GetAppShortCutName(), true); |
152 install_list->AddSetRegValueWorkItem(reg_root, | 152 install_list->AddSetRegValueWorkItem(reg_root, |
153 uninstall_reg, installer::kUninstallStringField, | 153 uninstall_reg, installer_util::kUninstallStringField, |
154 quoted_uninstall_cmd.command_line_string(), true); | 154 quoted_uninstall_cmd.command_line_string(), true); |
155 install_list->AddSetRegValueWorkItem(reg_root, | 155 install_list->AddSetRegValueWorkItem(reg_root, |
156 uninstall_reg, | 156 uninstall_reg, |
157 L"InstallLocation", | 157 L"InstallLocation", |
158 install_path.value(), | 158 install_path.value(), |
159 true); | 159 true); |
160 | 160 |
161 // DisplayIcon, NoModify and NoRepair | 161 // DisplayIcon, NoModify and NoRepair |
162 FilePath chrome_icon(install_path.Append(installer::kChromeExe)); | 162 FilePath chrome_icon(install_path.Append(installer_util::kChromeExe)); |
163 ShellUtil::GetChromeIcon(product.distribution(), chrome_icon.value()); | 163 ShellUtil::GetChromeIcon(product.distribution(), chrome_icon.value()); |
164 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 164 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
165 L"DisplayIcon", chrome_icon.value(), | 165 L"DisplayIcon", chrome_icon.value(), |
166 true); | 166 true); |
167 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 167 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
168 L"NoModify", 1, true); | 168 L"NoModify", 1, true); |
169 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 169 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
170 L"NoRepair", 1, true); | 170 L"NoRepair", 1, true); |
171 | 171 |
172 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 172 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 VLOG(1) << "Failed to delete old uninstall shortcut."; | 227 VLOG(1) << "Failed to delete old uninstall shortcut."; |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 // Copy master preferences file provided to installer, in the same folder | 231 // Copy master preferences file provided to installer, in the same folder |
232 // as chrome.exe so Chrome first run can find it. This function will be called | 232 // as chrome.exe so Chrome first run can find it. This function will be called |
233 // only on the first install of Chrome. | 233 // only on the first install of Chrome. |
234 void CopyPreferenceFileForFirstRun(const Package& package, | 234 void CopyPreferenceFileForFirstRun(const Package& package, |
235 const FilePath& prefs_source_path) { | 235 const FilePath& prefs_source_path) { |
236 FilePath prefs_dest_path(package.path().AppendASCII( | 236 FilePath prefs_dest_path(package.path().AppendASCII( |
237 installer::kDefaultMasterPrefs)); | 237 installer_util::kDefaultMasterPrefs)); |
238 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { | 238 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { |
239 VLOG(1) << "Failed to copy master preferences from:" | 239 VLOG(1) << "Failed to copy master preferences from:" |
240 << prefs_source_path.value() << " gle: " << ::GetLastError(); | 240 << prefs_source_path.value() << " gle: " << ::GetLastError(); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 // This method creates Chrome shortcuts in Start->Programs for all users or | 244 // This method creates Chrome shortcuts in Start->Programs for all users or |
245 // only for current user depending on whether it is system wide install or | 245 // only for current user depending on whether it is system wide install or |
246 // user only install. | 246 // user only install. |
247 // | 247 // |
248 // If first_install is true, it creates shortcuts for launching and | 248 // If first_install is true, it creates shortcuts for launching and |
249 // uninstalling chrome. | 249 // uninstalling chrome. |
250 // If first_install is false, the function only updates the shortcut for | 250 // If first_install is false, the function only updates the shortcut for |
251 // uninstalling chrome. According to | 251 // uninstalling chrome. According to |
252 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, | 252 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, |
253 // updating uninstall shortcut should not trigger Windows "new application | 253 // updating uninstall shortcut should not trigger Windows "new application |
254 // installed" notification. | 254 // installed" notification. |
255 // | 255 // |
256 // If the shortcuts do not exist, the function does not recreate them during | 256 // If the shortcuts do not exist, the function does not recreate them during |
257 // update. | 257 // update. |
258 bool CreateOrUpdateChromeShortcuts(const FilePath& setup_path, | 258 bool CreateOrUpdateChromeShortcuts(const FilePath& setup_path, |
259 const Version& new_version, | 259 const Version& new_version, |
260 installer::InstallStatus install_status, | 260 installer_util::InstallStatus install_status, |
261 const Product& product, | 261 const Product& product, |
262 bool create_all_shortcut, | 262 bool create_all_shortcut, |
263 bool alt_shortcut) { | 263 bool alt_shortcut) { |
264 // TODO(tommi): Change this function to use WorkItemList. | 264 // TODO(tommi): Change this function to use WorkItemList. |
265 #ifndef NDEBUG | 265 #ifndef NDEBUG |
266 const installer::MasterPreferences& prefs = | 266 const installer_util::MasterPreferences& prefs = |
267 installer::MasterPreferences::ForCurrentProcess(); | 267 installer_util::MasterPreferences::ForCurrentProcess(); |
268 DCHECK(prefs.install_chrome()); | 268 DCHECK(prefs.install_chrome()); |
269 #endif | 269 #endif |
270 | 270 |
271 FilePath shortcut_path; | 271 FilePath shortcut_path; |
272 int dir_enum = product.system_level() ? base::DIR_COMMON_START_MENU : | 272 int dir_enum = product.system_level() ? base::DIR_COMMON_START_MENU : |
273 base::DIR_START_MENU; | 273 base::DIR_START_MENU; |
274 if (!PathService::Get(dir_enum, &shortcut_path)) { | 274 if (!PathService::Get(dir_enum, &shortcut_path)) { |
275 LOG(ERROR) << "Failed to get location for shortcut."; | 275 LOG(ERROR) << "Failed to get location for shortcut."; |
276 return false; | 276 return false; |
277 } | 277 } |
(...skipping 10 matching lines...) Expand all Loading... |
288 // - This is a new install or install repair | 288 // - This is a new install or install repair |
289 // OR | 289 // OR |
290 // - The shortcut already exists in case of updates (user may have deleted | 290 // - The shortcut already exists in case of updates (user may have deleted |
291 // shortcuts since our install. So on updates we only update if shortcut | 291 // shortcuts since our install. So on updates we only update if shortcut |
292 // already exists) | 292 // already exists) |
293 bool ret = true; | 293 bool ret = true; |
294 FilePath chrome_link(shortcut_path); // Chrome link (launches Chrome) | 294 FilePath chrome_link(shortcut_path); // Chrome link (launches Chrome) |
295 chrome_link = chrome_link.Append(product_name + L".lnk"); | 295 chrome_link = chrome_link.Append(product_name + L".lnk"); |
296 // Chrome link target | 296 // Chrome link target |
297 FilePath chrome_exe( | 297 FilePath chrome_exe( |
298 product.package().path().Append(installer::kChromeExe)); | 298 product.package().path().Append(installer_util::kChromeExe)); |
299 | 299 |
300 if ((install_status == installer::FIRST_INSTALL_SUCCESS) || | 300 if ((install_status == installer_util::FIRST_INSTALL_SUCCESS) || |
301 (install_status == installer::INSTALL_REPAIRED)) { | 301 (install_status == installer_util::INSTALL_REPAIRED)) { |
302 if (!file_util::PathExists(shortcut_path)) | 302 if (!file_util::PathExists(shortcut_path)) |
303 file_util::CreateDirectoryW(shortcut_path); | 303 file_util::CreateDirectoryW(shortcut_path); |
304 | 304 |
305 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at " | 305 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at " |
306 << chrome_link.value(); | 306 << chrome_link.value(); |
307 ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | 307 ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), |
308 chrome_link.value(), product_desc, true); | 308 chrome_link.value(), product_desc, true); |
309 } else if (file_util::PathExists(chrome_link)) { | 309 } else if (file_util::PathExists(chrome_link)) { |
310 VLOG(1) << "Updating shortcut at " << chrome_link.value() | 310 VLOG(1) << "Updating shortcut at " << chrome_link.value() |
311 << " to point to " << chrome_exe.value(); | 311 << " to point to " << chrome_exe.value(); |
312 ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | 312 ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), |
313 chrome_link.value(), product_desc, false); | 313 chrome_link.value(), product_desc, false); |
314 } else { | 314 } else { |
315 VLOG(1) | 315 VLOG(1) |
316 << "not first or repaired install, link file doesn't exist. status: " | 316 << "not first or repaired install, link file doesn't exist. status: " |
317 << install_status; | 317 << install_status; |
318 } | 318 } |
319 | 319 |
320 // Create/update uninstall link if we are not an MSI install. MSI | 320 // Create/update uninstall link if we are not an MSI install. MSI |
321 // installations are, for the time being, managed only through the | 321 // installations are, for the time being, managed only through the |
322 // Add/Remove Programs dialog. | 322 // Add/Remove Programs dialog. |
323 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. | 323 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
324 if (ret && !product.IsMsi()) { | 324 if (ret && !product.IsMsi()) { |
325 FilePath uninstall_link(shortcut_path); // Uninstall Chrome link | 325 FilePath uninstall_link(shortcut_path); // Uninstall Chrome link |
326 uninstall_link = uninstall_link.Append( | 326 uninstall_link = uninstall_link.Append( |
327 browser_dist->GetUninstallLinkName() + L".lnk"); | 327 browser_dist->GetUninstallLinkName() + L".lnk"); |
328 if ((install_status == installer::FIRST_INSTALL_SUCCESS) || | 328 if ((install_status == installer_util::FIRST_INSTALL_SUCCESS) || |
329 (install_status == installer::INSTALL_REPAIRED) || | 329 (install_status == installer_util::INSTALL_REPAIRED) || |
330 (file_util::PathExists(uninstall_link))) { | 330 (file_util::PathExists(uninstall_link))) { |
331 if (!file_util::PathExists(shortcut_path)) | 331 if (!file_util::PathExists(shortcut_path)) |
332 file_util::CreateDirectory(shortcut_path); | 332 file_util::CreateDirectory(shortcut_path); |
333 | 333 |
334 FilePath setup_exe( | 334 FilePath setup_exe( |
335 product.package().GetInstallerDirectory(new_version) | 335 product.package().GetInstallerDirectory(new_version) |
336 .Append(setup_path.BaseName())); | 336 .Append(setup_path.BaseName())); |
337 | 337 |
338 CommandLine arguments(CommandLine::NO_PROGRAM); | 338 CommandLine arguments(CommandLine::NO_PROGRAM); |
339 AppendUninstallCommandLineFlags(&arguments, product); | 339 AppendUninstallCommandLineFlags(&arguments, product); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (!current_version) { | 428 if (!current_version) { |
429 LOG(ERROR) << "New chrome.exe exists but current version is NULL!"; | 429 LOG(ERROR) << "New chrome.exe exists but current version is NULL!"; |
430 return false; | 430 return false; |
431 } | 431 } |
432 | 432 |
433 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); | 433 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); |
434 FilePath installer_path(package.GetInstallerDirectory(new_version) | 434 FilePath installer_path(package.GetInstallerDirectory(new_version) |
435 .Append(setup_path.BaseName())); | 435 .Append(setup_path.BaseName())); |
436 | 436 |
437 CommandLine rename(installer_path); | 437 CommandLine rename(installer_path); |
438 rename.AppendSwitch(installer::switches::kRenameChromeExe); | 438 rename.AppendSwitch(installer_util::switches::kRenameChromeExe); |
439 if (package.system_level()) | 439 if (package.system_level()) |
440 rename.AppendSwitch(installer::switches::kSystemLevel); | 440 rename.AppendSwitch(installer_util::switches::kSystemLevel); |
441 | 441 |
442 if (InstallUtil::IsChromeSxSProcess()) | 442 if (InstallUtil::IsChromeSxSProcess()) |
443 rename.AppendSwitch(installer::switches::kChromeSxS); | 443 rename.AppendSwitch(installer_util::switches::kChromeSxS); |
444 | 444 |
445 for (size_t i = 0; i < products.size(); ++i) { | 445 for (size_t i = 0; i < products.size(); ++i) { |
446 BrowserDistribution* dist = products[i]->distribution(); | 446 BrowserDistribution* dist = products[i]->distribution(); |
447 std::wstring version_key(dist->GetVersionKey()); | 447 std::wstring version_key(dist->GetVersionKey()); |
448 inuse_list->AddSetRegValueWorkItem(root, version_key, | 448 inuse_list->AddSetRegValueWorkItem(root, version_key, |
449 google_update::kRegOldVersionField, | 449 google_update::kRegOldVersionField, |
450 current_version->GetString(), true); | 450 current_version->GetString(), true); |
451 | 451 |
452 // Adding this registry entry for all products is overkill. | 452 // Adding this registry entry for all products is overkill. |
453 // However, as it stands, we don't have a way to know which distribution | 453 // However, as it stands, we don't have a way to know which distribution |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 BrowserDistribution::CHROME_BROWSER); | 535 BrowserDistribution::CHROME_BROWSER); |
536 | 536 |
537 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 537 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
538 // error checking here because this operation will fail if user doesn't | 538 // error checking here because this operation will fail if user doesn't |
539 // have admin rights and we want to ignore the error. | 539 // have admin rights and we want to ignore the error. |
540 AddChromeToMediaPlayerList(); | 540 AddChromeToMediaPlayerList(); |
541 | 541 |
542 // Is --make-chrome-default option is given we make Chrome default browser | 542 // Is --make-chrome-default option is given we make Chrome default browser |
543 // otherwise we only register it on the machine as a valid browser. | 543 // otherwise we only register it on the machine as a valid browser. |
544 FilePath chrome_exe( | 544 FilePath chrome_exe( |
545 product.package().path().Append(installer::kChromeExe)); | 545 product.package().path().Append(installer_util::kChromeExe)); |
546 VLOG(1) << "Registering Chrome as browser: " << chrome_exe.value(); | 546 VLOG(1) << "Registering Chrome as browser: " << chrome_exe.value(); |
547 if (make_chrome_default) { | 547 if (make_chrome_default) { |
548 int level = ShellUtil::CURRENT_USER; | 548 int level = ShellUtil::CURRENT_USER; |
549 if (product.system_level()) | 549 if (product.system_level()) |
550 level = level | ShellUtil::SYSTEM_LEVEL; | 550 level = level | ShellUtil::SYSTEM_LEVEL; |
551 ShellUtil::MakeChromeDefault(product.distribution(), level, | 551 ShellUtil::MakeChromeDefault(product.distribution(), level, |
552 chrome_exe.value(), true); | 552 chrome_exe.value(), true); |
553 } else { | 553 } else { |
554 ShellUtil::RegisterChromeBrowser(product.distribution(), chrome_exe.value(), | 554 ShellUtil::RegisterChromeBrowser(product.distribution(), chrome_exe.value(), |
555 L"", false); | 555 L"", false); |
(...skipping 13 matching lines...) Expand all Loading... |
569 // new_version: new Chrome version that needs to be installed | 569 // new_version: new Chrome version that needs to be installed |
570 // oldest_installed_version: returns the oldest active version (if any) | 570 // oldest_installed_version: returns the oldest active version (if any) |
571 // | 571 // |
572 // This function makes best effort to do installation in a transactional | 572 // This function makes best effort to do installation in a transactional |
573 // manner. If failed it tries to rollback all changes on the file system | 573 // manner. If failed it tries to rollback all changes on the file system |
574 // and registry. For example, if package exists before calling the | 574 // and registry. For example, if package exists before calling the |
575 // function, it rolls back all new file and directory changes under | 575 // function, it rolls back all new file and directory changes under |
576 // package. If package does not exist before calling the function | 576 // package. If package does not exist before calling the function |
577 // (typical new install), the function creates package during install | 577 // (typical new install), the function creates package during install |
578 // and removes the whole directory during rollback. | 578 // and removes the whole directory during rollback. |
579 installer::InstallStatus InstallNewVersion( | 579 installer_util::InstallStatus InstallNewVersion( |
580 const FilePath& setup_path, | 580 const FilePath& setup_path, |
581 const FilePath& archive_path, | 581 const FilePath& archive_path, |
582 const FilePath& src_path, | 582 const FilePath& src_path, |
583 const FilePath& temp_dir, | 583 const FilePath& temp_dir, |
584 const Version& new_version, | 584 const Version& new_version, |
585 scoped_ptr<Version>* current_version, | 585 scoped_ptr<Version>* current_version, |
586 const Package& package) { | 586 const Package& package) { |
587 DCHECK(current_version); | 587 DCHECK(current_version); |
588 | 588 |
589 const Products& products = package.products(); | 589 const Products& products = package.products(); |
590 DCHECK(products.size()); | 590 DCHECK(products.size()); |
591 | 591 |
592 if (FindProduct(products, BrowserDistribution::CHROME_FRAME)) { | 592 if (FindProduct(products, BrowserDistribution::CHROME_FRAME)) { |
593 // Make sure that we don't end up deleting installed files on next reboot. | 593 // Make sure that we don't end up deleting installed files on next reboot. |
594 if (!RemoveFromMovesPendingReboot(package.path().value().c_str())) { | 594 if (!RemoveFromMovesPendingReboot(package.path().value().c_str())) { |
595 LOG(ERROR) << "Error accessing pending moves value."; | 595 LOG(ERROR) << "Error accessing pending moves value."; |
596 } | 596 } |
597 } | 597 } |
598 | 598 |
599 current_version->reset(package.GetCurrentVersion()); | 599 current_version->reset(package.GetCurrentVersion()); |
600 | 600 |
601 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 601 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
602 // A temp directory that work items need and the actual install directory. | 602 // A temp directory that work items need and the actual install directory. |
603 install_list->AddCreateDirWorkItem(temp_dir); | 603 install_list->AddCreateDirWorkItem(temp_dir); |
604 install_list->AddCreateDirWorkItem(package.path()); | 604 install_list->AddCreateDirWorkItem(package.path()); |
605 | 605 |
606 // Delete any new_chrome.exe if present (we will end up creating a new one | 606 // Delete any new_chrome.exe if present (we will end up creating a new one |
607 // if required) and then copy chrome.exe | 607 // if required) and then copy chrome.exe |
608 FilePath new_chrome_exe( | 608 FilePath new_chrome_exe( |
609 package.path().Append(installer::kChromeNewExe)); | 609 package.path().Append(installer_util::kChromeNewExe)); |
610 | 610 |
611 install_list->AddDeleteTreeWorkItem(new_chrome_exe); | 611 install_list->AddDeleteTreeWorkItem(new_chrome_exe); |
612 install_list->AddCopyTreeWorkItem( | 612 install_list->AddCopyTreeWorkItem( |
613 src_path.Append(installer::kChromeExe).value(), | 613 src_path.Append(installer_util::kChromeExe).value(), |
614 package.path().Append(installer::kChromeExe).value(), | 614 package.path().Append(installer_util::kChromeExe).value(), |
615 temp_dir.value(), WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe.value()); | 615 temp_dir.value(), WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe.value()); |
616 | 616 |
617 // Extra executable for 64 bit systems. | 617 // Extra executable for 64 bit systems. |
618 if (Is64bit()) { | 618 if (Is64bit()) { |
619 install_list->AddCopyTreeWorkItem( | 619 install_list->AddCopyTreeWorkItem( |
620 src_path.Append(installer::kWowHelperExe).value(), | 620 src_path.Append(installer::kWowHelperExe).value(), |
621 package.path().Append(installer::kWowHelperExe).value(), | 621 package.path().Append(installer::kWowHelperExe).value(), |
622 temp_dir.value(), WorkItem::ALWAYS); | 622 temp_dir.value(), WorkItem::ALWAYS); |
623 } | 623 } |
624 | 624 |
(...skipping 12 matching lines...) Expand all Loading... |
637 } | 637 } |
638 | 638 |
639 // Copy the default Dictionaries only if the folder doesn't exist already. | 639 // Copy the default Dictionaries only if the folder doesn't exist already. |
640 install_list->AddCopyTreeWorkItem( | 640 install_list->AddCopyTreeWorkItem( |
641 src_path.Append(installer::kDictionaries).value(), | 641 src_path.Append(installer::kDictionaries).value(), |
642 package.path().Append(installer::kDictionaries).value(), | 642 package.path().Append(installer::kDictionaries).value(), |
643 temp_dir.value(), WorkItem::IF_NOT_PRESENT); | 643 temp_dir.value(), WorkItem::IF_NOT_PRESENT); |
644 | 644 |
645 // Delete any old_chrome.exe if present. | 645 // Delete any old_chrome.exe if present. |
646 install_list->AddDeleteTreeWorkItem( | 646 install_list->AddDeleteTreeWorkItem( |
647 package.path().Append(installer::kChromeOldExe)); | 647 package.path().Append(installer_util::kChromeOldExe)); |
648 | 648 |
649 // Copy installer in install directory and | 649 // Copy installer in install directory and |
650 // add shortcut in Control Panel->Add/Remove Programs. | 650 // add shortcut in Control Panel->Add/Remove Programs. |
651 AddInstallerCopyTasks(setup_path, archive_path, temp_dir, new_version, | 651 AddInstallerCopyTasks(setup_path, archive_path, temp_dir, new_version, |
652 install_list.get(), package); | 652 install_list.get(), package); |
653 | 653 |
654 for (size_t i = 0; i < products.size(); ++i) { | 654 for (size_t i = 0; i < products.size(); ++i) { |
655 const Product* product = products[i]; | 655 const Product* product = products[i]; |
656 | 656 |
657 AddUninstallShortcutWorkItems(setup_path, new_version, install_list.get(), | 657 AddUninstallShortcutWorkItems(setup_path, new_version, install_list.get(), |
(...skipping 17 matching lines...) Expand all Loading... |
675 false); // set during first install | 675 false); // set during first install |
676 install_list->AddSetRegValueWorkItem(root, version_key, | 676 install_list->AddSetRegValueWorkItem(root, version_key, |
677 google_update::kRegVersionField, | 677 google_update::kRegVersionField, |
678 new_version.GetString(), | 678 new_version.GetString(), |
679 true); // overwrite version | 679 true); // overwrite version |
680 } | 680 } |
681 | 681 |
682 if (!install_list->Do() || | 682 if (!install_list->Do() || |
683 !DoPostInstallTasks(setup_path, new_chrome_exe, current_version->get(), | 683 !DoPostInstallTasks(setup_path, new_chrome_exe, current_version->get(), |
684 new_version, package)) { | 684 new_version, package)) { |
685 installer::InstallStatus result = | 685 installer_util::InstallStatus result = |
686 file_util::PathExists(new_chrome_exe) && current_version->get() && | 686 file_util::PathExists(new_chrome_exe) && current_version->get() && |
687 new_version.IsEqual(*current_version->get()) ? | 687 new_version.IsEqual(*current_version->get()) ? |
688 installer::SAME_VERSION_REPAIR_FAILED : | 688 installer_util::SAME_VERSION_REPAIR_FAILED : |
689 installer::INSTALL_FAILED; | 689 installer_util::INSTALL_FAILED; |
690 LOG(ERROR) << "Install failed, rolling back... result: " << result; | 690 LOG(ERROR) << "Install failed, rolling back... result: " << result; |
691 install_list->Rollback(); | 691 install_list->Rollback(); |
692 LOG(ERROR) << "Rollback complete. "; | 692 LOG(ERROR) << "Rollback complete. "; |
693 return result; | 693 return result; |
694 } | 694 } |
695 | 695 |
696 if (!current_version->get()) { | 696 if (!current_version->get()) { |
697 VLOG(1) << "First install of version " << new_version.GetString(); | 697 VLOG(1) << "First install of version " << new_version.GetString(); |
698 return installer::FIRST_INSTALL_SUCCESS; | 698 return installer_util::FIRST_INSTALL_SUCCESS; |
699 } | 699 } |
700 | 700 |
701 if (new_version.IsEqual(*current_version->get())) { | 701 if (new_version.IsEqual(*current_version->get())) { |
702 VLOG(1) << "Install repaired of version " << new_version.GetString(); | 702 VLOG(1) << "Install repaired of version " << new_version.GetString(); |
703 return installer::INSTALL_REPAIRED; | 703 return installer_util::INSTALL_REPAIRED; |
704 } | 704 } |
705 | 705 |
706 if (new_version.IsHigherThan(current_version->get())) { | 706 if (new_version.IsHigherThan(current_version->get())) { |
707 if (file_util::PathExists(new_chrome_exe)) { | 707 if (file_util::PathExists(new_chrome_exe)) { |
708 VLOG(1) << "Version updated to " << new_version.GetString() | 708 VLOG(1) << "Version updated to " << new_version.GetString() |
709 << " while running " << (*current_version)->GetString(); | 709 << " while running " << (*current_version)->GetString(); |
710 return installer::IN_USE_UPDATED; | 710 return installer_util::IN_USE_UPDATED; |
711 } | 711 } |
712 VLOG(1) << "Version updated to " << new_version.GetString(); | 712 VLOG(1) << "Version updated to " << new_version.GetString(); |
713 return installer::NEW_VERSION_UPDATED; | 713 return installer_util::NEW_VERSION_UPDATED; |
714 } | 714 } |
715 | 715 |
716 LOG(ERROR) << "Not sure how we got here while updating" | 716 LOG(ERROR) << "Not sure how we got here while updating" |
717 << ", new version: " << new_version.GetString() | 717 << ", new version: " << new_version.GetString() |
718 << ", old version: " << (*current_version)->GetString(); | 718 << ", old version: " << (*current_version)->GetString(); |
719 | 719 |
720 return installer::INSTALL_FAILED; | 720 return installer_util::INSTALL_FAILED; |
721 } | 721 } |
722 | 722 |
723 } // end namespace | 723 } // end namespace |
724 | 724 |
725 namespace installer { | 725 namespace installer { |
726 | 726 |
727 installer::InstallStatus InstallOrUpdateChrome( | 727 installer_util::InstallStatus InstallOrUpdateChrome( |
728 const FilePath& setup_path, const FilePath& archive_path, | 728 const FilePath& setup_path, const FilePath& archive_path, |
729 const FilePath& install_temp_path, const FilePath& prefs_path, | 729 const FilePath& install_temp_path, const FilePath& prefs_path, |
730 const installer::MasterPreferences& prefs, const Version& new_version, | 730 const installer_util::MasterPreferences& prefs, const Version& new_version, |
731 const Package& install) { | 731 const Package& install) { |
732 bool system_install = install.system_level(); | 732 bool system_install = install.system_level(); |
733 | 733 |
734 FilePath src_path(install_temp_path); | 734 FilePath src_path(install_temp_path); |
735 src_path = src_path.Append(kInstallSourceDir).Append(kInstallSourceChromeDir); | 735 src_path = src_path.Append(kInstallSourceDir).Append(kInstallSourceChromeDir); |
736 | 736 |
737 scoped_ptr<Version> existing_version; | 737 scoped_ptr<Version> existing_version; |
738 installer::InstallStatus result = InstallNewVersion(setup_path, | 738 installer_util::InstallStatus result = InstallNewVersion(setup_path, |
739 archive_path, src_path, install_temp_path, new_version, | 739 archive_path, src_path, install_temp_path, new_version, |
740 &existing_version, install); | 740 &existing_version, install); |
741 | 741 |
742 if (!BrowserDistribution::GetInstallReturnCode(result)) { | 742 if (!BrowserDistribution::GetInstallReturnCode(result)) { |
743 if (result == installer::FIRST_INSTALL_SUCCESS) | 743 if (result == installer_util::FIRST_INSTALL_SUCCESS) |
744 CopyPreferenceFileForFirstRun(install, prefs_path); | 744 CopyPreferenceFileForFirstRun(install, prefs_path); |
745 | 745 |
746 bool do_not_create_shortcuts = false; | 746 bool do_not_create_shortcuts = false; |
747 prefs.GetBool(installer::master_preferences::kDoNotCreateShortcuts, | 747 prefs.GetBool(installer_util::master_preferences::kDoNotCreateShortcuts, |
748 &do_not_create_shortcuts); | 748 &do_not_create_shortcuts); |
749 | 749 |
750 // Currently this only creates shortcuts for Chrome, but for other products | 750 // Currently this only creates shortcuts for Chrome, but for other products |
751 // we might want to create shortcuts. | 751 // we might want to create shortcuts. |
752 const Product* chrome_install = | 752 const Product* chrome_install = |
753 FindProduct(install.products(), BrowserDistribution::CHROME_BROWSER); | 753 FindProduct(install.products(), BrowserDistribution::CHROME_BROWSER); |
754 if (chrome_install && !do_not_create_shortcuts) { | 754 if (chrome_install && !do_not_create_shortcuts) { |
755 bool create_all_shortcut = false; | 755 bool create_all_shortcut = false; |
756 prefs.GetBool(installer::master_preferences::kCreateAllShortcuts, | 756 prefs.GetBool(installer_util::master_preferences::kCreateAllShortcuts, |
757 &create_all_shortcut); | 757 &create_all_shortcut); |
758 bool alt_shortcut = false; | 758 bool alt_shortcut = false; |
759 prefs.GetBool(installer::master_preferences::kAltShortcutText, | 759 prefs.GetBool(installer_util::master_preferences::kAltShortcutText, |
760 &alt_shortcut); | 760 &alt_shortcut); |
761 if (!CreateOrUpdateChromeShortcuts(setup_path, new_version, result, | 761 if (!CreateOrUpdateChromeShortcuts(setup_path, new_version, result, |
762 *chrome_install, create_all_shortcut, | 762 *chrome_install, create_all_shortcut, |
763 alt_shortcut)) { | 763 alt_shortcut)) { |
764 PLOG(WARNING) << "Failed to create/update start menu shortcut."; | 764 PLOG(WARNING) << "Failed to create/update start menu shortcut."; |
765 } | 765 } |
766 | 766 |
767 bool make_chrome_default = false; | 767 bool make_chrome_default = false; |
768 prefs.GetBool(installer::master_preferences::kMakeChromeDefault, | 768 prefs.GetBool(installer_util::master_preferences::kMakeChromeDefault, |
769 &make_chrome_default); | 769 &make_chrome_default); |
770 | 770 |
771 // If this is not the user's first Chrome install, but they have chosen | 771 // If this is not the user's first Chrome install, but they have chosen |
772 // Chrome to become their default browser on the download page, we must | 772 // Chrome to become their default browser on the download page, we must |
773 // force it here because the master_preferences file will not get copied | 773 // force it here because the master_preferences file will not get copied |
774 // into the build. | 774 // into the build. |
775 bool force_chrome_default_for_user = false; | 775 bool force_chrome_default_for_user = false; |
776 if (result == installer::NEW_VERSION_UPDATED || | 776 if (result == installer_util::NEW_VERSION_UPDATED || |
777 result == installer::INSTALL_REPAIRED) { | 777 result == installer_util::INSTALL_REPAIRED) { |
778 prefs.GetBool( | 778 prefs.GetBool( |
779 installer::master_preferences::kMakeChromeDefaultForUser, | 779 installer_util::master_preferences::kMakeChromeDefaultForUser, |
780 &force_chrome_default_for_user); | 780 &force_chrome_default_for_user); |
781 } | 781 } |
782 | 782 |
783 RegisterChromeOnMachine(*chrome_install, | 783 RegisterChromeOnMachine(*chrome_install, |
784 make_chrome_default || force_chrome_default_for_user); | 784 make_chrome_default || force_chrome_default_for_user); |
785 } | 785 } |
786 | 786 |
787 install.RemoveOldVersionDirectories(existing_version.get() ? | 787 install.RemoveOldVersionDirectories(existing_version.get() ? |
788 *existing_version.get() : new_version); | 788 *existing_version.get() : new_version); |
789 } | 789 } |
(...skipping 22 matching lines...) Expand all Loading... |
812 success = work_item_list->Do(); | 812 success = work_item_list->Do(); |
813 if (!success && rollback_on_failure) { | 813 if (!success && rollback_on_failure) { |
814 work_item_list->Rollback(); | 814 work_item_list->Rollback(); |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
818 return success; | 818 return success; |
819 } | 819 } |
820 | 820 |
821 } // namespace installer | 821 } // namespace installer |
OLD | NEW |