diff options
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 22 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 3 | ||||
-rw-r--r-- | chrome/renderer/renderer_webkitclient_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webfileutilities_impl.cc | 4 | ||||
-rw-r--r-- | webkit/glue/webfileutilities_impl.h | 1 |
6 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index f53b1b7..d6334fd 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -37,6 +37,7 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notifications_prefs_cache.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/printing/printer_query.h" #include "chrome/browser/printing/print_job_manager.h" @@ -455,6 +456,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { OnCheckNotificationPermission) IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromExtension, OnGetMimeTypeFromExtension) + IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromFile, OnGetMimeTypeFromFile) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPreferredExtensionForMimeType, @@ -524,6 +526,26 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { return handled; } +void ResourceMessageFilter::OnRevealFolderInOS(const FilePath& path) { +#if defined(OS_MACOSX) + const BrowserThread::ID kThreadID = BrowserThread::UI; +#else + const BrowserThread::ID kThreadID = BrowserThread::FILE; +#endif + if (!BrowserThread::CurrentlyOn(kThreadID)) { + // Only honor the request if appropriate persmissions are granted. + if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) + BrowserThread::PostTask( + kThreadID, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::OnRevealFolderInOS, path)); + return; + } + + DCHECK(BrowserThread::CurrentlyOn(kThreadID)); + platform_util::OpenItem(path); +} + void ResourceMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 15c97de..bd20764 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -252,6 +252,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnGetWindowRect(gfx::NativeViewId window, IPC::Message* reply); void OnGetRootWindowRect(gfx::NativeViewId window, IPC::Message* reply); #endif + + void OnRevealFolderInOS(const FilePath& path); void OnGetMimeTypeFromExtension(const FilePath::StringType& ext, std::string* mime_type); void OnGetMimeTypeFromFile(const FilePath& file_path, diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a746a96..353bfc9 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1942,6 +1942,9 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_ROUTED1(ViewHostMsg_DataReceived_ACK, int /* request_id */) + IPC_MESSAGE_CONTROL1(ViewHostMsg_RevealFolderInOS, + FilePath /* path */) + // Sent when the renderer has processed a DataDownloaded message. IPC_MESSAGE_ROUTED1(ViewHostMsg_DataDownloaded_ACK, int /* request_id */) diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc index c681bc2..2fb5efc 100644 --- a/chrome/renderer/renderer_webkitclient_impl.cc +++ b/chrome/renderer/renderer_webkitclient_impl.cc @@ -93,6 +93,7 @@ class RendererWebKitClientImpl::MimeRegistry class RendererWebKitClientImpl::FileUtilities : public webkit_glue::WebFileUtilitiesImpl { public: + virtual void revealFolderInOS(const WebKit::WebString& path); virtual bool getFileSize(const WebKit::WebString& path, long long& result); virtual bool getFileModificationTime(const WebKit::WebString& path, double& result); @@ -372,6 +373,13 @@ bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, return false; } +void RendererWebKitClientImpl::FileUtilities::revealFolderInOS( + const WebString& path) { + FilePath file_path(webkit_glue::WebStringToFilePath(path)); + file_util::AbsolutePath(&file_path); + RenderThread::current()->Send(new ViewHostMsg_RevealFolderInOS(file_path)); +} + bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime( const WebString& path, double& result) { diff --git a/webkit/glue/webfileutilities_impl.cc b/webkit/glue/webfileutilities_impl.cc index a77184d..6cea225 100644 --- a/webkit/glue/webfileutilities_impl.cc +++ b/webkit/glue/webfileutilities_impl.cc @@ -24,6 +24,10 @@ WebFileUtilitiesImpl::WebFileUtilitiesImpl() WebFileUtilitiesImpl::~WebFileUtilitiesImpl() { } +void WebFileUtilitiesImpl::revealFolderInOS(const WebString& path) { + NOTREACHED(); +} + bool WebFileUtilitiesImpl::fileExists(const WebString& path) { FilePath::StringType file_path = WebStringToFilePathString(path); return file_util::PathExists(FilePath(file_path)); diff --git a/webkit/glue/webfileutilities_impl.h b/webkit/glue/webfileutilities_impl.h index 5867396..c1ef986 100644 --- a/webkit/glue/webfileutilities_impl.h +++ b/webkit/glue/webfileutilities_impl.h @@ -16,6 +16,7 @@ class WebFileUtilitiesImpl : public WebKit::WebFileUtilities { virtual ~WebFileUtilitiesImpl(); // WebFileUtilities methods: + virtual void revealFolderInOS(const WebKit::WebString& path); virtual bool fileExists(const WebKit::WebString& path); virtual bool deleteFile(const WebKit::WebString& path); virtual bool deleteEmptyDirectory(const WebKit::WebString& path); |