OLD | NEW |
---|---|
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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 if (app_id && !base::win::SetAppIdForPropertyStore(property_store, app_id)) | 439 if (app_id && !base::win::SetAppIdForPropertyStore(property_store, app_id)) |
440 return false; | 440 return false; |
441 if (is_dual_mode && | 441 if (is_dual_mode && |
442 !base::win::SetDualModeForPropertyStore(property_store)) { | 442 !base::win::SetDualModeForPropertyStore(property_store)) { |
443 return false; | 443 return false; |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 HRESULT result = i_persist_file->Save(destination, TRUE); | 447 HRESULT result = i_persist_file->Save(destination, TRUE); |
448 | 448 |
449 // If we successfully updated the icon, notify the shell that we have done so. | 449 // Release the interfaces in case the SHChangeNotify call below depends on |
450 if (!create && SUCCEEDED(result)) { | 450 // the operations above being fully completed. |
451 // Release the interfaces in case the SHChangeNotify call below depends on | 451 i_persist_file.Release(); |
452 // the operations above being fully completed. | 452 i_shell_link.Release(); |
453 i_persist_file.Release(); | |
454 i_shell_link.Release(); | |
455 | 453 |
456 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | 454 // If we successfully created/updated the icon, notify the shell that we have |
455 // done so. | |
456 const bool succeeded = SUCCEEDED(result); | |
457 if (succeeded) { | |
458 if (create) | |
459 SHChangeNotify(SHCNE_CREATE, SHCNF_PATH, destination, NULL); | |
460 else | |
grt (UTC plus 2)
2012/09/01 03:20:28
add braces here and to the if side unless you remo
gab
2012/09/01 22:28:40
Done.
| |
461 // TODO(gab): Only use SHCNE_ASSOCCHANGED when the icon changed. | |
grt (UTC plus 2)
2012/09/01 03:20:28
is it even possible to put icon change detection l
gab
2012/09/01 22:28:40
My goal is to modify this function to check (for u
grt (UTC plus 2)
2012/09/02 14:18:19
The last time the icon changed, there was nothing
grt (UTC plus 2)
2012/09/04 18:44:35
As discussed, it isn't practical to detect the ico
gab
2012/09/04 18:51:07
Done.
| |
462 // Otherwise a simple SHCNE_UPDATEITEM should be sufficient. | |
463 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | |
457 } | 464 } |
458 | 465 |
459 return SUCCEEDED(result); | 466 return succeeded; |
460 } | 467 } |
461 | 468 |
462 bool TaskbarPinShortcutLink(const wchar_t* shortcut) { | 469 bool TaskbarPinShortcutLink(const wchar_t* shortcut) { |
463 base::ThreadRestrictions::AssertIOAllowed(); | 470 base::ThreadRestrictions::AssertIOAllowed(); |
464 | 471 |
465 // "Pin to taskbar" is only supported after Win7. | 472 // "Pin to taskbar" is only supported after Win7. |
466 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 473 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
467 return false; | 474 return false; |
468 | 475 |
469 int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut, | 476 int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut, |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 HANDLE cp = GetCurrentProcess(); | 1129 HANDLE cp = GetCurrentProcess(); |
1123 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { | 1130 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { |
1124 *nt_path = FilePath(mapped_file_path); | 1131 *nt_path = FilePath(mapped_file_path); |
1125 success = true; | 1132 success = true; |
1126 } | 1133 } |
1127 ::UnmapViewOfFile(file_view); | 1134 ::UnmapViewOfFile(file_view); |
1128 return success; | 1135 return success; |
1129 } | 1136 } |
1130 | 1137 |
1131 } // namespace file_util | 1138 } // namespace file_util |
OLD | NEW |