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

Side by Side Diff: base/win/shortcut.cc

Issue 2792383003: Rename ScopedComPtr::Release() to ScopedComPtr::Reset() (Closed)
Patch Set: Fix New Callers Created 3 years, 8 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
« no previous file with comments | « base/win/scoped_comptr_unittest.cc ('k') | chrome/browser/google/google_update_win.cc » ('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/win/shortcut.h" 5 #include "base/win/shortcut.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <propkey.h> 9 #include <propkey.h>
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 // Initializes |i_shell_link| and |i_persist_file| (releasing them first if they 23 // Initializes |i_shell_link| and |i_persist_file| (releasing them first if they
24 // are already initialized). 24 // are already initialized).
25 // If |shortcut| is not NULL, loads |shortcut| into |i_persist_file|. 25 // If |shortcut| is not NULL, loads |shortcut| into |i_persist_file|.
26 // If any of the above steps fail, both |i_shell_link| and |i_persist_file| will 26 // If any of the above steps fail, both |i_shell_link| and |i_persist_file| will
27 // be released. 27 // be released.
28 void InitializeShortcutInterfaces( 28 void InitializeShortcutInterfaces(
29 const wchar_t* shortcut, 29 const wchar_t* shortcut,
30 ScopedComPtr<IShellLink>* i_shell_link, 30 ScopedComPtr<IShellLink>* i_shell_link,
31 ScopedComPtr<IPersistFile>* i_persist_file) { 31 ScopedComPtr<IPersistFile>* i_persist_file) {
32 i_shell_link->Release(); 32 i_shell_link->Reset();
33 i_persist_file->Release(); 33 i_persist_file->Reset();
34 if (FAILED(i_shell_link->CreateInstance(CLSID_ShellLink, NULL, 34 if (FAILED(i_shell_link->CreateInstance(CLSID_ShellLink, NULL,
35 CLSCTX_INPROC_SERVER)) || 35 CLSCTX_INPROC_SERVER)) ||
36 FAILED(i_persist_file->QueryFrom(i_shell_link->get())) || 36 FAILED(i_persist_file->QueryFrom(i_shell_link->get())) ||
37 (shortcut && FAILED((*i_persist_file)->Load(shortcut, STGM_READWRITE)))) { 37 (shortcut && FAILED((*i_persist_file)->Load(shortcut, STGM_READWRITE)))) {
38 i_shell_link->Release(); 38 i_shell_link->Reset();
39 i_persist_file->Release(); 39 i_persist_file->Reset();
40 } 40 }
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 ShortcutProperties::ShortcutProperties() 45 ShortcutProperties::ShortcutProperties()
46 : icon_index(-1), dual_mode(false), options(0U) { 46 : icon_index(-1), dual_mode(false), options(0U) {
47 } 47 }
48 48
49 ShortcutProperties::ShortcutProperties(const ShortcutProperties& other) = 49 ShortcutProperties::ShortcutProperties(const ShortcutProperties& other) =
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (has_dual_mode && 151 if (has_dual_mode &&
152 !SetBooleanValueForPropertyStore(property_store.get(), 152 !SetBooleanValueForPropertyStore(property_store.get(),
153 PKEY_AppUserModel_IsDualMode, 153 PKEY_AppUserModel_IsDualMode,
154 properties.dual_mode)) { 154 properties.dual_mode)) {
155 return false; 155 return false;
156 } 156 }
157 } 157 }
158 158
159 // Release the interfaces to the old shortcut to make sure it doesn't prevent 159 // Release the interfaces to the old shortcut to make sure it doesn't prevent
160 // overwriting it if needed. 160 // overwriting it if needed.
161 old_i_persist_file.Release(); 161 old_i_persist_file.Reset();
162 old_i_shell_link.Release(); 162 old_i_shell_link.Reset();
163 163
164 HRESULT result = i_persist_file->Save(shortcut_path.value().c_str(), TRUE); 164 HRESULT result = i_persist_file->Save(shortcut_path.value().c_str(), TRUE);
165 165
166 // Release the interfaces in case the SHChangeNotify call below depends on 166 // Release the interfaces in case the SHChangeNotify call below depends on
167 // the operations above being fully completed. 167 // the operations above being fully completed.
168 i_persist_file.Release(); 168 i_persist_file.Reset();
169 i_shell_link.Release(); 169 i_shell_link.Reset();
170 170
171 // If we successfully created/updated the icon, notify the shell that we have 171 // If we successfully created/updated the icon, notify the shell that we have
172 // done so. 172 // done so.
173 const bool succeeded = SUCCEEDED(result); 173 const bool succeeded = SUCCEEDED(result);
174 if (succeeded) { 174 if (succeeded) {
175 if (shortcut_existed) { 175 if (shortcut_existed) {
176 // TODO(gab): SHCNE_UPDATEITEM might be sufficient here; further testing 176 // TODO(gab): SHCNE_UPDATEITEM might be sufficient here; further testing
177 // required. 177 // required.
178 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); 178 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
179 } else { 179 } else {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (GetVersion() < VERSION_WIN7) 340 if (GetVersion() < VERSION_WIN7)
341 return false; 341 return false;
342 342
343 intptr_t result = reinterpret_cast<intptr_t>(ShellExecute( 343 intptr_t result = reinterpret_cast<intptr_t>(ShellExecute(
344 NULL, L"taskbarunpin", shortcut.value().c_str(), NULL, NULL, 0)); 344 NULL, L"taskbarunpin", shortcut.value().c_str(), NULL, NULL, 0));
345 return result > 32; 345 return result > 32;
346 } 346 }
347 347
348 } // namespace win 348 } // namespace win
349 } // namespace base 349 } // namespace base
OLDNEW
« no previous file with comments | « base/win/scoped_comptr_unittest.cc ('k') | chrome/browser/google/google_update_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698