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

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

Issue 10914109: Refactoring and tests for the highly undertested file_util::CreateOrUpdateShortcutLink() method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespace s/Win/win 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
« no previous file with comments | « chrome/browser/web_applications/web_app_win.cc ('k') | chrome/installer/setup/uninstall.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) 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/win/shortcut.h"
20 #include "base/win/windows_version.h" 21 #include "base/win/windows_version.h"
21 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
22 #include "chrome/installer/setup/setup_constants.h" 23 #include "chrome/installer/setup/setup_constants.h"
23 #include "chrome/installer/setup/install_worker.h" 24 #include "chrome/installer/setup/install_worker.h"
24 #include "chrome/installer/util/auto_launch_util.h" 25 #include "chrome/installer/util/auto_launch_util.h"
25 #include "chrome/installer/util/browser_distribution.h" 26 #include "chrome/installer/util/browser_distribution.h"
26 #include "chrome/installer/util/create_reg_key_work_item.h" 27 #include "chrome/installer/util/create_reg_key_work_item.h"
27 #include "chrome/installer/util/delete_after_reboot_helper.h" 28 #include "chrome/installer/util/delete_after_reboot_helper.h"
28 #include "chrome/installer/util/google_update_constants.h" 29 #include "chrome/installer/util/google_update_constants.h"
29 #include "chrome/installer/util/helper.h" 30 #include "chrome/installer/util/helper.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 chrome_link.value(), string16(), product_desc, chrome_exe.value(), 303 chrome_link.value(), string16(), product_desc, chrome_exe.value(),
303 browser_dist->GetIconIndex(), options)) { 304 browser_dist->GetIconIndex(), options)) {
304 LOG(WARNING) << operation << " shortcut at " << chrome_link.value() 305 LOG(WARNING) << operation << " shortcut at " << chrome_link.value()
305 << " failed."; 306 << " failed.";
306 } else if (create_always && 307 } else if (create_always &&
307 base::win::GetVersion() >= base::win::VERSION_WIN7) { 308 base::win::GetVersion() >= base::win::VERSION_WIN7) {
308 // If the Start Menu shortcut was successfully created and |create_always|, 309 // If the Start Menu shortcut was successfully created and |create_always|,
309 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. 310 // proceed to pin the Start Menu shortcut to the taskbar on Win7+.
310 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() 311 VLOG(1) << "Pinning new shortcut at " << chrome_link.value()
311 << " to taskbar"; 312 << " to taskbar";
312 if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { 313 if (!base::win::TaskbarPinShortcutLink(chrome_link.value().c_str())) {
313 LOG(ERROR) << "Failed to pin shortcut to taskbar: " 314 LOG(ERROR) << "Failed to pin shortcut to taskbar: "
314 << chrome_link.value(); 315 << chrome_link.value();
315 } 316 }
316 } 317 }
317 318
318 // Create/update uninstall link if we are not an MSI install. MSI 319 // Create/update uninstall link if we are not an MSI install. MSI
319 // installations are, for the time being, managed only through the 320 // installations are, for the time being, managed only through the
320 // Add/Remove Programs dialog. 321 // Add/Remove Programs dialog.
321 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. 322 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here.
322 if (!installer_state.is_msi()) { 323 if (!installer_state.is_msi()) {
323 // Uninstall Chrome link 324 // Uninstall Chrome link
324 FilePath uninstall_link(start_menu_folder_path.Append( 325 FilePath uninstall_link(start_menu_folder_path.Append(
325 browser_dist->GetUninstallLinkName() + L".lnk")); 326 browser_dist->GetUninstallLinkName() + L".lnk"));
326 327
327 CommandLine arguments(CommandLine::NO_PROGRAM); 328 CommandLine arguments(CommandLine::NO_PROGRAM);
328 AppendUninstallCommandLineFlags(installer_state, product, &arguments); 329 AppendUninstallCommandLineFlags(installer_state, product, &arguments);
329 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); 330 VLOG(1) << operation << " uninstall link at " << uninstall_link.value();
330 if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), 331 base::win::ShortcutProperties shortcut_properties;
331 uninstall_link.value().c_str(), NULL, 332 shortcut_properties.set_target(setup_exe);
332 arguments.GetCommandLineString().c_str(), NULL, 333 shortcut_properties.set_arguments(arguments.GetCommandLineString());
333 setup_exe.value().c_str(), 0, NULL, 334 shortcut_properties.set_icon(setup_exe, 0);
334 create_always ? file_util::SHORTCUT_CREATE_ALWAYS : 335 if (!base::win::CreateOrUpdateShortcutLink(
335 file_util::SHORTCUT_NO_OPTIONS)) { 336 uninstall_link, shortcut_properties,
337 create_always ? base::win::SHORTCUT_CREATE_ALWAYS :
338 base::win::SHORTCUT_UPDATE_EXISTING)) {
336 LOG(WARNING) << operation << " uninstall link at " 339 LOG(WARNING) << operation << " uninstall link at "
337 << uninstall_link.value() << " failed."; 340 << uninstall_link.value() << " failed.";
338 } 341 }
339 } 342 }
340 } 343 }
341 344
342 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( 345 void CreateOrUpdateDesktopAndQuickLaunchShortcuts(
343 const InstallerState& installer_state, 346 const InstallerState& installer_state,
344 const Product& product, 347 const Product& product,
345 uint32 options) { 348 uint32 options) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; 566 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE;
564 CreateOrUpdateDesktopAndQuickLaunchShortcuts( 567 CreateOrUpdateDesktopAndQuickLaunchShortcuts(
565 installer_state, chrome, shortcut_options); 568 installer_state, chrome, shortcut_options);
566 CreateOrUpdateStartMenuAndTaskbarShortcuts( 569 CreateOrUpdateStartMenuAndTaskbarShortcuts(
567 installer_state, setup_exe, chrome, shortcut_options); 570 installer_state, setup_exe, chrome, shortcut_options);
568 RegisterChromeOnMachine(installer_state, chrome, false); 571 RegisterChromeOnMachine(installer_state, chrome, false);
569 } 572 }
570 } 573 }
571 574
572 } // namespace installer 575 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_win.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698