| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 bool error_occured_ = false; | 55 bool error_occured_ = false; |
| 56 base::win::ScopedCOMInitializer scoped_com_initializer_; | 56 base::win::ScopedCOMInitializer scoped_com_initializer_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(IsPinnedToTaskbarHelper); | 58 DISALLOW_COPY_AND_ASSIGN(IsPinnedToTaskbarHelper); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 base::string16 IsPinnedToTaskbarHelper::LoadShellResourceString( | 61 base::string16 IsPinnedToTaskbarHelper::LoadShellResourceString( |
| 62 uint32_t resource_id) { | 62 uint32_t resource_id) { |
| 63 base::ScopedNativeLibrary scoped_native_library(::LoadLibraryEx( | 63 base::ScopedNativeLibrary scoped_native_library(::LoadLibraryEx( |
| 64 FILE_PATH_LITERAL("shell32.dll"), nullptr, LOAD_LIBRARY_AS_DATAFILE)); | 64 FILE_PATH_LITERAL("shell32.dll"), nullptr, |
| 65 LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE)); |
| 65 if (!scoped_native_library.is_valid()) | 66 if (!scoped_native_library.is_valid()) |
| 66 return base::string16(); | 67 return base::string16(); |
| 67 | 68 |
| 68 const wchar_t* resource_ptr = nullptr; | 69 const wchar_t* resource_ptr = nullptr; |
| 69 int length = ::LoadStringW(scoped_native_library.get(), resource_id, | 70 int length = ::LoadStringW(scoped_native_library.get(), resource_id, |
| 70 reinterpret_cast<wchar_t*>(&resource_ptr), 0); | 71 reinterpret_cast<wchar_t*>(&resource_ptr), 0); |
| 71 if (!length || !resource_ptr) | 72 if (!length || !resource_ptr) |
| 72 return base::string16(); | 73 return base::string16(); |
| 73 return base::string16(resource_ptr, length); | 74 return base::string16(resource_ptr, length); |
| 74 } | 75 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 mojo::MakeStrongBinding(base::MakeUnique<ShellHandlerImpl>(), | 217 mojo::MakeStrongBinding(base::MakeUnique<ShellHandlerImpl>(), |
| 217 std::move(request)); | 218 std::move(request)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void ShellHandlerImpl::IsPinnedToTaskbar( | 221 void ShellHandlerImpl::IsPinnedToTaskbar( |
| 221 const IsPinnedToTaskbarCallback& callback) { | 222 const IsPinnedToTaskbarCallback& callback) { |
| 222 IsPinnedToTaskbarHelper helper; | 223 IsPinnedToTaskbarHelper helper; |
| 223 bool is_pinned_to_taskbar = helper.GetResult(); | 224 bool is_pinned_to_taskbar = helper.GetResult(); |
| 224 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); | 225 callback.Run(!helper.error_occured(), is_pinned_to_taskbar); |
| 225 } | 226 } |
| OLD | NEW |