| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/utility/shell_handler_impl_win.h" | 5 #include "chrome/utility/shell_handler_impl_win.h" |
| 6 | 6 |
| 7 #include <shldisp.h> | 7 #include <shldisp.h> |
| 8 | 8 |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 HRESULT hresult = | 90 HRESULT hresult = |
| 91 shell_dispatch.CreateInstance(CLSID_Shell, nullptr, CLSCTX_INPROC_SERVER); | 91 shell_dispatch.CreateInstance(CLSID_Shell, nullptr, CLSCTX_INPROC_SERVER); |
| 92 if (FAILED(hresult) || !shell_dispatch) { | 92 if (FAILED(hresult) || !shell_dispatch) { |
| 93 error_occured_ = true; | 93 error_occured_ = true; |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 base::win::ScopedComPtr<Folder> folder; | 97 base::win::ScopedComPtr<Folder> folder; |
| 98 hresult = shell_dispatch->NameSpace( | 98 hresult = shell_dispatch->NameSpace( |
| 99 base::win::ScopedVariant(shortcut.DirName().value().c_str()), | 99 base::win::ScopedVariant(shortcut.DirName().value().c_str()), |
| 100 folder.Receive()); | 100 folder.GetAddressOf()); |
| 101 if (FAILED(hresult) || !folder) { | 101 if (FAILED(hresult) || !folder) { |
| 102 error_occured_ = true; | 102 error_occured_ = true; |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 base::win::ScopedComPtr<FolderItem> item; | 106 base::win::ScopedComPtr<FolderItem> item; |
| 107 hresult = folder->ParseName( | 107 hresult = folder->ParseName( |
| 108 base::win::ScopedBstr(shortcut.BaseName().value().c_str()), | 108 base::win::ScopedBstr(shortcut.BaseName().value().c_str()), |
| 109 item.Receive()); | 109 item.GetAddressOf()); |
| 110 if (FAILED(hresult) || !item) { | 110 if (FAILED(hresult) || !item) { |
| 111 error_occured_ = true; | 111 error_occured_ = true; |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 | 114 |
| 115 base::win::ScopedComPtr<FolderItemVerbs> verbs; | 115 base::win::ScopedComPtr<FolderItemVerbs> verbs; |
| 116 hresult = item->Verbs(verbs.Receive()); | 116 hresult = item->Verbs(verbs.GetAddressOf()); |
| 117 if (FAILED(hresult) || !verbs) { | 117 if (FAILED(hresult) || !verbs) { |
| 118 error_occured_ = true; | 118 error_occured_ = true; |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 long verb_count = 0; | 122 long verb_count = 0; |
| 123 hresult = verbs->get_Count(&verb_count); | 123 hresult = verbs->get_Count(&verb_count); |
| 124 if (FAILED(hresult)) { | 124 if (FAILED(hresult)) { |
| 125 error_occured_ = true; | 125 error_occured_ = true; |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 long error_count = 0; | 129 long error_count = 0; |
| 130 for (long i = 0; i < verb_count; ++i) { | 130 for (long i = 0; i < verb_count; ++i) { |
| 131 base::win::ScopedComPtr<FolderItemVerb> verb; | 131 base::win::ScopedComPtr<FolderItemVerb> verb; |
| 132 hresult = verbs->Item(base::win::ScopedVariant(i, VT_I4), verb.Receive()); | 132 hresult = |
| 133 verbs->Item(base::win::ScopedVariant(i, VT_I4), verb.GetAddressOf()); |
| 133 if (FAILED(hresult) || !verb) { | 134 if (FAILED(hresult) || !verb) { |
| 134 error_count++; | 135 error_count++; |
| 135 continue; | 136 continue; |
| 136 } | 137 } |
| 137 base::win::ScopedBstr name; | 138 base::win::ScopedBstr name; |
| 138 hresult = verb->get_Name(name.Receive()); | 139 hresult = verb->get_Name(name.Receive()); |
| 139 if (FAILED(hresult)) { | 140 if (FAILED(hresult)) { |
| 140 error_count++; | 141 error_count++; |
| 141 continue; | 142 continue; |
| 142 } | 143 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 mojo::MakeStrongBinding(base::MakeUnique<ShellHandlerImpl>(), | 221 mojo::MakeStrongBinding(base::MakeUnique<ShellHandlerImpl>(), |
| 221 std::move(request)); | 222 std::move(request)); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void ShellHandlerImpl::IsPinnedToTaskbar( | 225 void ShellHandlerImpl::IsPinnedToTaskbar( |
| 225 const IsPinnedToTaskbarCallback& callback) { | 226 const IsPinnedToTaskbarCallback& callback) { |
| 226 IsPinnedToTaskbarHelper helper; | 227 IsPinnedToTaskbarHelper helper; |
| 227 bool is_pinned_to_taskbar = helper.GetResult(); | 228 bool is_pinned_to_taskbar = helper.GetResult(); |
| 228 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); | 229 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); |
| 229 } | 230 } |
| OLD | NEW |