summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_applications
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 07:14:55 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 07:14:55 +0000
commitf1024e222989f0ad1895d46bf407bac95c110b6c (patch)
treea8154c03b7ac6e04a5e2239698e5d8629f5d725a /chrome/browser/web_applications
parent69ebc68fc96a84197c8c93d2adb65e680cb2c988 (diff)
downloadchromium_src-f1024e222989f0ad1895d46bf407bac95c110b6c.zip
chromium_src-f1024e222989f0ad1895d46bf407bac95c110b6c.tar.gz
chromium_src-f1024e222989f0ad1895d46bf407bac95c110b6c.tar.bz2
Fix and re-commit http://codereview.chromium.org/10914109/ (after revert in http://crrev.com/155918) -- Refactoring and tests for the highly undertested file_util::CreateOrUpdateShortcutLink() method.
Simplify file_util::CreateOrUpdateShortcutLink()'s interface (use a struct to set parameters passed which allows callers to specify exactly what they want without having to pass in a bunch of NULLs for the unused parameters). The same concept will be used for ShellUtil's shortcut functions in an upcoming CL. Moved ShellUtil::VerifyChromeShortcut() to file_util::VerifyShortcut() and augmented it for every shortcut properties. This will also allow other shortcut creators (web apps, profiles, etc.) to have a broader test coverage on the shortcut they create (i.e. more testable properties available). I will leave it up to the owners of these various projects to augment their tests, this CL keeps the previously tested behavior, not more, not less. This is the 1st CL of a massive refactoring effort for shortcuts (http://goo.gl/Az889) in which ShellUtil's shortcut methods have to be refactored (http://codereview.chromium.org/10836247/ : soon to incorporate interface changes from this CL) which led me even lower to first refactor file_util's shortcut methods. TBR=robertshield@chromium.org, sky@chromium.org, agl@chromium.org, dgrogan@chromium.org BUG=132825, 148539 TEST=base_unittests --gtest_filter=FileUtilShortcutTest* installer_util_unitests --gtest_filter=ShellUtilTestWithDirAndDist* unit_tests --gtest_filter=ProfileShortcutManagerTest* (run tests on XP as well) Review URL: https://chromiumcodereview.appspot.com/10909171 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r--chrome/browser/web_applications/web_app_win.cc37
1 files changed, 19 insertions, 18 deletions
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index b1aca7d..cfc68e1 100644
--- a/chrome/browser/web_applications/web_app_win.cc
+++ b/chrome/browser/web_applications/web_app_win.cc
@@ -13,6 +13,7 @@
#include "base/path_service.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
+#include "base/win/shortcut.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -124,7 +125,7 @@ std::vector<FilePath> GetShortcutPaths(
bool ShortcutIsForProfile(const FilePath& shortcut_file_name,
const FilePath& profile_path) {
string16 cmd_line_string;
- if (file_util::ResolveShortcut(shortcut_file_name, NULL, &cmd_line_string)) {
+ if (base::win::ResolveShortcut(shortcut_file_name, NULL, &cmd_line_string)) {
cmd_line_string = L"program " + cmd_line_string;
CommandLine shortcut_cmd_line = CommandLine::FromString(cmd_line_string);
return shortcut_cmd_line.HasSwitch(switches::kProfileDirectory) &&
@@ -229,7 +230,7 @@ bool CreatePlatformShortcuts(
return false;
// Working directory.
- FilePath chrome_folder = chrome_exe.DirName();
+ FilePath chrome_folder(chrome_exe.DirName());
CommandLine cmd_line(CommandLine::NO_PROGRAM);
cmd_line = ShellIntegration::CommandLineArgsForLauncher(shortcut_info.url,
@@ -247,10 +248,9 @@ bool CreatePlatformShortcuts(
description.resize(MAX_PATH - 1);
// Generates app id from web app url and profile path.
- std::string app_name =
- web_app::GenerateApplicationNameFromInfo(shortcut_info);
- string16 app_id = ShellIntegration::GetAppModelIdForProfile(
- UTF8ToUTF16(app_name), shortcut_info.profile_path);
+ std::string app_name(web_app::GenerateApplicationNameFromInfo(shortcut_info));
+ string16 app_id(ShellIntegration::GetAppModelIdForProfile(
+ UTF8ToUTF16(app_name), shortcut_info.profile_path));
FilePath shortcut_to_pin;
bool success = true;
@@ -268,16 +268,17 @@ bool CreatePlatformShortcuts(
StringPrintf(" (%d)", unique_number));
}
- 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(),
- file_util::SHORTCUT_CREATE_ALWAYS) && success;
+ base::win::ShortcutProperties shortcut_properties;
+ shortcut_properties.set_target(chrome_exe);
+ shortcut_properties.set_working_dir(chrome_folder);
+ shortcut_properties.set_arguments(wide_switches);
+ shortcut_properties.set_description(description);
+ shortcut_properties.set_icon(icon_file, 0);
+ shortcut_properties.set_app_id(app_id);
+ shortcut_properties.set_dual_mode(false);
+ success = base::win::CreateOrUpdateShortcutLink(
+ shortcut_file, shortcut_properties,
+ base::win::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())
@@ -286,7 +287,7 @@ bool CreatePlatformShortcuts(
if (success && pin_to_taskbar) {
if (!shortcut_to_pin.empty()) {
- success &= file_util::TaskbarPinShortcutLink(
+ success &= base::win::TaskbarPinShortcutLink(
shortcut_to_pin.value().c_str());
} else {
success = false;
@@ -320,7 +321,7 @@ void DeletePlatformShortcuts(
j != shortcut_files.end(); ++j) {
// Any shortcut could have been pinned, either by chrome or the user, so
// they are all unpinned.
- file_util::TaskbarUnpinShortcutLink(j->value().c_str());
+ base::win::TaskbarUnpinShortcutLink(j->value().c_str());
file_util::Delete(*j, false);
}
}