OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/win/jumplist_updater.h" | 5 #include "chrome/browser/win/jumplist_updater.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <propkey.h> | 8 #include <propkey.h> |
9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // "Task" category. | 183 // "Task" category. |
184 base::win::ScopedComPtr<IObjectCollection> collection; | 184 base::win::ScopedComPtr<IObjectCollection> collection; |
185 HRESULT result = collection.CreateInstance(CLSID_EnumerableObjectCollection, | 185 HRESULT result = collection.CreateInstance(CLSID_EnumerableObjectCollection, |
186 NULL, CLSCTX_INPROC_SERVER); | 186 NULL, CLSCTX_INPROC_SERVER); |
187 if (FAILED(result)) | 187 if (FAILED(result)) |
188 return false; | 188 return false; |
189 | 189 |
190 // Add items to the "Task" category. | 190 // Add items to the "Task" category. |
191 for (ShellLinkItemList::const_iterator it = link_items.begin(); | 191 for (ShellLinkItemList::const_iterator it = link_items.begin(); |
192 it != link_items.end(); ++it) { | 192 it != link_items.end(); ++it) { |
193 AddShellLink(collection, application_path.value(), *it); | 193 if (!AddShellLink(collection, application_path.value(), *it)) |
| 194 return false; |
194 } | 195 } |
195 | 196 |
196 // We can now add the new list to the JumpList. | 197 // We can now add the new list to the JumpList. |
197 // ICustomDestinationList::AddUserTasks() also uses the IObjectArray | 198 // ICustomDestinationList::AddUserTasks() also uses the IObjectArray |
198 // interface to retrieve each item in the list. So, we retrieve the | 199 // interface to retrieve each item in the list. So, we retrieve the |
199 // IObjectArray interface from the EnumerableObjectCollection object. | 200 // IObjectArray interface from the EnumerableObjectCollection object. |
200 base::win::ScopedComPtr<IObjectArray> object_array; | 201 base::win::ScopedComPtr<IObjectArray> object_array; |
201 result = collection.QueryInterface(object_array.Receive()); | 202 result = collection.QueryInterface(object_array.Receive()); |
202 if (FAILED(result)) | 203 if (FAILED(result)) |
203 return false; | 204 return false; |
(...skipping 25 matching lines...) Expand all Loading... |
229 // We once add the given items to this collection object and add this | 230 // We once add the given items to this collection object and add this |
230 // collection to the JumpList. | 231 // collection to the JumpList. |
231 base::win::ScopedComPtr<IObjectCollection> collection; | 232 base::win::ScopedComPtr<IObjectCollection> collection; |
232 HRESULT result = collection.CreateInstance(CLSID_EnumerableObjectCollection, | 233 HRESULT result = collection.CreateInstance(CLSID_EnumerableObjectCollection, |
233 NULL, CLSCTX_INPROC_SERVER); | 234 NULL, CLSCTX_INPROC_SERVER); |
234 if (FAILED(result)) | 235 if (FAILED(result)) |
235 return false; | 236 return false; |
236 | 237 |
237 for (ShellLinkItemList::const_iterator item = link_items.begin(); | 238 for (ShellLinkItemList::const_iterator item = link_items.begin(); |
238 item != link_items.end() && max_items > 0; ++item, --max_items) { | 239 item != link_items.end() && max_items > 0; ++item, --max_items) { |
239 scoped_refptr<ShellLinkItem> link(*item); | 240 if (!AddShellLink(collection, application_path.value(), *item)) |
240 AddShellLink(collection, application_path.value(), link); | 241 return false; |
241 } | 242 } |
242 | 243 |
243 // We can now add the new list to the JumpList. | 244 // We can now add the new list to the JumpList. |
244 // The ICustomDestinationList::AppendCategory() function needs the | 245 // The ICustomDestinationList::AppendCategory() function needs the |
245 // IObjectArray interface to retrieve each item in the list. So, we retrive | 246 // IObjectArray interface to retrieve each item in the list. So, we retrive |
246 // the IObjectArray interface from the IEnumerableObjectCollection object | 247 // the IObjectArray interface from the IEnumerableObjectCollection object |
247 // and use it. | 248 // and use it. |
248 // It seems the ICustomDestinationList::AppendCategory() function just | 249 // It seems the ICustomDestinationList::AppendCategory() function just |
249 // replaces all items in the given category with the ones in the new list. | 250 // replaces all items in the given category with the ones in the new list. |
250 base::win::ScopedComPtr<IObjectArray> object_array; | 251 base::win::ScopedComPtr<IObjectArray> object_array; |
251 result = collection.QueryInterface(object_array.Receive()); | 252 result = collection.QueryInterface(object_array.Receive()); |
252 if (FAILED(result)) | 253 if (FAILED(result)) |
253 return false; | 254 return false; |
254 | 255 |
255 return SUCCEEDED(destination_list_->AppendCategory(category_name.c_str(), | 256 return SUCCEEDED(destination_list_->AppendCategory(category_name.c_str(), |
256 object_array.get())); | 257 object_array.get())); |
257 } | 258 } |
OLD | NEW |