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

Side by Side Diff: chrome/browser/web_applications/web_app_win.cc

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rearranged code for unpacked_installer.cc; moved App Host code from chrome_launch_support to app_ho… Created 8 years, 2 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
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/browser/web_applications/web_app.h" 5 #include "chrome/browser/web_applications/web_app.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/md5.h" 12 #include "base/md5.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/win/shortcut.h" 16 #include "base/win/shortcut.h"
17 #include "base/win/windows_version.h" 17 #include "base/win/windows_version.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "ui/gfx/icon_util.h" 21 #include "ui/gfx/icon_util.h"
21 22
22 namespace { 23 namespace {
23 24
24 const FilePath::CharType kIconChecksumFileExt[] = FILE_PATH_LITERAL(".ico.md5"); 25 const FilePath::CharType kIconChecksumFileExt[] = FILE_PATH_LITERAL(".ico.md5");
25 26
26 // Calculates image checksum using MD5. 27 // Calculates image checksum using MD5.
27 void GetImageCheckSum(const SkBitmap& image, base::MD5Digest* digest) { 28 void GetImageCheckSum(const SkBitmap& image, base::MD5Digest* digest) {
28 DCHECK(digest); 29 DCHECK(digest);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 web_app::internals::GetSanitizedFileName(shortcut_info.title); 218 web_app::internals::GetSanitizedFileName(shortcut_info.title);
218 219
219 // Creates an ico file to use with shortcut. 220 // Creates an ico file to use with shortcut.
220 FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension( 221 FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension(
221 FILE_PATH_LITERAL(".ico")); 222 FILE_PATH_LITERAL(".ico"));
222 if (!web_app::internals::CheckAndSaveIcon(icon_file, 223 if (!web_app::internals::CheckAndSaveIcon(icon_file,
223 *shortcut_info.favicon.ToSkBitmap())) { 224 *shortcut_info.favicon.ToSkBitmap())) {
224 return false; 225 return false;
225 } 226 }
226 227
227 FilePath chrome_exe; 228 FilePath app_host_exe(chrome_launcher_support::GetAnyAppHostPath());
228 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) 229 if (app_host_exe.empty())
229 return false; 230 return false;
230 231
231 // Working directory. 232 // Working directory.
232 FilePath chrome_folder(chrome_exe.DirName()); 233 FilePath working_dir(app_host_exe.DirName());
233 234
234 CommandLine cmd_line(CommandLine::NO_PROGRAM); 235 CommandLine cmd_line(CommandLine::NO_PROGRAM);
235 cmd_line = ShellIntegration::CommandLineArgsForLauncher(shortcut_info.url, 236 cmd_line = ShellIntegration::CommandLineArgsForLauncher(shortcut_info.url,
236 shortcut_info.extension_id, shortcut_info.profile_path); 237 shortcut_info.extension_id, shortcut_info.profile_path);
237 238
238 // TODO(evan): we rely on the fact that command_line_string() is 239 // TODO(evan): we rely on the fact that command_line_string() is
239 // properly quoted for a Windows command line. The method on 240 // properly quoted for a Windows command line. The method on
240 // CommandLine should probably be renamed to better reflect that 241 // CommandLine should probably be renamed to better reflect that
241 // fact. 242 // fact.
242 string16 wide_switches(cmd_line.GetCommandLineString()); 243 string16 wide_switches(cmd_line.GetCommandLineString());
(...skipping 18 matching lines...) Expand all
261 file_util::GetUniquePathNumber(shortcut_file, FILE_PATH_LITERAL("")); 262 file_util::GetUniquePathNumber(shortcut_file, FILE_PATH_LITERAL(""));
262 if (unique_number == -1) { 263 if (unique_number == -1) {
263 success = false; 264 success = false;
264 continue; 265 continue;
265 } else if (unique_number > 0) { 266 } else if (unique_number > 0) {
266 shortcut_file = shortcut_file.InsertBeforeExtensionASCII( 267 shortcut_file = shortcut_file.InsertBeforeExtensionASCII(
267 StringPrintf(" (%d)", unique_number)); 268 StringPrintf(" (%d)", unique_number));
268 } 269 }
269 270
270 base::win::ShortcutProperties shortcut_properties; 271 base::win::ShortcutProperties shortcut_properties;
271 shortcut_properties.set_target(chrome_exe); 272 shortcut_properties.set_target(app_host_exe);
272 shortcut_properties.set_working_dir(chrome_folder); 273 shortcut_properties.set_working_dir(working_dir);
273 shortcut_properties.set_arguments(wide_switches); 274 shortcut_properties.set_arguments(wide_switches);
274 shortcut_properties.set_description(description); 275 shortcut_properties.set_description(description);
275 shortcut_properties.set_icon(icon_file, 0); 276 shortcut_properties.set_icon(icon_file, 0);
276 shortcut_properties.set_app_id(app_id); 277 shortcut_properties.set_app_id(app_id);
277 shortcut_properties.set_dual_mode(false); 278 shortcut_properties.set_dual_mode(false);
278 success = base::win::CreateOrUpdateShortcutLink( 279 success = base::win::CreateOrUpdateShortcutLink(
279 shortcut_file, shortcut_properties, 280 shortcut_file, shortcut_properties,
280 base::win::SHORTCUT_CREATE_ALWAYS) && success; 281 base::win::SHORTCUT_CREATE_ALWAYS) && success;
281 282
282 // Any shortcut would work for the pinning. We use the first one. 283 // Any shortcut would work for the pinning. We use the first one.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // they are all unpinned. 323 // they are all unpinned.
323 base::win::TaskbarUnpinShortcutLink(j->value().c_str()); 324 base::win::TaskbarUnpinShortcutLink(j->value().c_str());
324 file_util::Delete(*j, false); 325 file_util::Delete(*j, false);
325 } 326 }
326 } 327 }
327 } 328 }
328 329
329 } // namespace internals 330 } // namespace internals
330 331
331 } // namespace web_app 332 } // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698