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

Side by Side Diff: base/file_util_win.cc

Issue 10837034: Remove packaged app Windows shortcuts when app is uninstalled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tidy up; linux and mac Created 8 years, 4 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 | « base/file_util.h ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('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 "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <propvarutil.h> 8 #include <propvarutil.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 bool is_resolved = false; 340 bool is_resolved = false;
341 341
342 // Get pointer to the IShellLink interface 342 // Get pointer to the IShellLink interface
343 result = i_shell_link.CreateInstance(CLSID_ShellLink, NULL, 343 result = i_shell_link.CreateInstance(CLSID_ShellLink, NULL,
344 CLSCTX_INPROC_SERVER); 344 CLSCTX_INPROC_SERVER);
345 if (SUCCEEDED(result)) { 345 if (SUCCEEDED(result)) {
346 base::win::ScopedComPtr<IPersistFile> persist; 346 base::win::ScopedComPtr<IPersistFile> persist;
347 // Query IShellLink for the IPersistFile interface 347 // Query IShellLink for the IPersistFile interface
348 result = persist.QueryFrom(i_shell_link); 348 result = persist.QueryFrom(i_shell_link);
349 if (SUCCEEDED(result)) { 349 if (SUCCEEDED(result)) {
350 WCHAR temp_path[MAX_PATH];
351 // Load the shell link 350 // Load the shell link
352 result = persist->Load(path->value().c_str(), STGM_READ); 351 result = persist->Load(path->value().c_str(), STGM_READ);
353 if (SUCCEEDED(result)) { 352 if (SUCCEEDED(result)) {
354 // Try to find the target of a shortcut 353 // Try to find the target of a shortcut
355 result = i_shell_link->Resolve(0, SLR_NO_UI); 354 result = i_shell_link->Resolve(0, SLR_NO_UI);
356 if (SUCCEEDED(result)) { 355 if (SUCCEEDED(result)) {
356 WCHAR temp_path[MAX_PATH];
357 result = i_shell_link->GetPath(temp_path, MAX_PATH, 357 result = i_shell_link->GetPath(temp_path, MAX_PATH,
358 NULL, SLGP_UNCPRIORITY); 358 NULL, SLGP_UNCPRIORITY);
359 *path = FilePath(temp_path); 359 *path = FilePath(temp_path);
360 is_resolved = true; 360 is_resolved = true;
361 } 361 }
362 } 362 }
363 } 363 }
364 } 364 }
365 365
366 return is_resolved; 366 return is_resolved;
367 } 367 }
368 368
369 bool GetShortcutArguments(const FilePath& shortcut_path, string16* args) {
brettw 2012/08/05 05:24:25 There's too much copy-and-pasted code here from th
brettw 2012/08/05 17:55:24 Maybe we should add a function to return a ScopedC
benwells 2012/08/07 12:24:05 OK, that all makes sense. For now I've merged thes
370 base::ThreadRestrictions::AssertIOAllowed();
371 DCHECK(args);
372
373 HRESULT result;
374 base::win::ScopedComPtr<IShellLink> i_shell_link;
375
376 // Get pointer to the IShellLink interface
377 result = i_shell_link.CreateInstance(CLSID_ShellLink, NULL,
378 CLSCTX_INPROC_SERVER);
379 if (SUCCEEDED(result)) {
380 base::win::ScopedComPtr<IPersistFile> persist;
381 // Query IShellLink for the IPersistFile interface
382 result = persist.QueryFrom(i_shell_link);
383 if (SUCCEEDED(result)) {
384 // Load the shell link
385 result = persist->Load(shortcut_path.value().c_str(), STGM_READ);
386 if (SUCCEEDED(result)) {
387 // Try to find the target of a shortcut
388 WCHAR temp_args[MAX_PATH];
389 result = i_shell_link->GetArguments(temp_args, MAX_PATH);
390 *args = string16(temp_args);
391 return true;
392 }
393 }
394 }
395
396 return false;
397 }
398
369 bool CreateOrUpdateShortcutLink(const wchar_t *source, 399 bool CreateOrUpdateShortcutLink(const wchar_t *source,
370 const wchar_t *destination, 400 const wchar_t *destination,
371 const wchar_t *working_dir, 401 const wchar_t *working_dir,
372 const wchar_t *arguments, 402 const wchar_t *arguments,
373 const wchar_t *description, 403 const wchar_t *description,
374 const wchar_t *icon, 404 const wchar_t *icon,
375 int icon_index, 405 int icon_index,
376 const wchar_t* app_id, 406 const wchar_t* app_id,
377 uint32 options) { 407 uint32 options) {
378 base::ThreadRestrictions::AssertIOAllowed(); 408 base::ThreadRestrictions::AssertIOAllowed();
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 HANDLE cp = GetCurrentProcess(); 1137 HANDLE cp = GetCurrentProcess();
1108 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { 1138 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) {
1109 *nt_path = FilePath(mapped_file_path); 1139 *nt_path = FilePath(mapped_file_path);
1110 success = true; 1140 success = true;
1111 } 1141 }
1112 ::UnmapViewOfFile(file_view); 1142 ::UnmapViewOfFile(file_view);
1113 return success; 1143 return success;
1114 } 1144 }
1115 1145
1116 } // namespace file_util 1146 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698