From c06ecf7ce927d1c4646a5c3c318dd454f223affb Mon Sep 17 00:00:00 2001 From: "cpu@chromium.org" Date: Wed, 4 Jan 2012 22:59:05 +0000 Subject: Cleanup shell.cc - We now delayload shell32 so manual function bind is just cruft - We now include the win7 sdk BUG=none TEST=chrome runs on xp Review URL: http://codereview.chromium.org/9088021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116396 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/base/win/shell.cc | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/ui/base/win/shell.cc b/ui/base/win/shell.cc index 29efce8..3081d77 100644 --- a/ui/base/win/shell.cc +++ b/ui/base/win/shell.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,44 +20,13 @@ namespace win { namespace { -const wchar_t kShell32[] = L"shell32.dll"; -const char kSHGetPropertyStoreForWindow[] = "SHGetPropertyStoreForWindow"; - -// Define the type of SHGetPropertyStoreForWindow is SHGPSFW. -typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *SHGPSFW)(HWND hwnd, - REFIID riid, - void** ppv); - void SetAppIdAndIconForWindow(const string16& app_id, const string16& app_icon, HWND hwnd) { // This functionality is only available on Win7+. if (base::win::GetVersion() < base::win::VERSION_WIN7) return; - - // Load Shell32.dll into memory. - // TODO(brg): Remove this mechanism when the Win7 SDK is available in trunk. - std::wstring shell32_filename(kShell32); - FilePath shell32_filepath(shell32_filename); - base::NativeLibrary shell32_library = base::LoadNativeLibrary( - shell32_filepath, NULL); - - if (!shell32_library) - return; - - // Get the function pointer for SHGetPropertyStoreForWindow. - void* function = base::GetFunctionPointerFromNativeLibrary( - shell32_library, - kSHGetPropertyStoreForWindow); - - if (!function) { - base::UnloadNativeLibrary(shell32_library); - return; - } - - // Set the application's name. base::win::ScopedComPtr pps; - SHGPSFW SHGetPropertyStoreForWindow = static_cast(function); HRESULT result = SHGetPropertyStoreForWindow( hwnd, __uuidof(*pps), reinterpret_cast(pps.Receive())); if (S_OK == result) { @@ -68,9 +37,6 @@ void SetAppIdAndIconForWindow(const string16& app_id, pps, PKEY_AppUserModel_RelaunchIconResource, app_icon.c_str()); } } - - // Cleanup. - base::UnloadNativeLibrary(shell32_library); } } // namespace @@ -88,7 +54,6 @@ bool OpenItemViaShell(const FilePath& full_path) { if ((error == SE_ERR_NOASSOC)) return OpenItemWithExternalApp(full_path.value()); - return false; } @@ -101,7 +66,7 @@ bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { if (::ShellExecuteExW(&sei)) return true; LONG_PTR error = reinterpret_cast(sei.hInstApp); - if ((error == SE_ERR_NOASSOC)) + if (error == SE_ERR_NOASSOC) return OpenItemWithExternalApp(full_path.value()); return false; } -- cgit v1.1