Chromium Code Reviews| 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 | |
| 461 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | |
|
Sigurður Ásgeirsson
2012/09/10 18:52:32
Is it not sufficient here to so SHCNE_UPDATEITEM w
| |
| 457 } | 462 } |
| 458 | 463 |
| 459 return SUCCEEDED(result); | 464 return succeeded; |
| 460 } | 465 } |
| 461 | 466 |
| 462 bool TaskbarPinShortcutLink(const wchar_t* shortcut) { | 467 bool TaskbarPinShortcutLink(const wchar_t* shortcut) { |
| 463 base::ThreadRestrictions::AssertIOAllowed(); | 468 base::ThreadRestrictions::AssertIOAllowed(); |
| 464 | 469 |
| 465 // "Pin to taskbar" is only supported after Win7. | 470 // "Pin to taskbar" is only supported after Win7. |
| 466 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 471 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 467 return false; | 472 return false; |
| 468 | 473 |
| 469 int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut, | 474 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(); | 1127 HANDLE cp = GetCurrentProcess(); |
| 1123 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { | 1128 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { |
| 1124 *nt_path = FilePath(mapped_file_path); | 1129 *nt_path = FilePath(mapped_file_path); |
| 1125 success = true; | 1130 success = true; |
| 1126 } | 1131 } |
| 1127 ::UnmapViewOfFile(file_view); | 1132 ::UnmapViewOfFile(file_view); |
| 1128 return success; | 1133 return success; |
| 1129 } | 1134 } |
| 1130 | 1135 |
| 1131 } // namespace file_util | 1136 } // namespace file_util |
| OLD | NEW |