diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 01:38:59 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 01:38:59 +0000 |
commit | 541434c24710c131b697cf461fc3a21ddb74ed39 (patch) | |
tree | c9c445ea4d5e2c95a7f5dd3fc3cd04078f9b3545 /ui | |
parent | 60d2744cf0fbc02b5255407a6d03abb21a264dc5 (diff) | |
download | chromium_src-541434c24710c131b697cf461fc3a21ddb74ed39.zip chromium_src-541434c24710c131b697cf461fc3a21ddb74ed39.tar.gz chromium_src-541434c24710c131b697cf461fc3a21ddb74ed39.tar.bz2 |
Revert 90464 - Move app/win/* files to base/win/, ui/base/win and chrome/common/ directories.
BUG=72317
TEST=None
R=rsesek@chromium.org,brettw@chromium.org
Review URL: http://codereview.chromium.org/7231016
TBR=tfarina@chromium.org
Review URL: http://codereview.chromium.org/7265009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/win/shell.cc | 112 | ||||
-rw-r--r-- | ui/base/win/shell.h | 42 | ||||
-rw-r--r-- | ui/ui_base.gypi | 2 |
3 files changed, 0 insertions, 156 deletions
diff --git a/ui/base/win/shell.cc b/ui/base/win/shell.cc deleted file mode 100644 index c78730c..0000000 --- a/ui/base/win/shell.cc +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ui/base/win/shell.h" - -#include <shellapi.h> -#include <shlobj.h> - -#include "base/file_path.h" -#include "base/native_library.h" -#include "base/string_util.h" -#include "base/win/scoped_comptr.h" -#include "base/win/win_util.h" -#include "base/win/windows_version.h" - -namespace ui { -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); - -} // namespace - -// Open an item via a shell execute command. Error code checking and casting -// explanation: http://msdn2.microsoft.com/en-us/library/ms647732.aspx -bool OpenItemViaShell(const FilePath& full_path) { - HINSTANCE h = ::ShellExecuteW( - NULL, NULL, full_path.value().c_str(), NULL, - full_path.DirName().value().c_str(), SW_SHOWNORMAL); - - LONG_PTR error = reinterpret_cast<LONG_PTR>(h); - if (error > 32) - return true; - - if ((error == SE_ERR_NOASSOC)) - return OpenItemWithExternalApp(full_path.value()); - - return false; -} - -bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { - SHELLEXECUTEINFO sei = { sizeof(sei) }; - sei.fMask = SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT; - sei.nShow = SW_SHOWNORMAL; - sei.lpVerb = NULL; - sei.lpFile = full_path.value().c_str(); - if (::ShellExecuteExW(&sei)) - return true; - LONG_PTR error = reinterpret_cast<LONG_PTR>(sei.hInstApp); - if ((error == SE_ERR_NOASSOC)) - return OpenItemWithExternalApp(full_path.value()); - return false; -} - -// Show the Windows "Open With" dialog box to ask the user to pick an app to -// open the file with. -bool OpenItemWithExternalApp(const string16& full_path) { - SHELLEXECUTEINFO sei = { sizeof(sei) }; - sei.fMask = SEE_MASK_FLAG_DDEWAIT; - sei.nShow = SW_SHOWNORMAL; - sei.lpVerb = L"openas"; - sei.lpFile = full_path.c_str(); - return (TRUE == ::ShellExecuteExW(&sei)); -} - -void SetAppIdForWindow(const string16& app_id, 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<IPropertyStore> pps; - SHGPSFW SHGetPropertyStoreForWindow = static_cast<SHGPSFW>(function); - HRESULT result = SHGetPropertyStoreForWindow( - hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); - if (S_OK == result) - base::win::SetAppIdForPropertyStore(pps, app_id.c_str()); - - // Cleanup. - base::UnloadNativeLibrary(shell32_library); -} - -} // namespace win -} // namespace ui diff --git a/ui/base/win/shell.h b/ui/base/win/shell.h deleted file mode 100644 index cc32477..0000000 --- a/ui/base/win/shell.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef UI_BASE_WIN_SHELL_H_ -#define UI_BASE_WIN_SHELL_H_ -#pragma once - -#include <windows.h> - -#include "base/string16.h" - -class FilePath; - -namespace ui { -namespace win { - -// Open or run a file via the Windows shell. In the event that there is no -// default application registered for the file specified by 'full_path', -// ask the user, via the Windows "Open With" dialog. -// Returns 'true' on successful open, 'false' otherwise. -bool OpenItemViaShell(const FilePath& full_path); - -// The download manager now writes the alternate data stream with the -// zone on all downloads. This function is equivalent to OpenItemViaShell -// without showing the zone warning dialog. -bool OpenItemViaShellNoZoneCheck(const FilePath& full_path); - -// Ask the user, via the Windows "Open With" dialog, for an application to use -// to open the file specified by 'full_path'. -// Returns 'true' on successful open, 'false' otherwise. -bool OpenItemWithExternalApp(const string16& full_path); - -// Sets the application id given as the Application Model ID for the window -// specified. This method is used to insure that different web applications -// do not group together on the Win7 task bar. -void SetAppIdForWindow(const string16& app_id, HWND hwnd); - -} // namespace win -} // namespace ui - -#endif // UI_BASE_WIN_SHELL_H_ diff --git a/ui/ui_base.gypi b/ui/ui_base.gypi index 3468eaa..b602b16 100644 --- a/ui/ui_base.gypi +++ b/ui/ui_base.gypi @@ -152,8 +152,6 @@ 'base/win/hwnd_util.h', 'base/win/ime_input.cc', 'base/win/ime_input.h', - 'base/win/shell.cc', - 'base/win/shell.h', 'base/win/window_impl.cc', 'base/win/window_impl.h', 'base/x/active_window_watcher_x.cc', |