diff options
27 files changed, 387 insertions, 429 deletions
diff --git a/chrome/common/all_messages.h b/chrome/common/all_messages.h index 5b396b6..1d51146 100644 --- a/chrome/common/all_messages.h +++ b/chrome/common/all_messages.h @@ -17,4 +17,5 @@ #include "chrome/common/common_message_generator.h" #include "chrome/common/nacl_messages.h" #include "content/common/content_message_generator.h" +#include "ppapi/proxy/pepper_file_messages.h" #include "ppapi/proxy/ppapi_messages.h" diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index 71cadc4..de2770a 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -74,8 +74,8 @@ PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( const content::PepperPluginInfo& info, const FilePath& profile_data_directory, net::HostResolver* host_resolver) { - PpapiPluginProcessHost* plugin_host = - new PpapiPluginProcessHost(profile_data_directory, host_resolver); + PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost( + info.name, profile_data_directory, host_resolver); if (plugin_host->Init(info)) return plugin_host; @@ -112,16 +112,23 @@ void PpapiPluginProcessHost::OpenChannelToPlugin(Client* client) { } PpapiPluginProcessHost::PpapiPluginProcessHost( + const std::string& plugin_name, const FilePath& profile_data_directory, net::HostResolver* host_resolver) - : filter_(new PepperMessageFilter(PepperMessageFilter::PLUGIN, - host_resolver)), - network_observer_(new PluginNetworkObserver(this)), + : network_observer_(new PluginNetworkObserver(this)), profile_data_directory_(profile_data_directory), is_broker_(false) { process_.reset(new BrowserChildProcessHostImpl( content::PROCESS_TYPE_PPAPI_PLUGIN, this)); + + filter_ = new PepperMessageFilter( + PepperMessageFilter::PLUGIN, host_resolver); + + file_filter_ = new PepperTrustedFileMessageFilter( + process_->GetData().id, plugin_name, profile_data_directory); + process_->GetHost()->AddFilter(filter_.get()); + process_->GetHost()->AddFilter(file_filter_.get()); } PpapiPluginProcessHost::PpapiPluginProcessHost() diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h index 71314b1..f5954f5 100644 --- a/content/browser/ppapi_plugin_process_host.h +++ b/content/browser/ppapi_plugin_process_host.h @@ -6,12 +6,14 @@ #define CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ #pragma once +#include <string> #include <queue> #include "base/basictypes.h" #include "base/file_path.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "content/browser/renderer_host/pepper_file_message_filter.h" #include "content/browser/renderer_host/pepper_message_filter.h" #include "content/public/browser/browser_child_process_host_delegate.h" #include "content/public/browser/browser_child_process_host_iterator.h" @@ -79,7 +81,8 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate, const FilePath& plugin_path() const { return plugin_path_; } const FilePath& profile_data_directory() const { - return profile_data_directory_; } + return profile_data_directory_; + } // The client pointer must remain valid until its callback is issued. @@ -88,7 +91,8 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate, // Constructors for plugin and broker process hosts, respectively. // You must call Init before doing anything else. - PpapiPluginProcessHost(const FilePath& profile_data_directory, + PpapiPluginProcessHost(const std::string& plugin_name, + const FilePath& profile_data_directory, net::HostResolver* host_resolver); PpapiPluginProcessHost(); @@ -112,6 +116,9 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate, // Handles most requests from the plugin. May be NULL. scoped_refptr<PepperMessageFilter> filter_; + // Handles filesystem requests from flash plugins. May be NULL. + scoped_refptr<PepperFileMessageFilter> file_filter_; + // Observes network changes. May be NULL. scoped_ptr<PluginNetworkObserver> network_observer_; diff --git a/content/browser/renderer_host/pepper_file_message_filter.cc b/content/browser/renderer_host/pepper_file_message_filter.cc index e8b3a92..a86542e 100644 --- a/content/browser/renderer_host/pepper_file_message_filter.cc +++ b/content/browser/renderer_host/pepper_file_message_filter.cc @@ -11,12 +11,11 @@ #include "base/process_util.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h" -#include "content/common/pepper_file_messages.h" -#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_constants.h" #include "ipc/ipc_platform_file.h" -#include "webkit/plugins/ppapi/file_path.h" +#include "ppapi/proxy/pepper_file_messages.h" +#include "ppapi/shared_impl/file_path.h" #if defined(OS_POSIX) #include "base/file_descriptor_posix.h" @@ -38,11 +37,9 @@ const int kWritePermissions = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_EXCLUSIVE_WRITE | base::PLATFORM_FILE_WRITE_ATTRIBUTES; -PepperFileMessageFilter::PepperFileMessageFilter( - int child_id, content::BrowserContext* browser_context) +PepperFileMessageFilter::PepperFileMessageFilter(int child_id) : child_id_(child_id), channel_(NULL) { - pepper_path_ = GetDataDirName(browser_context->GetPath()); } void PepperFileMessageFilter::OverrideThreadForMessage( @@ -83,7 +80,7 @@ PepperFileMessageFilter::~PepperFileMessageFilter() { // Called on the FILE thread: void PepperFileMessageFilter::OnOpenFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, int flags, base::PlatformFileError* error, IPC::PlatformFileForTransit* file) { @@ -128,8 +125,8 @@ void PepperFileMessageFilter::OnOpenFile( } void PepperFileMessageFilter::OnRenameFile( - const webkit::ppapi::PepperFilePath& from_path, - const webkit::ppapi::PepperFilePath& to_path, + const ppapi::PepperFilePath& from_path, + const ppapi::PepperFilePath& to_path, base::PlatformFileError* error) { FilePath from_full_path = ValidateAndConvertPepperFilePath(from_path, kWritePermissions); @@ -146,7 +143,7 @@ void PepperFileMessageFilter::OnRenameFile( } void PepperFileMessageFilter::OnDeleteFileOrDir( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, bool recursive, base::PlatformFileError* error) { FilePath full_path = ValidateAndConvertPepperFilePath(path, @@ -162,7 +159,7 @@ void PepperFileMessageFilter::OnDeleteFileOrDir( } void PepperFileMessageFilter::OnCreateDir( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, base::PlatformFileError* error) { FilePath full_path = ValidateAndConvertPepperFilePath(path, kWritePermissions); @@ -177,7 +174,7 @@ void PepperFileMessageFilter::OnCreateDir( } void PepperFileMessageFilter::OnQueryFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, base::PlatformFileInfo* info, base::PlatformFileError* error) { FilePath full_path = ValidateAndConvertPepperFilePath(path, kReadPermissions); @@ -192,8 +189,8 @@ void PepperFileMessageFilter::OnQueryFile( } void PepperFileMessageFilter::OnGetDirContents( - const webkit::ppapi::PepperFilePath& path, - webkit::ppapi::DirContents* contents, + const ppapi::PepperFilePath& path, + ppapi::DirContents* contents, base::PlatformFileError* error) { FilePath full_path = ValidateAndConvertPepperFilePath(path, kReadPermissions); if (full_path.empty()) { @@ -213,7 +210,7 @@ void PepperFileMessageFilter::OnGetDirContents( while (!enumerator.Next().empty()) { file_util::FileEnumerator::FindInfo info; enumerator.GetFindInfo(&info); - webkit::ppapi::DirEntry entry = { + ppapi::DirEntry entry = { file_util::FileEnumerator::GetFilename(info), file_util::FileEnumerator::IsDirectory(info) }; @@ -224,19 +221,44 @@ void PepperFileMessageFilter::OnGetDirContents( } FilePath PepperFileMessageFilter::ValidateAndConvertPepperFilePath( - const webkit::ppapi::PepperFilePath& pepper_path, int flags) { + const ppapi::PepperFilePath& pepper_path, int flags) { + FilePath file_path; // Empty path returned on error. + if (pepper_path.domain() == ppapi::PepperFilePath::DOMAIN_ABSOLUTE) { + if (pepper_path.path().IsAbsolute() && + ChildProcessSecurityPolicyImpl::GetInstance()->HasPermissionsForFile( + child_id(), pepper_path.path(), flags)) + file_path = pepper_path.path(); + } + return file_path; +} + +PepperTrustedFileMessageFilter::PepperTrustedFileMessageFilter( + int child_id, + const std::string& plugin_name, + const FilePath& profile_data_directory) + : PepperFileMessageFilter(child_id) { + plugin_data_directory_ = GetDataDirName(profile_data_directory).Append( + FilePath::FromUTF8Unsafe(plugin_name)); +} + +PepperTrustedFileMessageFilter::~PepperTrustedFileMessageFilter() { +} + +FilePath PepperTrustedFileMessageFilter::ValidateAndConvertPepperFilePath( + const ppapi::PepperFilePath& pepper_path, + int flags) { FilePath file_path; // Empty path returned on error. switch(pepper_path.domain()) { - case webkit::ppapi::PepperFilePath::DOMAIN_ABSOLUTE: + case ppapi::PepperFilePath::DOMAIN_ABSOLUTE: if (pepper_path.path().IsAbsolute() && ChildProcessSecurityPolicyImpl::GetInstance()->HasPermissionsForFile( child_id(), pepper_path.path(), flags)) file_path = pepper_path.path(); break; - case webkit::ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL: + case ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL: if (!pepper_path.path().IsAbsolute() && !pepper_path.path().ReferencesParent()) - file_path = pepper_path_.Append(pepper_path.path()); + file_path = plugin_data_directory_.Append(pepper_path.path()); break; default: NOTREACHED(); diff --git a/content/browser/renderer_host/pepper_file_message_filter.h b/content/browser/renderer_host/pepper_file_message_filter.h index 09f01f6..167f1f3 100644 --- a/content/browser/renderer_host/pepper_file_message_filter.h +++ b/content/browser/renderer_host/pepper_file_message_filter.h @@ -16,23 +16,20 @@ #include "build/build_config.h" #include "content/public/browser/browser_message_filter.h" #include "ipc/ipc_platform_file.h" -#include "webkit/plugins/ppapi/dir_contents.h" +#include "ppapi/shared_impl/dir_contents.h" namespace content { class BrowserContext; } -namespace webkit { namespace ppapi { class PepperFilePath; } -} // A message filter for Pepper-specific File I/O messages. class PepperFileMessageFilter : public content::BrowserMessageFilter { public: - PepperFileMessageFilter(int child_id, - content::BrowserContext* browser_context); + explicit PepperFileMessageFilter(int child_id); // content::BrowserMessageFilter methods: virtual void OverrideThreadForMessage( @@ -57,29 +54,29 @@ class PepperFileMessageFilter : public content::BrowserMessageFilter { friend class base::DeleteHelper<PepperFileMessageFilter>; // Called on the FILE thread: - void OnOpenFile(const webkit::ppapi::PepperFilePath& path, + void OnOpenFile(const ppapi::PepperFilePath& path, int flags, base::PlatformFileError* error, IPC::PlatformFileForTransit* file); - void OnRenameFile(const webkit::ppapi::PepperFilePath& from_path, - const webkit::ppapi::PepperFilePath& to_path, + void OnRenameFile(const ppapi::PepperFilePath& from_path, + const ppapi::PepperFilePath& to_path, base::PlatformFileError* error); - void OnDeleteFileOrDir(const webkit::ppapi::PepperFilePath& path, + void OnDeleteFileOrDir(const ppapi::PepperFilePath& path, bool recursive, base::PlatformFileError* error); - void OnCreateDir(const webkit::ppapi::PepperFilePath& path, + void OnCreateDir(const ppapi::PepperFilePath& path, base::PlatformFileError* error); - void OnQueryFile(const webkit::ppapi::PepperFilePath& path, + void OnQueryFile(const ppapi::PepperFilePath& path, base::PlatformFileInfo* info, base::PlatformFileError* error); - void OnGetDirContents(const webkit::ppapi::PepperFilePath& path, - webkit::ppapi::DirContents* contents, + void OnGetDirContents(const ppapi::PepperFilePath& path, + ppapi::DirContents* contents, base::PlatformFileError* error); // Validate and convert the Pepper file path to a "real" |FilePath|. Returns // an empty |FilePath| on error. - FilePath ValidateAndConvertPepperFilePath( - const webkit::ppapi::PepperFilePath& pepper_path, int flags); + virtual FilePath ValidateAndConvertPepperFilePath( + const ppapi::PepperFilePath& pepper_path, int flags); // The ID of the child process. const int child_id_; @@ -88,10 +85,27 @@ class PepperFileMessageFilter : public content::BrowserMessageFilter { // owned by this class. IPC::Channel* channel_; - // The base path for the pepper data. - FilePath pepper_path_; - DISALLOW_COPY_AND_ASSIGN(PepperFileMessageFilter); }; +// Class for out-of-process plugins providing relaxed path validation. +class PepperTrustedFileMessageFilter : public PepperFileMessageFilter { + public: + PepperTrustedFileMessageFilter(int child_id, + const std::string& plugin_name, + const FilePath& profile_data_directory); + + protected: + virtual ~PepperTrustedFileMessageFilter(); + + private: + virtual FilePath ValidateAndConvertPepperFilePath( + const ppapi::PepperFilePath& pepper_path, int flags) OVERRIDE; + + // The path to the per-plugin directory under the per-profile data directory. + FilePath plugin_data_directory_; + + DISALLOW_COPY_AND_ASSIGN(PepperTrustedFileMessageFilter); +}; + #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_FILE_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 5493eca..9f490bb 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -482,7 +482,7 @@ void RenderProcessHostImpl::CreateMessageFilters() { channel_->AddFilter(new media_stream::MediaStreamDispatcherHost( resource_context, GetID(), BrowserMainLoop::GetAudioManager())); #endif - channel_->AddFilter(new PepperFileMessageFilter(GetID(), browser_context)); + channel_->AddFilter(new PepperFileMessageFilter(GetID())); channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER, GetID(), browser_context)); #if defined(ENABLE_INPUT_SPEECH) diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index 82e650e..2bb605c 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -30,7 +30,6 @@ #include "content/common/media/video_capture_messages.h" #include "content/common/mime_registry_messages.h" #include "content/common/p2p_messages.h" -#include "content/common/pepper_file_messages.h" #include "content/common/pepper_messages.h" #include "content/common/plugin_messages.h" #include "content/common/quota_messages.h" diff --git a/content/common/pepper_file_messages.cc b/content/common/pepper_file_messages.cc deleted file mode 100644 index 313c2b7..0000000 --- a/content/common/pepper_file_messages.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 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 "content/common/pepper_file_messages.h" - -namespace IPC { - -void ParamTraits<webkit::ppapi::PepperFilePath>::Write(Message* m, - const param_type& p) { - WriteParam(m, static_cast<unsigned>(p.domain())); - WriteParam(m, p.path()); -} - -bool ParamTraits<webkit::ppapi::PepperFilePath>::Read(const Message* m, - PickleIterator* iter, - param_type* p) { - unsigned domain; - FilePath path; - if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) - return false; - if (domain > webkit::ppapi::PepperFilePath::DOMAIN_MAX_VALID) - return false; - - *p = webkit::ppapi::PepperFilePath( - static_cast<webkit::ppapi::PepperFilePath::Domain>(domain), path); - return true; -} - -void ParamTraits<webkit::ppapi::PepperFilePath>::Log(const param_type& p, - std::string* l) { - l->append("("); - LogParam(static_cast<unsigned>(p.domain()), l); - l->append(", "); - LogParam(p.path(), l); - l->append(")"); -} - -} // namespace IPC diff --git a/content/content_common.gypi b/content/content_common.gypi index d170634..a838085 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -269,8 +269,6 @@ 'common/p2p_messages.h', 'common/p2p_sockets.h', 'common/page_zoom.cc', - 'common/pepper_file_messages.cc', - 'common/pepper_file_messages.h', 'common/pepper_messages.h', 'common/pepper_plugin_registry.cc', 'common/pepper_plugin_registry.h', diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc index c1ca266..0a30831 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc @@ -24,7 +24,6 @@ #include "content/common/fileapi/file_system_dispatcher.h" #include "content/common/fileapi/file_system_messages.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" -#include "content/common/pepper_file_messages.h" #include "content/common/pepper_plugin_registry.h" #include "content/common/pepper_messages.h" #include "content/common/quota_dispatcher.h" @@ -64,7 +63,9 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_flash.h" #include "ppapi/proxy/host_dispatcher.h" +#include "ppapi/proxy/pepper_file_messages.h" #include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/file_path.h" #include "ppapi/shared_impl/platform_file.h" #include "ppapi/shared_impl/ppapi_preferences.h" #include "ppapi/shared_impl/ppb_device_ref_shared.h" @@ -82,7 +83,6 @@ #include "ui/gfx/size.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/plugins/npapi/webplugin.h" -#include "webkit/plugins/ppapi/file_path.h" #include "webkit/plugins/ppapi/ppb_file_io_impl.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -913,7 +913,7 @@ bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( } base::PlatformFileError PepperPluginDelegateImpl::OpenFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, int flags, base::PlatformFile* file) { IPC::PlatformFileForTransit transit_file; @@ -929,8 +929,8 @@ base::PlatformFileError PepperPluginDelegateImpl::OpenFile( } base::PlatformFileError PepperPluginDelegateImpl::RenameFile( - const webkit::ppapi::PepperFilePath& from_path, - const webkit::ppapi::PepperFilePath& to_path) { + const ppapi::PepperFilePath& from_path, + const ppapi::PepperFilePath& to_path) { base::PlatformFileError error; IPC::Message* msg = new PepperFileMsg_RenameFile(from_path, to_path, &error); if (!render_view_->Send(msg)) @@ -939,7 +939,7 @@ base::PlatformFileError PepperPluginDelegateImpl::RenameFile( } base::PlatformFileError PepperPluginDelegateImpl::DeleteFileOrDir( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, bool recursive) { base::PlatformFileError error; IPC::Message* msg = new PepperFileMsg_DeleteFileOrDir( @@ -950,7 +950,7 @@ base::PlatformFileError PepperPluginDelegateImpl::DeleteFileOrDir( } base::PlatformFileError PepperPluginDelegateImpl::CreateDir( - const webkit::ppapi::PepperFilePath& path) { + const ppapi::PepperFilePath& path) { base::PlatformFileError error; IPC::Message* msg = new PepperFileMsg_CreateDir(path, &error); if (!render_view_->Send(msg)) @@ -959,7 +959,7 @@ base::PlatformFileError PepperPluginDelegateImpl::CreateDir( } base::PlatformFileError PepperPluginDelegateImpl::QueryFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, base::PlatformFileInfo* info) { base::PlatformFileError error; IPC::Message* msg = new PepperFileMsg_QueryFile(path, info, &error); @@ -969,8 +969,8 @@ base::PlatformFileError PepperPluginDelegateImpl::QueryFile( } base::PlatformFileError PepperPluginDelegateImpl::GetDirContents( - const webkit::ppapi::PepperFilePath& path, - webkit::ppapi::DirContents* contents) { + const ppapi::PepperFilePath& path, + ppapi::DirContents* contents) { base::PlatformFileError error; IPC::Message* msg = new PepperFileMsg_GetDirContents(path, contents, &error); if (!render_view_->Send(msg)) diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h index 21b2f1e..c013402 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h @@ -42,6 +42,7 @@ struct ChannelHandle; } namespace ppapi { +class PepperFilePath; class PPB_X509Certificate_Fields; } @@ -52,7 +53,6 @@ class Range; namespace webkit { struct WebPluginInfo; namespace ppapi { -class PepperFilePath; class PluginInstance; class PluginModule; } @@ -251,23 +251,23 @@ class PepperPluginDelegateImpl virtual void WillUpdateFile(const GURL& file_path) OVERRIDE; virtual void DidUpdateFile(const GURL& file_path, int64_t delta) OVERRIDE; virtual base::PlatformFileError OpenFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, int flags, base::PlatformFile* file) OVERRIDE; virtual base::PlatformFileError RenameFile( - const webkit::ppapi::PepperFilePath& from_path, - const webkit::ppapi::PepperFilePath& to_path) OVERRIDE; + const ppapi::PepperFilePath& from_path, + const ppapi::PepperFilePath& to_path) OVERRIDE; virtual base::PlatformFileError DeleteFileOrDir( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, bool recursive) OVERRIDE; virtual base::PlatformFileError CreateDir( - const webkit::ppapi::PepperFilePath& path) OVERRIDE; + const ppapi::PepperFilePath& path) OVERRIDE; virtual base::PlatformFileError QueryFile( - const webkit::ppapi::PepperFilePath& path, + const ppapi::PepperFilePath& path, base::PlatformFileInfo* info) OVERRIDE; virtual base::PlatformFileError GetDirContents( - const webkit::ppapi::PepperFilePath& path, - webkit::ppapi::DirContents* contents) OVERRIDE; + const ppapi::PepperFilePath& path, + ppapi::DirContents* contents) OVERRIDE; virtual void SyncGetFileSystemPlatformPath( const GURL& url, FilePath* platform_path) OVERRIDE; diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 538c333..fde6415 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -48,6 +48,8 @@ 'proxy/interface_list.h', 'proxy/interface_proxy.cc', 'proxy/interface_proxy.h', + 'proxy/pepper_file_messages.cc', + 'proxy/pepper_file_messages.h', 'proxy/plugin_array_buffer_var.cc', 'proxy/plugin_array_buffer_var.h', 'proxy/plugin_dispatcher.cc', diff --git a/ppapi/ppapi_proxy_untrusted.gypi b/ppapi/ppapi_proxy_untrusted.gypi index 82e9936..4985f76 100644 --- a/ppapi/ppapi_proxy_untrusted.gypi +++ b/ppapi/ppapi_proxy_untrusted.gypi @@ -344,6 +344,7 @@ 'proxy/host_var_serialization_rules.cc', 'proxy/interface_list.cc', 'proxy/interface_proxy.cc', + 'proxy/pepper_file_messages.cc', 'proxy/plugin_array_buffer_var.cc', 'proxy/plugin_dispatcher.cc', 'proxy/plugin_globals.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index d9d0140..5afcefe 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -41,7 +41,7 @@ ], 'export_dependent_settings': [ '../base/base.gyp:base', - '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', + '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', ], 'conditions': [ ['OS=="mac"', { @@ -57,6 +57,8 @@ 'shared_impl/array_writer.h', 'shared_impl/callback_tracker.cc', 'shared_impl/callback_tracker.h', + 'shared_impl/file_path.cc', + 'shared_impl/file_path.h', 'shared_impl/file_type_conversion.cc', 'shared_impl/file_type_conversion.h', 'shared_impl/host_resource.h', diff --git a/ppapi/proxy/pepper_file_messages.cc b/ppapi/proxy/pepper_file_messages.cc new file mode 100644 index 0000000..53b4fcb --- /dev/null +++ b/ppapi/proxy/pepper_file_messages.cc @@ -0,0 +1,68 @@ +// Copyright (c) 2012 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. + + +// Get basic type definitions. +#define IPC_MESSAGE_IMPL +#include "ppapi/proxy/pepper_file_messages.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "ppapi/proxy/pepper_file_messages.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#include "ppapi/proxy/pepper_file_messages.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "ppapi/proxy/pepper_file_messages.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "ppapi/proxy/pepper_file_messages.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "ppapi/proxy/pepper_file_messages.h" +} // namespace IPC + +namespace IPC { + +void ParamTraits<ppapi::PepperFilePath>::Write(Message* m, + const param_type& p) { + WriteParam(m, static_cast<unsigned>(p.domain())); + WriteParam(m, p.path()); +} + +bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m, + PickleIterator* iter, + param_type* p) { + unsigned domain; + FilePath path; + if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) + return false; + if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID) + return false; + + *p = ppapi::PepperFilePath( + static_cast<ppapi::PepperFilePath::Domain>(domain), path); + return true; +} + +void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, + std::string* l) { + l->append("("); + LogParam(static_cast<unsigned>(p.domain()), l); + l->append(", "); + LogParam(p.path(), l); + l->append(")"); +} + +} // namespace IPC diff --git a/content/common/pepper_file_messages.h b/ppapi/proxy/pepper_file_messages.h index d202d53..c36e7b6 100644 --- a/content/common/pepper_file_messages.h +++ b/ppapi/proxy/pepper_file_messages.h @@ -3,22 +3,22 @@ // found in the LICENSE file. // Multiply-included message file, no traditional include guard. -#include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_param_traits.h" #include "ipc/ipc_platform_file.h" -#include "webkit/plugins/ppapi/dir_contents.h" -#include "webkit/plugins/ppapi/file_path.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/dir_contents.h" +#include "ppapi/shared_impl/file_path.h" // Singly-included section since need custom serialization. -#ifndef CONTENT_COMMON_PEPPER_FILE_MESSAGES_H_ -#define CONTENT_COMMON_PEPPER_FILE_MESSAGES_H_ +#ifndef PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_ +#define PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_ namespace IPC { template <> -struct ParamTraits<webkit::ppapi::PepperFilePath> { - typedef webkit::ppapi::PepperFilePath param_type; +struct ParamTraits<ppapi::PepperFilePath> { + typedef ppapi::PepperFilePath param_type; static void Write(Message* m, const param_type& p); static bool Read(const Message* m, PickleIterator* iter, param_type* p); static void Log(const param_type& p, std::string* l); @@ -26,11 +26,14 @@ struct ParamTraits<webkit::ppapi::PepperFilePath> { } // namespace IPC -#endif // CONTENT_COMMON_PEPPER_FILE_MESSAGES_H_ +#endif // PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_ + +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT PPAPI_PROXY_EXPORT #define IPC_MESSAGE_START PepperFileMsgStart -IPC_STRUCT_TRAITS_BEGIN(webkit::ppapi::DirEntry) +IPC_STRUCT_TRAITS_BEGIN(ppapi::DirEntry) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(is_dir) IPC_STRUCT_TRAITS_END() @@ -39,37 +42,37 @@ IPC_STRUCT_TRAITS_END() // Open the file. IPC_SYNC_MESSAGE_CONTROL2_2(PepperFileMsg_OpenFile, - webkit::ppapi::PepperFilePath /* path */, + ppapi::PepperFilePath /* path */, int /* flags */, base::PlatformFileError /* error_code */, IPC::PlatformFileForTransit /* result */) // Rename the file. IPC_SYNC_MESSAGE_CONTROL2_1(PepperFileMsg_RenameFile, - webkit::ppapi::PepperFilePath /* from_path */, - webkit::ppapi::PepperFilePath /* to_path */, + ppapi::PepperFilePath /* from_path */, + ppapi::PepperFilePath /* to_path */, base::PlatformFileError /* error_code */) // Delete the file. IPC_SYNC_MESSAGE_CONTROL2_1(PepperFileMsg_DeleteFileOrDir, - webkit::ppapi::PepperFilePath /* path */, + ppapi::PepperFilePath /* path */, bool /* recursive */, base::PlatformFileError /* error_code */) // Create the directory. IPC_SYNC_MESSAGE_CONTROL1_1(PepperFileMsg_CreateDir, - webkit::ppapi::PepperFilePath /* path */, + ppapi::PepperFilePath /* path */, base::PlatformFileError /* error_code */) // Query the file's info. IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_QueryFile, - webkit::ppapi::PepperFilePath /* path */, + ppapi::PepperFilePath /* path */, base::PlatformFileInfo, /* info */ base::PlatformFileError /* error_code */) // Get the directory's contents. IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_GetDirContents, - webkit::ppapi::PepperFilePath /* path */, - webkit::ppapi::DirContents, /* contents */ + ppapi::PepperFilePath /* path */, + ppapi::DirContents, /* contents */ base::PlatformFileError /* error_code */) diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 3abb786..b2787a9 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1208,38 +1208,6 @@ IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBFlash_WriteClipboardData, int /* clipboard_type */, std::vector<int> /* formats */, std::vector<ppapi::proxy::SerializedVar> /* data */) -IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBFlash_OpenFile, - PP_Instance /* instance */, - std::string /* path */, - int32_t /* mode */, - IPC::PlatformFileForTransit /* file_handle */, - int32_t /* result */) -IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlash_RenameFile, - PP_Instance /* instance */, - std::string /* path_from */, - std::string /* path_to */, - int32_t /* result */) -IPC_SYNC_MESSAGE_ROUTED3_1( - PpapiHostMsg_PPBFlash_DeleteFileOrDir, - PP_Instance /* instance */, - std::string /* path */, - PP_Bool /* recursive */, - int32_t /* result */) -IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_CreateDir, - PP_Instance /* instance */, - std::string /* path */, - int32_t /* result */) -IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlash_QueryFile, - PP_Instance /* instance */, - std::string /* path */, - PP_FileInfo /* info */, - int32_t /* result */) -IPC_SYNC_MESSAGE_ROUTED2_2( - PpapiHostMsg_PPBFlash_GetDirContents, - PP_Instance /* instance */, - std::string /* path */, - std::vector<ppapi::proxy::SerializedDirEntry> /* entries */, - int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBFlash_OpenFileRef, PP_Instance /* instance */, ppapi::HostResource /* file_ref */, diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 632c40a..5bfd5f4 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -20,12 +20,15 @@ #include "ppapi/c/private/ppb_flash.h" #include "ppapi/c/private/ppb_flash_print.h" #include "ppapi/proxy/host_dispatcher.h" +#include "ppapi/proxy/pepper_file_messages.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/proxy_module.h" #include "ppapi/proxy/serialized_var.h" +#include "ppapi/shared_impl/dir_contents.h" +#include "ppapi/shared_impl/file_type_conversion.h" #include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/resource.h" @@ -427,18 +430,6 @@ bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgReadClipboardData) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_WriteClipboardData, OnHostMsgWriteClipboardData) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFile, - OnHostMsgOpenFile) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RenameFile, - OnHostMsgRenameFile) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DeleteFileOrDir, - OnHostMsgDeleteFileOrDir) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_CreateDir, - OnHostMsgCreateDir) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFile, - OnHostMsgQueryFile) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDirContents, - OnHostMsgGetDirContents) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, OnHostMsgOpenFileRef) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, @@ -687,102 +678,128 @@ void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { g_module_local_thread_adapter->ClearInstanceRouting(instance); } -int32_t PPB_Flash_Proxy::OpenFile(PP_Instance instance, +int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, const char* path, int32_t mode, PP_FileHandle* file) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; + int flags = 0; + if (!path || + !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || + !file) + return PP_ERROR_BADARGUMENT; - int32_t result = PP_ERROR_FAILED; - IPC::PlatformFileForTransit transit; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_OpenFile( - API_ID_PPB_FLASH, instance, path, mode, &transit, &result)); - *file = IPC::PlatformFileForTransitToPlatformFile(transit); - return result; + base::PlatformFileError error; + IPC::PlatformFileForTransit transit_file; + ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(path)); + + if (PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_OpenFile(pepper_path, flags, + &error, &transit_file))) { + *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); + } else { + *file = base::kInvalidPlatformFileValue; + error = base::PLATFORM_FILE_ERROR_FAILED; + } + + return ppapi::PlatformFileErrorToPepperError(error); } -int32_t PPB_Flash_Proxy::RenameFile(PP_Instance instance, - const char* path_from, - const char* path_to) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; +int32_t PPB_Flash_Proxy::RenameFile(PP_Instance, + const char* from_path, + const char* to_path) { + base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; + ppapi::PepperFilePath pepper_from(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(from_path)); + ppapi::PepperFilePath pepper_to(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(to_path)); - int32_t result = PP_ERROR_FAILED; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_RenameFile( - API_ID_PPB_FLASH, instance, path_from, path_to, &result)); - return result; + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_RenameFile(pepper_from, pepper_to, &error)); + + return ppapi::PlatformFileErrorToPepperError(error); } -int32_t PPB_Flash_Proxy::DeleteFileOrDir(PP_Instance instance, +int32_t PPB_Flash_Proxy::DeleteFileOrDir(PP_Instance, const char* path, PP_Bool recursive) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; + base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; + ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(path)); - int32_t result = PP_ERROR_FAILED; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_DeleteFileOrDir( - API_ID_PPB_FLASH, instance, path, recursive, &result)); - return result; + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_DeleteFileOrDir(pepper_path, + PP_ToBool(recursive), + &error)); + + return ppapi::PlatformFileErrorToPepperError(error); } -int32_t PPB_Flash_Proxy::CreateDir(PP_Instance instance, const char* path) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; +int32_t PPB_Flash_Proxy::CreateDir(PP_Instance, const char* path) { + base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; + ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(path)); - int32_t result = PP_ERROR_FAILED; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_CreateDir( - API_ID_PPB_FLASH, instance, path, &result)); - return result; + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_CreateDir(pepper_path, &error)); + + return ppapi::PlatformFileErrorToPepperError(error); } -int32_t PPB_Flash_Proxy::QueryFile(PP_Instance instance, +int32_t PPB_Flash_Proxy::QueryFile(PP_Instance, const char* path, PP_FileInfo* info) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; + base::PlatformFileInfo file_info; + base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; + ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(path)); - int32_t result = PP_ERROR_FAILED; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_QueryFile( - API_ID_PPB_FLASH, instance, path, info, &result)); - return result; + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_QueryFile(pepper_path, &file_info, &error)); + + if (error == base::PLATFORM_FILE_OK) { + info->size = file_info.size; + info->creation_time = TimeToPPTime(file_info.creation_time); + info->last_access_time = TimeToPPTime(file_info.last_accessed); + info->last_modified_time = TimeToPPTime(file_info.last_modified); + info->system_type = PP_FILESYSTEMTYPE_EXTERNAL; + if (file_info.is_directory) + info->type = PP_FILETYPE_DIRECTORY; + else + info->type = PP_FILETYPE_REGULAR; + } + + return ppapi::PlatformFileErrorToPepperError(error); } -int32_t PPB_Flash_Proxy::GetDirContents(PP_Instance instance, +int32_t PPB_Flash_Proxy::GetDirContents(PP_Instance, const char* path, PP_DirContents_Dev** contents) { - if (!g_module_local_thread_adapter) - return PP_ERROR_FAILED; + ppapi::DirContents entries; + base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; + ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, + FilePath::FromUTF8Unsafe(path)); - int32_t result = PP_ERROR_FAILED; - std::vector<SerializedDirEntry> entries; - g_module_local_thread_adapter->Send(instance, - new PpapiHostMsg_PPBFlash_GetDirContents( - API_ID_PPB_FLASH, instance, path, &entries, &result)); - - if (result != PP_OK) - return result; - - // Copy the serialized dir entries to the output struct. - *contents = new PP_DirContents_Dev; - (*contents)->count = static_cast<int32_t>(entries.size()); - (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; - for (size_t i = 0; i < entries.size(); i++) { - const SerializedDirEntry& source = entries[i]; - PP_DirEntry_Dev* dest = &(*contents)->entries[i]; - - char* name_copy = new char[source.name.size() + 1]; - memcpy(name_copy, source.name.c_str(), source.name.size() + 1); - dest->name = name_copy; - dest->is_dir = PP_FromBool(source.is_dir); + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PepperFileMsg_GetDirContents(pepper_path, &entries, &error)); + + if (error == base::PLATFORM_FILE_OK) { + // Copy the serialized dir entries to the output struct. + *contents = new PP_DirContents_Dev; + (*contents)->count = static_cast<int32_t>(entries.size()); + (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; + for (size_t i = 0; i < entries.size(); i++) { + const ppapi::DirEntry& source = entries[i]; + PP_DirEntry_Dev* dest = &(*contents)->entries[i]; + std::string name = source.name.AsUTF8Unsafe(); + char* name_copy = new char[name.size() + 1]; + memcpy(name_copy, name.c_str(), name.size() + 1); + dest->name = name_copy; + dest->is_dir = PP_FromBool(source.is_dir); + } } - return result; + return ppapi::PlatformFileErrorToPepperError(error); } int32_t PPB_Flash_Proxy::OpenFileRef(PP_Instance instance, @@ -1048,101 +1065,6 @@ void PPB_Flash_Proxy::OnHostMsgWriteClipboardData( } } -void PPB_Flash_Proxy::OnHostMsgOpenFile( - PP_Instance instance, - const std::string& path, - int32_t mode, - IPC::PlatformFileForTransit* file_handle, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - base::PlatformFile file; - *result = enter.functions()->GetFlashAPI()->OpenFile( - instance, path.c_str(), mode, &file); - *file_handle = PlatformFileToPlatformFileForTransit( - dispatcher(), result, file); - } else { - *result = PP_ERROR_BADARGUMENT; - } -} - -void PPB_Flash_Proxy::OnHostMsgRenameFile(PP_Instance instance, - const std::string& from_path, - const std::string& to_path, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - *result = enter.functions()->GetFlashAPI()->RenameFile( - instance, from_path.c_str(), to_path.c_str()); - } else { - *result = PP_ERROR_BADARGUMENT; - } -} - -void PPB_Flash_Proxy::OnHostMsgDeleteFileOrDir(PP_Instance instance, - const std::string& path, - PP_Bool recursive, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - *result = enter.functions()->GetFlashAPI()->DeleteFileOrDir( - instance, path.c_str(), recursive); - } else { - *result = PP_ERROR_BADARGUMENT; - } -} - -void PPB_Flash_Proxy::OnHostMsgCreateDir(PP_Instance instance, - const std::string& path, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - *result = enter.functions()->GetFlashAPI()->CreateDir( - instance, path.c_str()); - } else { - *result = PP_ERROR_BADARGUMENT; - } -} - -void PPB_Flash_Proxy::OnHostMsgQueryFile(PP_Instance instance, - const std::string& path, - PP_FileInfo* info, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.succeeded()) { - *result = enter.functions()->GetFlashAPI()->QueryFile( - instance, path.c_str(), info); - } else { - *result = PP_ERROR_BADARGUMENT; - } -} - -void PPB_Flash_Proxy::OnHostMsgGetDirContents( - PP_Instance instance, - const std::string& path, - std::vector<SerializedDirEntry>* entries, - int32_t* result) { - EnterInstanceNoLock enter(instance); - if (enter.failed()) { - *result = PP_ERROR_BADARGUMENT; - return; - } - - PP_DirContents_Dev* contents = NULL; - *result = enter.functions()->GetFlashAPI()->GetDirContents( - instance, path.c_str(), &contents); - if (*result != PP_OK) - return; - - // Convert the list of entries to the serialized version. - entries->resize(contents->count); - for (int32_t i = 0; i < contents->count; i++) { - (*entries)[i].name.assign(contents->entries[i].name); - (*entries)[i].is_dir = PP_ToBool(contents->entries[i].is_dir); - } - enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents); -} - void PPB_Flash_Proxy::OnHostMsgOpenFileRef( PP_Instance instance, const HostResource& host_resource, diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index b9ae9d0..8cbf144 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -160,30 +160,6 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared { int clipboard_type, const std::vector<int>& formats, SerializedVarVectorReceiveInput data_items); - void OnHostMsgOpenFile(PP_Instance instance, - const std::string& path, - int32_t mode, - IPC::PlatformFileForTransit* file_handle, - int32_t* result); - void OnHostMsgRenameFile(PP_Instance instance, - const std::string& path_from, - const std::string& path_to, - int32_t* result); - void OnHostMsgDeleteFileOrDir(PP_Instance instance, - const std::string& path, - PP_Bool recursive, - int32_t* result); - void OnHostMsgCreateDir(PP_Instance instance, - const std::string& path, - int32_t* result); - void OnHostMsgQueryFile(PP_Instance instance, - const std::string& path, - PP_FileInfo* info, - int32_t* result); - void OnHostMsgGetDirContents(PP_Instance instance, - const std::string& path, - std::vector<SerializedDirEntry>* entries, - int32_t* result); void OnHostMsgOpenFileRef(PP_Instance instance, const ppapi::HostResource& host_resource, int32_t mode, diff --git a/webkit/plugins/ppapi/dir_contents.h b/ppapi/shared_impl/dir_contents.h index f9a6c45..98c29f3 100644 --- a/webkit/plugins/ppapi/dir_contents.h +++ b/ppapi/shared_impl/dir_contents.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_ -#define WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_ +#ifndef PPAPI_SHARED_IMPL_DIR_CONTENTS_H_ +#define PPAPI_SHARED_IMPL_DIR_CONTENTS_H_ + #include <vector> #include "base/file_path.h" -namespace webkit { namespace ppapi { struct DirEntry { @@ -20,6 +20,5 @@ struct DirEntry { typedef std::vector<DirEntry> DirContents; } // namespace ppapi -} // namespace webkit -#endif // WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_ +#endif // PPAPI_SHARED_IMPL_DIR_CONTENTS_H_ diff --git a/webkit/plugins/ppapi/file_path.cc b/ppapi/shared_impl/file_path.cc index 14d8970..1208b08 100644 --- a/webkit/plugins/ppapi/file_path.cc +++ b/ppapi/shared_impl/file_path.cc @@ -2,17 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/plugins/ppapi/file_path.h" +#include "ppapi/shared_impl/file_path.h" #include <string> -#include "webkit/plugins/ppapi/plugin_module.h" - #if defined(OS_WIN) #include "base/utf_string_conversions.h" #endif -namespace webkit { namespace ppapi { namespace { @@ -44,12 +41,11 @@ PepperFilePath PepperFilePath::MakeAbsolute(const FilePath& path) { } // static -PepperFilePath PepperFilePath::MakeModuleLocal(PluginModule* module, +PepperFilePath PepperFilePath::MakeModuleLocal(const std::string& name, const char* utf8_path) { - FilePath full_path = GetFilePathFromUTF8(module->name()).Append( + FilePath full_path = GetFilePathFromUTF8(name).Append( GetFilePathFromUTF8(utf8_path)); return PepperFilePath(DOMAIN_MODULE_LOCAL, full_path); } } // namespace ppapi -} // namespace webkit diff --git a/webkit/plugins/ppapi/file_path.h b/ppapi/shared_impl/file_path.h index ce8fe53..bcec9f8 100644 --- a/webkit/plugins/ppapi/file_path.h +++ b/ppapi/shared_impl/file_path.h @@ -2,24 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_PLUGINS_PPAPI_FILE_PATH_H_ -#define WEBKIT_PLUGINS_PPAPI_FILE_PATH_H_ +#ifndef PPAPI_SHARED_IMPL_FILE_PATH_H_ +#define PPAPI_SHARED_IMPL_FILE_PATH_H_ #include <string> #include "base/file_path.h" -#include "webkit/plugins/webkit_plugins_export.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" -namespace webkit { namespace ppapi { -class PluginModule; - // TODO(vtl): Once we put |::FilePath| into the |base| namespace, get rid of the // |Pepper| (or |PEPPER_|) prefixes. Right now, it's just too // confusing/dangerous! -class PepperFilePath { +class PPAPI_SHARED_EXPORT PepperFilePath { public: enum Domain { DOMAIN_INVALID = 0, @@ -30,11 +27,11 @@ class PepperFilePath { DOMAIN_MAX_VALID = DOMAIN_MODULE_LOCAL }; - WEBKIT_PLUGINS_EXPORT PepperFilePath(); - WEBKIT_PLUGINS_EXPORT PepperFilePath(Domain d, const FilePath& p); + PepperFilePath(); + PepperFilePath(Domain d, const FilePath& p); static PepperFilePath MakeAbsolute(const FilePath& path); - static PepperFilePath MakeModuleLocal(PluginModule* module, + static PepperFilePath MakeModuleLocal(const std::string& name, const char* utf8_path); Domain domain() const { return domain_; } @@ -46,6 +43,5 @@ class PepperFilePath { }; } // namespace ppapi -} // namespace webkit -#endif // WEBKIT_PLUGINS_PPAPI_FILE_PATH_H_ +#endif // PPAPI_SHARED_IMPL_FILE_PATH_H_ diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index ea477f8..c9e54c2 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -227,13 +227,10 @@ '../plugins/ppapi/audio_helper.cc', '../plugins/ppapi/audio_helper.h', '../plugins/ppapi/common.h', - '../plugins/ppapi/dir_contents.h', '../plugins/ppapi/event_conversion.cc', '../plugins/ppapi/event_conversion.h', '../plugins/ppapi/file_callbacks.cc', '../plugins/ppapi/file_callbacks.h', - '../plugins/ppapi/file_path.cc', - '../plugins/ppapi/file_path.h', '../plugins/ppapi/fullscreen_container.h', '../plugins/ppapi/gfx_conversion.h', '../plugins/ppapi/host_array_buffer_var.cc', diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 7c7329f..f82fe93 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -202,38 +202,38 @@ void MockPluginDelegate::DidUpdateFile(const GURL& file_path, int64_t delta) { } base::PlatformFileError MockPluginDelegate::OpenFile( - const PepperFilePath& path, + const ::ppapi::PepperFilePath& path, int flags, base::PlatformFile* file) { return base::PLATFORM_FILE_ERROR_FAILED; } base::PlatformFileError MockPluginDelegate::RenameFile( - const PepperFilePath& from_path, - const PepperFilePath& to_path) { + const ::ppapi::PepperFilePath& from_path, + const ::ppapi::PepperFilePath& to_path) { return base::PLATFORM_FILE_ERROR_FAILED; } base::PlatformFileError MockPluginDelegate::DeleteFileOrDir( - const PepperFilePath& path, + const ::ppapi::PepperFilePath& path, bool recursive) { return base::PLATFORM_FILE_ERROR_FAILED; } base::PlatformFileError MockPluginDelegate::CreateDir( - const PepperFilePath& path) { + const ::ppapi::PepperFilePath& path) { return base::PLATFORM_FILE_ERROR_FAILED; } base::PlatformFileError MockPluginDelegate::QueryFile( - const PepperFilePath& path, + const ::ppapi::PepperFilePath& path, base::PlatformFileInfo* info) { return base::PLATFORM_FILE_ERROR_FAILED; } base::PlatformFileError MockPluginDelegate::GetDirContents( - const PepperFilePath& path, - DirContents* contents) { + const ::ppapi::PepperFilePath& path, + ::ppapi::DirContents* contents) { return base::PLATFORM_FILE_ERROR_FAILED; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 3136847..276342f 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -96,18 +96,24 @@ class MockPluginDelegate : public PluginDelegate { const AvailableSpaceCallback& callback); virtual void WillUpdateFile(const GURL& file_path); virtual void DidUpdateFile(const GURL& file_path, int64_t delta); - virtual base::PlatformFileError OpenFile(const PepperFilePath& path, - int flags, - base::PlatformFile* file); - virtual base::PlatformFileError RenameFile(const PepperFilePath& from_path, - const PepperFilePath& to_path); - virtual base::PlatformFileError DeleteFileOrDir(const PepperFilePath& path, - bool recursive); - virtual base::PlatformFileError CreateDir(const PepperFilePath& path); - virtual base::PlatformFileError QueryFile(const PepperFilePath& path, - base::PlatformFileInfo* info); - virtual base::PlatformFileError GetDirContents(const PepperFilePath& path, - DirContents* contents); + virtual base::PlatformFileError OpenFile( + const ::ppapi::PepperFilePath& path, + int flags, + base::PlatformFile* file); + virtual base::PlatformFileError RenameFile( + const ::ppapi::PepperFilePath& from_path, + const ::ppapi::PepperFilePath& to_path); + virtual base::PlatformFileError DeleteFileOrDir( + const ::ppapi::PepperFilePath& path, + bool recursive); + virtual base::PlatformFileError CreateDir( + const ::ppapi::PepperFilePath& path); + virtual base::PlatformFileError QueryFile( + const ::ppapi::PepperFilePath& path, + base::PlatformFileInfo* info); + virtual base::PlatformFileError GetDirContents( + const ::ppapi::PepperFilePath& path, + ::ppapi::DirContents* contents); virtual void SyncGetFileSystemPlatformPath(const GURL& url, FilePath* platform_path); virtual scoped_refptr<base::MessageLoopProxy> diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 1908a53..8bbd125 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -25,10 +25,10 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/shared_impl/dir_contents.h" #include "ui/gfx/size.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/glue/clipboard_client.h" -#include "webkit/plugins/ppapi/dir_contents.h" #include "webkit/quota/quota_types.h" class GURL; @@ -55,6 +55,7 @@ class CommandBuffer; } namespace ppapi { +class PepperFilePath; class PPB_HostResolver_Shared; class PPB_X509Certificate_Fields; struct DeviceRefData; @@ -86,7 +87,6 @@ namespace ppapi { class FileIO; class FullscreenContainer; -class PepperFilePath; class PluginInstance; class PluginModule; class PPB_Broker_Impl; @@ -456,18 +456,24 @@ class PluginDelegate { virtual void WillUpdateFile(const GURL& file_path) = 0; virtual void DidUpdateFile(const GURL& file_path, int64_t delta) = 0; - virtual base::PlatformFileError OpenFile(const PepperFilePath& path, - int flags, - base::PlatformFile* file) = 0; - virtual base::PlatformFileError RenameFile(const PepperFilePath& from_path, - const PepperFilePath& to_path) = 0; - virtual base::PlatformFileError DeleteFileOrDir(const PepperFilePath& path, - bool recursive) = 0; - virtual base::PlatformFileError CreateDir(const PepperFilePath& path) = 0; - virtual base::PlatformFileError QueryFile(const PepperFilePath& path, - base::PlatformFileInfo* info) = 0; - virtual base::PlatformFileError GetDirContents(const PepperFilePath& path, - DirContents* contents) = 0; + virtual base::PlatformFileError OpenFile( + const ::ppapi::PepperFilePath& path, + int flags, + base::PlatformFile* file) = 0; + virtual base::PlatformFileError RenameFile( + const ::ppapi::PepperFilePath& from_path, + const ::ppapi::PepperFilePath& to_path) = 0; + virtual base::PlatformFileError DeleteFileOrDir( + const ::ppapi::PepperFilePath& path, + bool recursive) = 0; + virtual base::PlatformFileError CreateDir( + const ::ppapi::PepperFilePath& path) = 0; + virtual base::PlatformFileError QueryFile( + const ::ppapi::PepperFilePath& path, + base::PlatformFileInfo* info) = 0; + virtual base::PlatformFileError GetDirContents( + const ::ppapi::PepperFilePath& path, + ::ppapi::DirContents* contents) = 0; // Synchronously returns the platform file path for a filesystem URL. virtual void SyncGetFileSystemPlatformPath(const GURL& url, diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 9290ba0..8b595ff 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -13,6 +13,7 @@ #include "googleurl/src/gurl.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/private/ppb_flash.h" +#include "ppapi/shared_impl/file_path.h" #include "ppapi/shared_impl/file_type_conversion.h" #include "ppapi/shared_impl/time_conversion.h" #include "ppapi/shared_impl/var.h" @@ -30,7 +31,6 @@ #include "webkit/glue/clipboard_client.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" #include "webkit/plugins/ppapi/common.h" -#include "webkit/plugins/ppapi/file_path.h" #include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -398,7 +398,8 @@ int32_t PPB_Flash_Impl::OpenFile(PP_Instance pp_instance, base::PlatformFile base_file; base::PlatformFileError result = instance->delegate()->OpenFile( - PepperFilePath::MakeModuleLocal(instance->module(), path), + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path), flags, &base_file); *file = base_file; @@ -416,8 +417,10 @@ int32_t PPB_Flash_Impl::RenameFile(PP_Instance pp_instance, return PP_ERROR_FAILED; base::PlatformFileError result = instance->delegate()->RenameFile( - PepperFilePath::MakeModuleLocal(instance->module(), path_from), - PepperFilePath::MakeModuleLocal(instance->module(), path_to)); + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path_from), + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path_to)); return ::ppapi::PlatformFileErrorToPepperError(result); } @@ -432,7 +435,8 @@ int32_t PPB_Flash_Impl::DeleteFileOrDir(PP_Instance pp_instance, return PP_ERROR_FAILED; base::PlatformFileError result = instance->delegate()->DeleteFileOrDir( - PepperFilePath::MakeModuleLocal(instance->module(), path), + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path), PPBoolToBool(recursive)); return ::ppapi::PlatformFileErrorToPepperError(result); } @@ -446,7 +450,8 @@ int32_t PPB_Flash_Impl::CreateDir(PP_Instance pp_instance, const char* path) { return PP_ERROR_FAILED; base::PlatformFileError result = instance->delegate()->CreateDir( - PepperFilePath::MakeModuleLocal(instance->module(), path)); + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path)); return ::ppapi::PlatformFileErrorToPepperError(result); } @@ -462,7 +467,8 @@ int32_t PPB_Flash_Impl::QueryFile(PP_Instance pp_instance, base::PlatformFileInfo file_info; base::PlatformFileError result = instance->delegate()->QueryFile( - PepperFilePath::MakeModuleLocal(instance->module(), path), + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path), &file_info); if (result == base::PLATFORM_FILE_OK) { info->size = file_info.size; @@ -488,9 +494,10 @@ int32_t PPB_Flash_Impl::GetDirContents(PP_Instance pp_instance, return PP_ERROR_FAILED; *contents = NULL; - DirContents pepper_contents; + ::ppapi::DirContents pepper_contents; base::PlatformFileError result = instance->delegate()->GetDirContents( - PepperFilePath::MakeModuleLocal(instance->module(), path), + ::ppapi::PepperFilePath::MakeModuleLocal( + instance->module()->name(), path), &pepper_contents); if (result != base::PLATFORM_FILE_OK) @@ -535,7 +542,7 @@ int32_t PPB_Flash_Impl::OpenFileRef(PP_Instance pp_instance, base::PlatformFile base_file; base::PlatformFileError result = instance->delegate()->OpenFile( - PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), + ::ppapi::PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), flags, &base_file); *file = base_file; @@ -556,7 +563,7 @@ int32_t PPB_Flash_Impl::QueryFileRef(PP_Instance pp_instance, base::PlatformFileInfo file_info; base::PlatformFileError result = instance->delegate()->QueryFile( - PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), + ::ppapi::PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), &file_info); if (result == base::PLATFORM_FILE_OK) { info->size = file_info.size; |