| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "app/win/shell.h" | 5 #include "app/win/shell.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { | 74 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { |
| 75 // This functionality is only available on Win7+. | 75 // This functionality is only available on Win7+. |
| 76 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 76 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 // Load Shell32.dll into memory. | 79 // Load Shell32.dll into memory. |
| 80 // TODO(brg): Remove this mechanism when the Win7 SDK is available in trunk. | 80 // TODO(brg): Remove this mechanism when the Win7 SDK is available in trunk. |
| 81 std::wstring shell32_filename(kShell32); | 81 std::wstring shell32_filename(kShell32); |
| 82 FilePath shell32_filepath(shell32_filename); | 82 FilePath shell32_filepath(shell32_filename); |
| 83 base::NativeLibrary shell32_library = base::LoadNativeLibrary( | 83 base::NativeLibrary shell32_library = base::LoadNativeLibrary( |
| 84 shell32_filepath); | 84 shell32_filepath, NULL); |
| 85 | 85 |
| 86 if (!shell32_library) | 86 if (!shell32_library) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 // Get the function pointer for SHGetPropertyStoreForWindow. | 89 // Get the function pointer for SHGetPropertyStoreForWindow. |
| 90 void* function = base::GetFunctionPointerFromNativeLibrary( | 90 void* function = base::GetFunctionPointerFromNativeLibrary( |
| 91 shell32_library, | 91 shell32_library, |
| 92 kSHGetPropertyStoreForWindow); | 92 kSHGetPropertyStoreForWindow); |
| 93 | 93 |
| 94 if (!function) { | 94 if (!function) { |
| 95 base::UnloadNativeLibrary(shell32_library); | 95 base::UnloadNativeLibrary(shell32_library); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Set the application's name. | 99 // Set the application's name. |
| 100 base::win::ScopedComPtr<IPropertyStore> pps; | 100 base::win::ScopedComPtr<IPropertyStore> pps; |
| 101 SHGPSFW SHGetPropertyStoreForWindow = static_cast<SHGPSFW>(function); | 101 SHGPSFW SHGetPropertyStoreForWindow = static_cast<SHGPSFW>(function); |
| 102 HRESULT result = SHGetPropertyStoreForWindow( | 102 HRESULT result = SHGetPropertyStoreForWindow( |
| 103 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); | 103 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); |
| 104 if (S_OK == result) | 104 if (S_OK == result) |
| 105 base::win::SetAppIdForPropertyStore(pps, app_id.c_str()); | 105 base::win::SetAppIdForPropertyStore(pps, app_id.c_str()); |
| 106 | 106 |
| 107 // Cleanup. | 107 // Cleanup. |
| 108 base::UnloadNativeLibrary(shell32_library); | 108 base::UnloadNativeLibrary(shell32_library); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace win | 111 } // namespace win |
| 112 } // namespace app | 112 } // namespace app |
| OLD | NEW |