summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 22:19:46 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 22:19:46 +0000
commit889636c1b0df6feb74cab6e23aa6ba1c7e65546a (patch)
tree301fec1f14656c1ebbb0b38ebbcc39fdb47cff18 /content/browser
parent90b3ee177b6f4dabf5f10ca10be123da2222ea9d (diff)
downloadchromium_src-889636c1b0df6feb74cab6e23aa6ba1c7e65546a.zip
chromium_src-889636c1b0df6feb74cab6e23aa6ba1c7e65546a.tar.gz
chromium_src-889636c1b0df6feb74cab6e23aa6ba1c7e65546a.tar.bz2
Open pepper files directly in browser.
This CL merges in the changes for the per-profile plugin process from the previously retired CL. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=140093 Review URL: https://chromiumcodereview.appspot.com/10387195 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/ppapi_plugin_process_host.cc17
-rw-r--r--content/browser/ppapi_plugin_process_host.h13
-rw-r--r--content/browser/renderer_host/pepper_file_message_filter.cc60
-rw-r--r--content/browser/renderer_host/pepper_file_message_filter.h50
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc2
5 files changed, 96 insertions, 46 deletions
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)