Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2808)

Unified Diff: chrome/common/win_util.cc

Issue 52034: Implement basic ShowItemInFolder for linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/win_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/win_util.cc
===================================================================
--- chrome/common/win_util.cc (revision 12379)
+++ chrome/common/win_util.cc (working copy)
@@ -159,72 +159,6 @@
return !!f;
}
-void ShowItemInFolder(const std::wstring& full_path) {
- std::wstring dir = file_util::GetDirectoryFromPath(full_path);
- if (dir == L"" || !file_util::PathExists(full_path))
- return;
-
- // ParseDisplayName will fail if the directory is "C:", it must be "C:\\".
- FilePath dir_path(dir);
- file_util::EnsureEndsWithSeparator(&dir_path);
- dir = dir_path.value();
-
- typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)(
- PCIDLIST_ABSOLUTE pidl_Folder,
- UINT cidl,
- PCUITEMID_CHILD_ARRAY pidls,
- DWORD flags);
-
- static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr =
- NULL;
- static bool initialize_open_folder_proc = true;
- if (initialize_open_folder_proc) {
- initialize_open_folder_proc = false;
- // The SHOpenFolderAndSelectItems API is exposed by shell32 version 6
- // and does not exist in Win2K. We attempt to retrieve this function export
- // from shell32 and if it does not exist, we just invoke ShellExecute to
- // open the folder thus losing the functionality to select the item in
- // the process.
- HMODULE shell32_base = GetModuleHandle(L"shell32.dll");
- if (!shell32_base) {
- NOTREACHED();
- return;
- }
- open_folder_and_select_itemsPtr =
- reinterpret_cast<SHOpenFolderAndSelectItemsFuncPtr>
- (GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems"));
- }
- if (!open_folder_and_select_itemsPtr) {
- ShellExecute(NULL, _T("open"), dir.c_str(), NULL, NULL, SW_SHOW);
- return;
- }
-
- CComPtr<IShellFolder> desktop;
- HRESULT hr = SHGetDesktopFolder(&desktop);
- if (FAILED(hr))
- return;
-
- CoMemReleaser<ITEMIDLIST> dir_item;
- hr = desktop->ParseDisplayName(NULL, NULL,
- const_cast<wchar_t *>(dir.c_str()),
- NULL, &dir_item, NULL);
- if (FAILED(hr))
- return;
-
- CoMemReleaser<ITEMIDLIST> file_item;
- hr = desktop->ParseDisplayName(NULL, NULL,
- const_cast<wchar_t *>(full_path.c_str()),
- NULL, &file_item, NULL);
- if (FAILED(hr))
- return;
-
- const ITEMIDLIST* highlight[] = {
- {file_item},
- };
- (*open_folder_and_select_itemsPtr)(dir_item, arraysize(highlight),
- highlight, NULL);
-}
-
// 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, bool ask_for_app) {
« no previous file with comments | « chrome/common/win_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698