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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/scoped_native_library.h" | 12 #include "base/scoped_native_library.h" |
13 #include "base/win/scoped_bstr.h" | 13 #include "base/win/scoped_bstr.h" |
14 #include "base/win/scoped_com_initializer.h" | 14 #include "base/win/scoped_com_initializer.h" |
15 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
16 #include "base/win/scoped_variant.h" | 16 #include "base/win/scoped_variant.h" |
17 #include "base/win/shortcut.h" | 17 #include "base/win/shortcut.h" |
18 #include "chrome/installer/util/install_util.h" | 18 #include "chrome/installer/util/install_util.h" |
19 #include "content/public/utility/utility_thread.h" | 19 #include "content/public/utility/utility_thread.h" |
| 20 #include "mojo/public/cpp/bindings/strong_binding.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // This class checks if the current executable is pinned to the taskbar. It also | 24 // This class checks if the current executable is pinned to the taskbar. It also |
24 // keeps track of the errors that occurs that prevents it from getting a result. | 25 // keeps track of the errors that occurs that prevents it from getting a result. |
25 class IsPinnedToTaskbarHelper { | 26 class IsPinnedToTaskbarHelper { |
26 public: | 27 public: |
27 IsPinnedToTaskbarHelper() = default; | 28 IsPinnedToTaskbarHelper() = default; |
28 | 29 |
29 // Returns true if the current executable is pinned to the taskbar. | 30 // Returns true if the current executable is pinned to the taskbar. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (DirectoryContainsPinnedShortcutForProgram(directory, | 200 if (DirectoryContainsPinnedShortcutForProgram(directory, |
200 current_exe_compare)) { | 201 current_exe_compare)) { |
201 return true; | 202 return true; |
202 } | 203 } |
203 } | 204 } |
204 return false; | 205 return false; |
205 } | 206 } |
206 | 207 |
207 } // namespace | 208 } // namespace |
208 | 209 |
| 210 ShellHandlerImpl::ShellHandlerImpl() = default; |
| 211 |
| 212 ShellHandlerImpl::~ShellHandlerImpl() = default; |
| 213 |
209 // static | 214 // static |
210 void ShellHandlerImpl::Create(mojom::ShellHandlerRequest request) { | 215 void ShellHandlerImpl::Create(mojom::ShellHandlerRequest request) { |
211 new ShellHandlerImpl(std::move(request)); | 216 mojo::MakeStrongBinding(base::MakeUnique<ShellHandlerImpl>(), |
| 217 std::move(request)); |
212 } | 218 } |
213 | 219 |
214 ShellHandlerImpl::ShellHandlerImpl(mojom::ShellHandlerRequest request) | |
215 : binding_(this, std::move(request)) {} | |
216 | |
217 ShellHandlerImpl::~ShellHandlerImpl() = default; | |
218 | |
219 void ShellHandlerImpl::IsPinnedToTaskbar( | 220 void ShellHandlerImpl::IsPinnedToTaskbar( |
220 const IsPinnedToTaskbarCallback& callback) { | 221 const IsPinnedToTaskbarCallback& callback) { |
221 IsPinnedToTaskbarHelper helper; | 222 IsPinnedToTaskbarHelper helper; |
222 bool is_pinned_to_taskbar = helper.GetResult(); | 223 bool is_pinned_to_taskbar = helper.GetResult(); |
223 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); | 224 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); |
224 } | 225 } |
OLD | NEW |