diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-06 19:23:11 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-06 19:23:11 +0000 |
commit | 2e1a4a80ce1c1f986beb6d9ab38bb1a166ccb6d8 (patch) | |
tree | 50a44ed10db0ef30ed1a3c315ea72f77ad07c094 /chrome | |
parent | 4d3ec0fa36368b7534a35400e75e00910f296a58 (diff) | |
download | chromium_src-2e1a4a80ce1c1f986beb6d9ab38bb1a166ccb6d8.zip chromium_src-2e1a4a80ce1c1f986beb6d9ab38bb1a166ccb6d8.tar.gz chromium_src-2e1a4a80ce1c1f986beb6d9ab38bb1a166ccb6d8.tar.bz2 |
Win 8 Start Menu shortcut changes
BUG=119242
TEST=Test DualModeApp properties are correctly set in Windows 8 on Start Menu shortcut.
Review URL: http://codereview.chromium.org/9837120
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chrome_browser_main_win.cc | 4 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_win.cc | 5 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_shortcut_manager_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/shell_integration_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/web_applications/web_app_ui.cc | 6 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_win.cc | 6 | ||||
-rw-r--r-- | chrome/installer/setup/install.cc | 33 | ||||
-rw-r--r-- | chrome/installer/setup/uninstall.cc | 16 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.cc | 63 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.h | 37 | ||||
-rw-r--r-- | chrome/installer/util/shell_util_unittest.cc | 199 |
11 files changed, 207 insertions, 174 deletions
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 44dde1a..22885d2 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -139,8 +139,8 @@ int DoUninstallTasks(bool chrome_still_running) { // We want to remove user level shortcuts and we only care about the ones // created by us and not by the installer so |alternate| is false. BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - if (!ShellUtil::RemoveChromeDesktopShortcut(dist, ShellUtil::CURRENT_USER, - false)) { + if (!ShellUtil::RemoveChromeDesktopShortcut( + dist, ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_NO_OPTIONS)) { VLOG(1) << "Failed to delete desktop shortcut."; } if (!ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index b2e0479..257d5d0 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -122,8 +122,7 @@ bool CreateChromeDesktopShortcut() { chrome_exe.value(), dist->GetIconIndex(), ShellUtil::CURRENT_USER, - false, - true); // create if doesn't exist. + ShellUtil::SHORTCUT_CREATE_ALWAYS); } // Creates the quick launch shortcut to chrome for the current user. Returns @@ -137,7 +136,7 @@ bool CreateChromeQuickLaunchShortcut() { dist, chrome_exe.value(), ShellUtil::CURRENT_USER, // create only for current user. - true); // create if doesn't exist. + ShellUtil::SHORTCUT_CREATE_ALWAYS); } void PlatformSetup(Profile* profile) { diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc index 5177c56..1e2632e 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc @@ -150,8 +150,8 @@ void CreateChromeDesktopShortcutForProfile( icon_path.empty() ? chrome_exe.value() : icon_path.value(), icon_path.empty() ? dist->GetIconIndex() : 0, ShellUtil::CURRENT_USER, - false, // Use alternate text. - create); // Create if it doesn't already exist. + create ? ShellUtil::SHORTCUT_CREATE_ALWAYS : + ShellUtil::SHORTCUT_NO_OPTIONS); } // Renames an existing Chrome desktop profile shortcut. Must be called on the @@ -203,7 +203,7 @@ void UpdateChromeDesktopShortcutForProfile( description, icon_path.empty() ? chrome_exe.value() : icon_path.value(), icon_path.empty() ? dist->GetIconIndex() : 0, - false); + ShellUtil::SHORTCUT_NO_OPTIONS); } void DeleteAutoLaunchValueForProfile( diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index f4b75e6..14e5f82 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -181,8 +181,10 @@ void MigrateWin7ShortcutsInPath( GetShortcutAppId(shell_link, &existing_app_id); if (expected_app_id != existing_app_id) { - file_util::UpdateShortcutLink(NULL, shortcut.value().c_str(), NULL, NULL, - NULL, NULL, 0, expected_app_id.c_str()); + file_util::CreateOrUpdateShortcutLink(NULL, shortcut.value().c_str(), + NULL, NULL, NULL, NULL, 0, + expected_app_id.c_str(), + file_util::SHORTCUT_NO_OPTIONS); } } } diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc index 9413d2b..6a034f4 100644 --- a/chrome/browser/ui/web_applications/web_app_ui.cc +++ b/chrome/browser/ui/web_applications/web_app_ui.cc @@ -257,14 +257,16 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() { shortcut_info_.description.resize(MAX_PATH - 1); for (size_t i = 0; i < shortcut_files_.size(); ++i) { - file_util::UpdateShortcutLink(NULL, + file_util::CreateOrUpdateShortcutLink( + NULL, shortcut_files_[i].value().c_str(), NULL, NULL, shortcut_info_.description.c_str(), icon_file.value().c_str(), 0, - app_id.c_str()); + app_id.c_str(), + file_util::SHORTCUT_NO_OPTIONS); } } diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index 97086c90..5a99442 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -229,14 +229,16 @@ void CreateShortcutTask(const FilePath& web_app_path, StringPrintf(" (%d)", unique_number)); } - success &= file_util::CreateShortcutLink(chrome_exe.value().c_str(), + success = file_util::CreateOrUpdateShortcutLink( + chrome_exe.value().c_str(), shortcut_file.value().c_str(), chrome_folder.value().c_str(), wide_switches.c_str(), description.c_str(), icon_file.value().c_str(), 0, - app_id.c_str()); + app_id.c_str(), + file_util::SHORTCUT_CREATE_ALWAYS) && success; // Any shortcut would work for the pinning. We use the first one. if (success && pin_to_taskbar && shortcut_to_pin.empty()) diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index f8c8e24..a434478 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -87,13 +87,13 @@ void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, // // If the shortcuts do not exist, the function does not recreate them during // update. +// |options|: bitfield for which the options come from ChromeShortcutOptions. void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, const FilePath& setup_path, const Version& new_version, installer::InstallStatus install_status, const Product& product, - bool create_all_shortcut, - bool alt_shortcut) { + uint32 options) { // TODO(tommi): Change this function to use WorkItemList. DCHECK(product.is_chrome()); @@ -135,7 +135,9 @@ void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, << chrome_link.value(); if (ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), chrome_link.value(), L"", product_desc, chrome_exe.value(), - browser_dist->GetIconIndex(), true)) { + browser_dist->GetIconIndex(), + ShellUtil::SHORTCUT_DUAL_MODE | + ShellUtil::SHORTCUT_CREATE_ALWAYS)) { if (base::win::GetVersion() >= base::win::VERSION_WIN7) { VLOG(1) << "Pinning new shortcut at " << chrome_link.value() << " to taskbar"; @@ -153,7 +155,7 @@ void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, << " to point to " << chrome_exe.value(); if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), chrome_link.value(), L"", product_desc, chrome_exe.value(), - browser_dist->GetIconIndex(), false)) { + browser_dist->GetIconIndex(), ShellUtil::SHORTCUT_DUAL_MODE)) { LOG(ERROR) << "Failed to update start menu shortcut at " << chrome_link.value(); } @@ -183,10 +185,11 @@ void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, AppendUninstallCommandLineFlags(installer_state, product, &arguments); VLOG(1) << "Creating/updating uninstall link at " << uninstall_link.value(); - if (!file_util::CreateShortcutLink(setup_exe.value().c_str(), + if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), uninstall_link.value().c_str(), NULL, arguments.GetCommandLineString().c_str(), NULL, - setup_exe.value().c_str(), 0, NULL)) { + setup_exe.value().c_str(), 0, NULL, + file_util::SHORTCUT_CREATE_ALWAYS)) { LOG(ERROR) << "Failed to create/update uninstall link in start menu " << " at " << uninstall_link.value(); } @@ -205,21 +208,20 @@ void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, } VLOG(1) << "Creating/updating desktop shortcut for " << chrome_exe.value() - << " will create new: " << create_all_shortcut; + << " will create new: " + << ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); if (!ShellUtil::CreateChromeDesktopShortcut(browser_dist, chrome_exe.value(), product_desc, L"", L"", chrome_exe.value(), - browser_dist->GetIconIndex(), desktop_level, alt_shortcut, - create_all_shortcut)) { + browser_dist->GetIconIndex(), desktop_level, options)) { LOG(WARNING) << "Did not create/update desktop shortcut for " << chrome_exe.value(); } VLOG(1) << "Creating/updating quick launch shortcut for " << chrome_exe.value() << " will create new: " - << create_all_shortcut; + << ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); if (!ShellUtil::CreateChromeQuickLaunchShortcut( - browser_dist, chrome_exe.value(), quick_launch_levels, - create_all_shortcut)) { + browser_dist, chrome_exe.value(), quick_launch_levels, options)) { LOG(WARNING) << "Did not create/update quick launch shortcut for " << chrome_exe.value(); } @@ -410,9 +412,14 @@ InstallStatus InstallOrUpdateProduct( &create_all_shortcut); bool alt_shortcut = false; prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); + uint32 shortcut_options = ShellUtil::SHORTCUT_NO_OPTIONS; + if (create_all_shortcut) + shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; + if (alt_shortcut) + shortcut_options |= ShellUtil::SHORTCUT_ALTERNATE; CreateOrUpdateChromeShortcuts(installer_state, setup_path, new_version, result, *chrome_install, - create_all_shortcut, alt_shortcut); + shortcut_options); bool make_chrome_default = false; prefs.GetBool(master_preferences::kMakeChromeDefault, diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 70284cc..83953e4 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -263,10 +263,14 @@ void DeleteChromeShortcuts(const InstallerState& installer_state, FilePath shortcut_path; if (installer_state.system_install()) { PathService::Get(base::DIR_COMMON_START_MENU, &shortcut_path); - if (!ShellUtil::RemoveChromeDesktopShortcut(product.distribution(), - ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, false)) { - ShellUtil::RemoveChromeDesktopShortcut(product.distribution(), - ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, true); + if (!ShellUtil::RemoveChromeDesktopShortcut( + product.distribution(), + ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_NO_OPTIONS)) { + ShellUtil::RemoveChromeDesktopShortcut( + product.distribution(), + ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_ALTERNATE); } ShellUtil::RemoveChromeQuickLaunchShortcut(product.distribution(), @@ -274,9 +278,9 @@ void DeleteChromeShortcuts(const InstallerState& installer_state, } else { PathService::Get(base::DIR_START_MENU, &shortcut_path); if (!ShellUtil::RemoveChromeDesktopShortcut(product.distribution(), - ShellUtil::CURRENT_USER, false)) { + ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_NO_OPTIONS)) { ShellUtil::RemoveChromeDesktopShortcut(product.distribution(), - ShellUtil::CURRENT_USER, true); + ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_ALTERNATE); } ShellUtil::RemoveChromeQuickLaunchShortcut(product.distribution(), diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 6fc4224..5a5957b 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -511,6 +511,15 @@ bool LaunchApplicationAssociationDialog(const std::wstring& app_id) { return SUCCEEDED(hr); } +uint32 ConvertShellUtilShortcutOptionsToFileUtil(uint32 options) { + uint32 converted_options = 0; + if (options & ShellUtil::SHORTCUT_DUAL_MODE) + converted_options |= file_util::SHORTCUT_DUAL_MODE; + if (options & ShellUtil::SHORTCUT_CREATE_ALWAYS) + converted_options |= file_util::SHORTCUT_CREATE_ALWAYS; + return converted_options; +} + } // namespace const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; @@ -567,9 +576,9 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, const std::wstring& icon_path, int icon_index, ShellChange shell_change, - bool alternate, - bool create_new) { + uint32 options) { std::wstring shortcut_name; + bool alternate = (options & ShellUtil::SHORTCUT_ALTERNATE) != 0; if (!ShellUtil::GetChromeShortcutName(dist, alternate, appended_name, &shortcut_name)) return false; @@ -594,7 +603,7 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, description, icon_path, icon_index, - create_new); + options); } } } else if (shell_change == ShellUtil::SYSTEM_LEVEL) { @@ -608,7 +617,7 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, description, icon_path, icon_index, - create_new); + options); } } else { NOTREACHED(); @@ -619,7 +628,7 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, const std::wstring& chrome_exe, int shell_change, - bool create_new) { + uint32 options) { std::wstring shortcut_name; if (!ShellUtil::GetChromeShortcutName(dist, false, L"", &shortcut_name)) return false; @@ -634,7 +643,7 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, user_ql_path.value(), L"", L"", chrome_exe, dist->GetIconIndex(), - create_new); + options); } else { ret = false; } @@ -650,7 +659,7 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, default_ql_path.value(), L"", L"", chrome_exe, dist->GetIconIndex(), - create_new) && ret; + options) && ret; } else { ret = false; } @@ -1009,8 +1018,12 @@ bool ShellUtil::RegisterChromeForProtocol(BrowserDistribution* dist, } bool ShellUtil::RemoveChromeDesktopShortcut(BrowserDistribution* dist, - int shell_change, bool alternate) { + int shell_change, uint32 options) { + // Only SHORTCUT_ALTERNATE is a valid option for this function. + DCHECK(!options || options == ShellUtil::SHORTCUT_ALTERNATE); + std::wstring shortcut_name; + bool alternate = (options & ShellUtil::SHORTCUT_ALTERNATE) != 0; if (!ShellUtil::GetChromeShortcutName(dist, alternate, L"", &shortcut_name)) return false; @@ -1095,7 +1108,7 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, const std::wstring& description, const std::wstring& icon_path, int icon_index, - bool create_new) { + uint32 options) { std::wstring chrome_path = FilePath(chrome_exe).DirName().value(); FilePath prefs_path(chrome_path); @@ -1105,25 +1118,15 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, &icon_index); } - if (create_new) { - return file_util::CreateShortcutLink( - chrome_exe.c_str(), // target - shortcut.c_str(), // shortcut - chrome_path.c_str(), // working dir - arguments.c_str(), // arguments - description.c_str(), // description - icon_path.c_str(), // icon file - icon_index, // icon index - dist->GetBrowserAppId().c_str()); // app id - } else { - return file_util::UpdateShortcutLink( - chrome_exe.c_str(), // target - shortcut.c_str(), // shortcut - chrome_path.c_str(), // working dir - arguments.c_str(), // arguments - description.c_str(), // description - icon_path.c_str(), // icon file - icon_index, // icon index - dist->GetBrowserAppId().c_str()); // app id - } + + return file_util::CreateOrUpdateShortcutLink( + chrome_exe.c_str(), + shortcut.c_str(), + chrome_path.c_str(), + arguments.c_str(), + description.c_str(), + icon_path.c_str(), + icon_index, + dist->GetBrowserAppId().c_str(), + ConvertShellUtilShortcutOptionsToFileUtil(options)); } diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index 31b2f8b..8f55943 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -106,9 +106,7 @@ class ShellUtil { // Desktop folder of current user's profile. // If |shell_change| is SYSTEM_LEVEL, the shortcut is created in the // Desktop folder of the "All Users" profile. - // If |alternate| is true, an alternate text for the shortcut is used. - // If |create_new| is false, an existing shortcut will be updated, but if - // no shortcut exists, it will not be created. + // |options|: bitfield for which the options come from ChromeShortcutOptions. // Returns true iff the method causes a shortcut to be created / updated. static bool CreateChromeDesktopShortcut(BrowserDistribution* dist, const std::wstring& chrome_exe, @@ -118,8 +116,7 @@ class ShellUtil { const std::wstring& icon_path, int icon_index, ShellChange shell_change, - bool alternate, - bool create_new); + uint32 options); // Create Chrome shortcut on Quick Launch Bar. // If shell_change is CURRENT_USER, the shortcut is created in the @@ -128,12 +125,11 @@ class ShellUtil { // Quick Launch folder of "Default User" profile. This will make sure // that this shortcut will be seen by all the new users logging into the // system. - // create_new: If false, will only update the shortcut. If true, the function - // will create a new shortcut if it doesn't exist already. + // |options|: bitfield for which the options come from ChromeShortcutOptions. static bool CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, const std::wstring& chrome_exe, int shell_change, - bool create_new); + uint32 options); // This method appends the Chrome icon index inside chrome.exe to the // chrome.exe path passed in as input, to generate the full path for @@ -264,15 +260,15 @@ class ShellUtil { bool elevate_if_not_admin); // Remove Chrome shortcut from Desktop. - // If shell_change is CURRENT_USER, the shortcut is removed from the + // If |shell_change| is CURRENT_USER, the shortcut is removed from the // Desktop folder of current user's profile. - // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the + // If |shell_change| is SYSTEM_LEVEL, the shortcut is removed from the // Desktop folder of "All Users" profile. - // If alternate is true, the shortcut with the alternate name is removed. See - // CreateChromeDesktopShortcut() for more information. + // |options|: bitfield for which the options come from ChromeShortcutOptions. + // Only SHORTCUT_ALTERNATE is a valid option for this function. static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, int shell_change, - bool alternate); + uint32 options); // Removes a set of existing Chrome desktop shortcuts. |appended_names| is a // list of shortcut file names as obtained from @@ -288,11 +284,24 @@ class ShellUtil { static bool RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, int shell_change); + enum ChromeShortcutOptions { + SHORTCUT_NO_OPTIONS = 0, + // Set DualMode property for Windows 8 Metro-enabled shortcuts. + SHORTCUT_DUAL_MODE = 1 << 0, + // Create a new shortcut (overwriting if necessary). If not specified, only + // specified (non-null) properties are going to be modified on the existing + // shortcut (which has to exist). + SHORTCUT_CREATE_ALWAYS = 1 << 1, + // Use an alternate, localized, application name for the shortcut. + SHORTCUT_ALTERNATE = 1 << 2, + }; + // Updates shortcut (or creates a new shortcut) at destination given by // shortcut to a target given by chrome_exe. The arguments are given by // |arguments| for the target and icon is set based on |icon_path| and // |icon_index|. If create_new is set to true, the function will create a new // shortcut if it doesn't exist. + // |options|: bitfield for which the options come from ChromeShortcutOptions. static bool UpdateChromeShortcut(BrowserDistribution* dist, const std::wstring& chrome_exe, const std::wstring& shortcut, @@ -300,7 +309,7 @@ class ShellUtil { const std::wstring& description, const std::wstring& icon_path, int icon_index, - bool create_new); + uint32 options); private: DISALLOW_COPY_AND_ASSIGN(ShellUtil); diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc index 4df10aa..2ad39ac 100644 --- a/chrome/installer/util/shell_util_unittest.cc +++ b/chrome/installer/util/shell_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -109,14 +109,15 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) { FilePath shortcut_path = temp_dir_.path().AppendASCII("shortcut.lnk"); const std::wstring description(L"dummy description"); - EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, - exe_path.value(), - shortcut_path.value(), - L"", - description, - exe_path.value(), - dist->GetIconIndex(), - true)); + EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( + dist, + exe_path.value(), + shortcut_path.value(), + L"", + description, + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), shortcut_path.value(), description, 0)); @@ -135,14 +136,15 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) { "}"; file.close(); ASSERT_TRUE(file_util::Delete(shortcut_path, false)); - EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, - exe_path.value(), - shortcut_path.value(), - L"", - description, - exe_path.value(), - dist->GetIconIndex(), - true)); + EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( + dist, + exe_path.value(), + shortcut_path.value(), + L"", + description, + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), shortcut_path.value(), description, 1)); @@ -157,7 +159,7 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) { description2, exe_path.value(), dist->GetIconIndex(), - false)); + ShellUtil::SHORTCUT_NO_OPTIONS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), shortcut_path.value(), description2, 1)); @@ -211,96 +213,99 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) { second_profile_shortcut_name); // Test simple creation of a user-level shortcut. - EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::CURRENT_USER, - false, - true)); + EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::CURRENT_USER, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), user_shortcut_path.value(), description, 0)); - EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, - ShellUtil::CURRENT_USER, - false)); + EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( + dist, + ShellUtil::CURRENT_USER, + ShellUtil::SHORTCUT_NO_OPTIONS)); // Test simple creation of a system-level shortcut. - EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::SYSTEM_LEVEL, - false, - true)); + EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), system_shortcut_path.value(), description, 0)); - EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, - ShellUtil::SYSTEM_LEVEL, - false)); + EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( + dist, + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_NO_OPTIONS)); // Test creation of a user-level shortcut when a system-level shortcut // is already present (should fail). - EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::SYSTEM_LEVEL, - false, - true)); - EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::CURRENT_USER, - false, - true)); + EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); + EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::CURRENT_USER, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), system_shortcut_path.value(), description, 0)); EXPECT_FALSE(file_util::PathExists(user_shortcut_path)); - EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, - ShellUtil::SYSTEM_LEVEL, - false)); + EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( + dist, + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_NO_OPTIONS)); // Test creation of a system-level shortcut when a user-level shortcut // is already present (should succeed). - EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::CURRENT_USER, - false, - true)); - EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, - exe_path.value(), - description, - L"", - L"", - exe_path.value(), - dist->GetIconIndex(), - ShellUtil::SYSTEM_LEVEL, - false, - true)); + EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::CURRENT_USER, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); + EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( + dist, + exe_path.value(), + description, + L"", + L"", + exe_path.value(), + dist->GetIconIndex(), + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), user_shortcut_path.value(), description, @@ -309,12 +314,14 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) { system_shortcut_path.value(), description, 0)); - EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, - ShellUtil::CURRENT_USER, - false)); - EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, - ShellUtil::SYSTEM_LEVEL, - false)); + EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( + dist, + ShellUtil::CURRENT_USER, + ShellUtil::SHORTCUT_NO_OPTIONS)); + EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( + dist, + ShellUtil::SYSTEM_LEVEL, + ShellUtil::SHORTCUT_NO_OPTIONS)); // Test creation of two profile-specific shortcuts (these are always // user-level). @@ -327,8 +334,7 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) { exe_path.value(), dist->GetIconIndex(), ShellUtil::CURRENT_USER, - false, - true)); + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), default_profile_shortcut_path.value(), description, @@ -342,8 +348,7 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) { exe_path.value(), dist->GetIconIndex(), ShellUtil::CURRENT_USER, - false, - true)); + ShellUtil::SHORTCUT_CREATE_ALWAYS)); EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), second_profile_shortcut_path.value(), description, |