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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 10889028: Install a user-level Start Menu shortcut for every user on system-installs through Active Setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments + exit code + create shell notify Created 8 years, 3 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
OLDNEW
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
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()) {
grt (UTC plus 2) 2012/09/01 03:20:28 nit: remove braces
gab 2012/09/01 22:28:40 Done.
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 // TODO(gab): This is a hack that is temporarily required for the Start Menu
347 // (now Start Screen) shortcut to show up on Win8. This will be removed when I'm
348 // done refactoring ShellUtil as part of http://goo.gl/Az889.
349 void ForceCreateUserLevelStartMenuShortcut(
350 const InstallerState& installer_state,
351 const Product& product) {
352 BrowserDistribution* browser_dist = product.distribution();
353 const string16 product_name(browser_dist->GetAppShortCutName());
354 const string16 product_desc(browser_dist->GetAppDescription());
355 const FilePath chrome_exe(
356 installer_state.target_path().Append(installer::kChromeExe));
357
358 FilePath start_menu_user_level;
grt (UTC plus 2) 2012/09/01 03:20:28 start_menu_user_level -> user_start_menu or per_us
gab 2012/09/01 22:28:40 Done.
359 if (!PathService::Get(base::DIR_START_MENU, &start_menu_user_level)) {
360 LOG(ERROR) << "Failed to get user-level start menu path.";
grt (UTC plus 2) 2012/09/01 03:20:28 i like DFATAL here since failure is extremely unex
gab 2012/09/01 22:28:40 Sure, although this makes the code differ more fro
361 return;
362 }
363 start_menu_user_level = start_menu_user_level.Append(product_name);
364 file_util::CreateDirectory(start_menu_user_level);
grt (UTC plus 2) 2012/09/01 03:20:28 y u no handle result? i suppose you could argue t
gab 2012/09/01 22:28:40 Again, keeping the same behavior as its copy-paste
grt (UTC plus 2) 2012/09/02 14:18:19 On its own, this isn't a good enough reason. The
365
366 const FilePath chrome_link(
367 start_menu_user_level.Append(product_name + L".lnk"));
368
369 const uint32 options = (ShellUtil::SHORTCUT_CREATE_ALWAYS |
370 ShellUtil::SHORTCUT_DUAL_MODE);
371
372 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at "
373 << chrome_link.value();
374 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(),
375 chrome_link.value(), string16(), product_desc, chrome_exe.value(),
376 browser_dist->GetIconIndex(), options)) {
377 LOG(ERROR) << "Creating shortcut at " << chrome_link.value()
378 << " failed.";
grt (UTC plus 2) 2012/09/01 03:20:28 nit: indentation (does this fit on the previous li
gab 2012/09/01 22:28:40 good eyes sir
379 }
380 }
381
342 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( 382 void CreateOrUpdateDesktopAndQuickLaunchShortcuts(
343 const InstallerState& installer_state, 383 const InstallerState& installer_state,
344 const Product& product, 384 const Product& product,
345 uint32 options) { 385 uint32 options) {
346 // TODO(tommi): Change this function to use WorkItemList. 386 // TODO(tommi): Change this function to use WorkItemList.
347 DCHECK(product.is_chrome()); 387 DCHECK(product.is_chrome());
348 388
349 // Information used for all shortcut types 389 // Information used for all shortcut types
350 BrowserDistribution* browser_dist = product.distribution(); 390 BrowserDistribution* browser_dist = product.distribution();
351 const string16 product_name(browser_dist->GetAppShortCutName()); 391 const string16 product_name(browser_dist->GetAppShortCutName());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 installer_state.RemoveOldVersionDirectories( 586 installer_state.RemoveOldVersionDirectories(
547 new_version, 587 new_version,
548 existing_version.get(), 588 existing_version.get(),
549 install_temp_path); 589 install_temp_path);
550 } 590 }
551 591
552 return result; 592 return result;
553 } 593 }
554 594
555 } // namespace installer 595 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698