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 #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 #include <winuser.h> | 9 #include <winuser.h> |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 // If the Start Menu shortcut was successfully created and |create_always|, | 308 // If the Start Menu shortcut was successfully created and |create_always|, |
309 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. | 309 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. |
310 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() | 310 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() |
311 << " to taskbar"; | 311 << " to taskbar"; |
312 if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { | 312 if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { |
313 LOG(ERROR) << "Failed to pin shortcut to taskbar: " | 313 LOG(ERROR) << "Failed to pin shortcut to taskbar: " |
314 << chrome_link.value(); | 314 << chrome_link.value(); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 if (create_always && installer_state.system_install()) { | |
319 ForceCreateUserLevelStartMenuShortcut(installer_state, product); | |
320 } | |
321 | |
318 // Create/update uninstall link if we are not an MSI install. MSI | 322 // Create/update uninstall link if we are not an MSI install. MSI |
319 // installations are, for the time being, managed only through the | 323 // installations are, for the time being, managed only through the |
320 // Add/Remove Programs dialog. | 324 // Add/Remove Programs dialog. |
321 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. | 325 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
322 if (!installer_state.is_msi()) { | 326 if (!installer_state.is_msi()) { |
323 // Uninstall Chrome link | 327 // Uninstall Chrome link |
324 FilePath uninstall_link(start_menu_folder_path.Append( | 328 FilePath uninstall_link(start_menu_folder_path.Append( |
325 browser_dist->GetUninstallLinkName() + L".lnk")); | 329 browser_dist->GetUninstallLinkName() + L".lnk")); |
326 | 330 |
327 CommandLine arguments(CommandLine::NO_PROGRAM); | 331 CommandLine arguments(CommandLine::NO_PROGRAM); |
328 AppendUninstallCommandLineFlags(installer_state, product, &arguments); | 332 AppendUninstallCommandLineFlags(installer_state, product, &arguments); |
329 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); | 333 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); |
330 if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), | 334 if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), |
331 uninstall_link.value().c_str(), NULL, | 335 uninstall_link.value().c_str(), NULL, |
332 arguments.GetCommandLineString().c_str(), NULL, | 336 arguments.GetCommandLineString().c_str(), NULL, |
333 setup_exe.value().c_str(), 0, NULL, | 337 setup_exe.value().c_str(), 0, NULL, |
334 create_always ? file_util::SHORTCUT_CREATE_ALWAYS : | 338 create_always ? file_util::SHORTCUT_CREATE_ALWAYS : |
335 file_util::SHORTCUT_NO_OPTIONS)) { | 339 file_util::SHORTCUT_NO_OPTIONS)) { |
336 LOG(WARNING) << operation << " uninstall link at " | 340 LOG(WARNING) << operation << " uninstall link at " |
337 << uninstall_link.value() << " failed."; | 341 << uninstall_link.value() << " failed."; |
338 } | 342 } |
339 } | 343 } |
340 } | 344 } |
341 | 345 |
346 void ForceCreateUserLevelStartMenuShortcut( | |
347 const InstallerState& installer_state, | |
348 const Product& product) { | |
349 BrowserDistribution* browser_dist = product.distribution(); | |
350 const string16 product_name(browser_dist->GetAppShortCutName()); | |
351 const string16 product_desc(browser_dist->GetAppDescription()); | |
352 const FilePath chrome_exe( | |
353 installer_state.target_path().Append(installer::kChromeExe)); | |
354 | |
355 FilePath start_menu_user_level; | |
356 if (!PathService::Get(base::DIR_START_MENU, &start_menu_user_level)) { | |
357 LOG(ERROR) << "Failed to get user-level start menu path."; | |
358 return; | |
359 } | |
360 start_menu_user_level = start_menu_user_level.Append(product_name); | |
361 if (!file_util::PathExists(start_menu_user_level)) | |
grt (UTC plus 2)
2012/08/29 17:07:06
no need for this check, as CreateDirectory does it
gab
2012/08/29 21:53:00
Done.
| |
362 file_util::CreateDirectoryW(start_menu_user_level); | |
grt (UTC plus 2)
2012/08/29 17:07:06
CreateDirectoryW -> CreateDirectory
gab
2012/08/29 21:53:00
Done.
| |
363 | |
364 const FilePath chrome_link( | |
365 start_menu_user_level.Append(product_name + L".lnk")); | |
366 | |
367 const uint32 options = (ShellUtil::SHORTCUT_CREATE_ALWAYS | | |
368 ShellUtil::SHORTCUT_DUAL_MODE); | |
369 | |
370 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at " | |
371 << chrome_link.value(); | |
372 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | |
373 chrome_link.value(), string16(), product_desc, chrome_exe.value(), | |
374 browser_dist->GetIconIndex(), options)) { | |
375 LOG(WARNING) << "Creating shortcut at " << chrome_link.value() | |
grt (UTC plus 2)
2012/08/29 17:07:06
WARNING -> ERROR?
gab
2012/08/29 21:53:00
Done.
| |
376 << " failed."; | |
377 } | |
378 } | |
379 | |
342 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 380 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
343 const InstallerState& installer_state, | 381 const InstallerState& installer_state, |
344 const Product& product, | 382 const Product& product, |
345 uint32 options) { | 383 uint32 options) { |
346 // TODO(tommi): Change this function to use WorkItemList. | 384 // TODO(tommi): Change this function to use WorkItemList. |
347 DCHECK(product.is_chrome()); | 385 DCHECK(product.is_chrome()); |
348 | 386 |
349 // Information used for all shortcut types | 387 // Information used for all shortcut types |
350 BrowserDistribution* browser_dist = product.distribution(); | 388 BrowserDistribution* browser_dist = product.distribution(); |
351 const string16 product_name(browser_dist->GetAppShortCutName()); | 389 const string16 product_name(browser_dist->GetAppShortCutName()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 installer_state.RemoveOldVersionDirectories( | 584 installer_state.RemoveOldVersionDirectories( |
547 new_version, | 585 new_version, |
548 existing_version.get(), | 586 existing_version.get(), |
549 install_temp_path); | 587 install_temp_path); |
550 } | 588 } |
551 | 589 |
552 return result; | 590 return result; |
553 } | 591 } |
554 | 592 |
555 } // namespace installer | 593 } // namespace installer |
OLD | NEW |