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

Side by Side Diff: chrome/browser/shell_integration_win.cc

Issue 2885063003: Remove ScopedComPtr::QueryFrom() (Closed)
Patch Set: Created 3 years, 7 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/shell_integration_win.h" 5 #include "chrome/browser/shell_integration_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlwapi.h> 8 #include <shlwapi.h>
9 #include <shobjidl.h> 9 #include <shobjidl.h>
10 #include <propkey.h> // Needs to come after shobjidl.h. 10 #include <propkey.h> // Needs to come after shobjidl.h.
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 base::string16 expected_app_id( 777 base::string16 expected_app_id(
778 GetExpectedAppId(command_line, is_per_user_install)); 778 GetExpectedAppId(command_line, is_per_user_install));
779 if (expected_app_id.empty()) 779 if (expected_app_id.empty())
780 continue; 780 continue;
781 781
782 // Load the shortcut. 782 // Load the shortcut.
783 base::win::ScopedComPtr<IShellLink> shell_link; 783 base::win::ScopedComPtr<IShellLink> shell_link;
784 base::win::ScopedComPtr<IPersistFile> persist_file; 784 base::win::ScopedComPtr<IPersistFile> persist_file;
785 if (FAILED(shell_link.CreateInstance(CLSID_ShellLink, NULL, 785 if (FAILED(shell_link.CreateInstance(CLSID_ShellLink, NULL,
786 CLSCTX_INPROC_SERVER)) || 786 CLSCTX_INPROC_SERVER)) ||
787 FAILED(persist_file.QueryFrom(shell_link.Get())) || 787 FAILED(shell_link.CopyTo(persist_file.GetAddressOf())) ||
788 FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) { 788 FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) {
789 DLOG(WARNING) << "Failed loading shortcut at " << shortcut.value(); 789 DLOG(WARNING) << "Failed loading shortcut at " << shortcut.value();
790 continue; 790 continue;
791 } 791 }
792 792
793 // Any properties that need to be updated on the shortcut will be stored in 793 // Any properties that need to be updated on the shortcut will be stored in
794 // |updated_properties|. 794 // |updated_properties|.
795 base::win::ShortcutProperties updated_properties; 795 base::win::ShortcutProperties updated_properties;
796 796
797 // Validate the existing app id for the shortcut. 797 // Validate the existing app id for the shortcut.
798 base::win::ScopedComPtr<IPropertyStore> property_store; 798 base::win::ScopedComPtr<IPropertyStore> property_store;
799 propvariant.Reset(); 799 propvariant.Reset();
800 if (FAILED(property_store.QueryFrom(shell_link.Get())) || 800 if (FAILED(shell_link.CopyTo(property_store.GetAddressOf())) ||
801 property_store->GetValue(PKEY_AppUserModel_ID, propvariant.Receive()) != 801 property_store->GetValue(PKEY_AppUserModel_ID, propvariant.Receive()) !=
802 S_OK) { 802 S_OK) {
803 // When in doubt, prefer not updating the shortcut. 803 // When in doubt, prefer not updating the shortcut.
804 NOTREACHED(); 804 NOTREACHED();
805 continue; 805 continue;
806 } else { 806 } else {
807 switch (propvariant.get().vt) { 807 switch (propvariant.get().vt) {
808 case VT_EMPTY: 808 case VT_EMPTY:
809 // If there is no app_id set, set our app_id if one is expected. 809 // If there is no app_id set, set our app_id if one is expected.
810 if (!expected_app_id.empty()) 810 if (!expected_app_id.empty())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 base::win::SHORTCUT_UPDATE_EXISTING)) { 849 base::win::SHORTCUT_UPDATE_EXISTING)) {
850 ++shortcuts_migrated; 850 ++shortcuts_migrated;
851 } 851 }
852 } 852 }
853 return shortcuts_migrated; 853 return shortcuts_migrated;
854 } 854 }
855 855
856 } // namespace win 856 } // namespace win
857 857
858 } // namespace shell_integration 858 } // namespace shell_integration
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698