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

Unified Diff: chrome/browser/web_applications/web_app_win.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/web_applications/web_app_ui.cc ('k') | chrome/installer/setup/install.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_applications/web_app_win.cc
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index b1aca7d247fb499305aeb0c11ff90deab2b17377..cfc68e15518421b88cab745f74f9e467ab37a7b8 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);
}
}
« no previous file with comments | « chrome/browser/ui/web_applications/web_app_ui.cc ('k') | chrome/installer/setup/install.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698