Index: chrome/browser/ui/webui/downloads_dom_handler.cc |
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc |
index f5e7929ce49d63f00a34573c4dad7fb57e61c438..c2c48a0ca8b549fd98f1f8eb3ee56037e5dfaac5 100644 |
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc |
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc |
@@ -18,11 +18,14 @@ |
#include "chrome/browser/download/download_history.h" |
#include "chrome/browser/download/download_item.h" |
#include "chrome/browser/download/download_util.h" |
+#include "chrome/browser/download/download_prefs.h" |
asanka
2011/07/19 18:58:00
download_prefs.h should go before download_util.h
|
+#include "chrome/browser/platform_util.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
#include "chrome/browser/ui/webui/fileicon_source.h" |
#include "chrome/browser/ui/webui/fileicon_source_cros.h" |
#include "chrome/common/jstemplate_builder.h" |
+#include "chrome/common/pref_names.h" |
asanka
2011/07/19 18:58:00
Do you need this anymore?
|
#include "chrome/common/url_constants.h" |
#include "content/browser/browser_thread.h" |
#include "content/browser/tab_contents/tab_contents.h" |
@@ -97,6 +100,8 @@ void DownloadsDOMHandler::RegisterMessages() { |
NewCallback(this, &DownloadsDOMHandler::HandleCancel)); |
web_ui_->RegisterMessageCallback("clearAll", |
NewCallback(this, &DownloadsDOMHandler::HandleClearAll)); |
+ web_ui_->RegisterMessageCallback("openDownloadsFolder", |
+ NewCallback(this, &DownloadsDOMHandler::HandleOpenDownloadsFolder)); |
} |
void DownloadsDOMHandler::OnDownloadUpdated(DownloadItem* download) { |
@@ -227,6 +232,19 @@ void DownloadsDOMHandler::HandleClearAll(const ListValue* args) { |
download_manager_->RemoveAllDownloads(); |
} |
+void DownloadsDOMHandler::HandleOpenDownloadsFolder(const ListValue* args) { |
+ FilePath path = download_manager_->download_prefs()->download_path(); |
+ |
+#if defined(OS_MACOSX) |
+ // Must be called from the UI thread on Mac. |
+ platform_util::OpenItem(path); |
+#else |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableFunction(&platform_util::OpenItem, path)); |
+#endif |
+} |
+ |
// DownloadsDOMHandler, private: ---------------------------------------------- |
void DownloadsDOMHandler::SendCurrentDownloads() { |