As the-golem said, it all starts with this:
// We don't need "show in folder" in chromium os. See download_ui.cc and
// http://code.google.com/p/chromium-os/issues/detail?id=916.
var showinfolder = localStrings.getString('control_showinfolder');
if (showinfolder) {
this.controlShow_ = createLink(this.show_.bind(this), showinfolder);
this.nodeControls_.appendChild(this.controlShow_);
} else {
this.controlShow_ = null;
}
Further down in downloads.html you have this:
/**
* Tells the backend to show the file in explorer.
*/
Download.prototype.show_ = function() {
chrome.send("show", [this.id_.toString()]);
return false;
}
From now on I'll just let the code speak mostly for itself:
chrome/browser/ui/webui/downloads_dom_handler.cc
web_ui_->RegisterMessageCallback("show",
base::Bind(&DownloadsDOMHandler::HandleShow,
base::Unretained(this)));
// Further down
void DownloadsDOMHandler::HandleShow(const ListValue* args) {
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW);
DownloadItem* file = GetDownloadByValue(args);
if (file)
file->ShowDownloadInShell();
}
content/browser/download/download_item_impl.cc
void DownloadItemImpl::ShowDownloadInShell() {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::GetContentClient()->browser()->ShowItemInFolder(GetFullPath());
}
chrome/browser/chrome_content_browser_client.cc
void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
platform_util::ShowItemInFolder(path);
}
Looks like we're getting closer...
chrome/browser/platform_util_win.cc
void ShowItemInFolder(const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&ShowItemInFolderOnFileThread, full_path));
}
//Higher up in the same file
void ShowItemInFolderOnFileThread(const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath dir = full_path.DirName();
// ParseDisplayName will fail if the directory is "C:", it must be "C:\\".
if (dir.value() == L"" || !file_util::EnsureEndsWithSeparator(&dir))
return;
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() << " " << __FUNCTION__ << "(): Can't open shell32.dll";
return;
}
open_folder_and_select_itemsPtr =
reinterpret_cast<SHOpenFolderAndSelectItemsFuncPtr>
(GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems"));
}
if (!open_folder_and_select_itemsPtr) {
ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
return;
}
base::win::ScopedComPtr<IShellFolder> desktop;
HRESULT hr = SHGetDesktopFolder(desktop.Receive());
if (FAILED(hr))
return;
base::win::ScopedCoMem<ITEMIDLIST> dir_item;
hr = desktop->ParseDisplayName(NULL, NULL,
const_cast<wchar_t *>(dir.value().c_str()),
NULL, &dir_item, NULL);
if (FAILED(hr))
return;
base::win::ScopedCoMem<ITEMIDLIST> file_item;
hr = desktop->ParseDisplayName(NULL, NULL,
const_cast<wchar_t *>(full_path.value().c_str()),
NULL, &file_item, NULL);
if (FAILED(hr))
return;
const ITEMIDLIST* highlight[] = {
{file_item},
};
hr = (*open_folder_and_select_itemsPtr)(dir_item, arraysize(highlight),
highlight, NULL);
if (FAILED(hr)) {
// On some systems, the above call mysteriously fails with "file not
// found" even though the file is there. In these cases, ShellExecute()
// seems to work as a fallback (although it won't select the file).
if (hr == ERROR_FILE_NOT_FOUND) {
ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
} else {
LPTSTR message = NULL;
DWORD message_length = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, hr, 0, reinterpret_cast<LPTSTR>(&message), 0, NULL);
LOG(WARNING) << " " << __FUNCTION__
<< "(): Can't open full_path = \""
<< full_path.value() << "\""
<< " hr = " << hr
<< " " << reinterpret_cast<LPTSTR>(&message);
if (message)
LocalFree(message);
}
}
}
So solving this bug: http://www.lsdev.org/bugs/view.php?id=60 will probably solve this problem as well