Skip to content

Commit

Permalink
Refactored the PPB_Flash_File_ModuleLocal/FileRef to the new ppapi re…
Browse files Browse the repository at this point in the history
…source model

The refactors PPB_Flash_File_ModuleLocal/FileRef to the new resource model. Calls for both these interfaces are now made directly to the browser. This removes the in-process implementation for these interfaces also (as they are flash-only). Tests are added for PPB_Flash_File_ModuleLocal.

Review URL: https://codereview.chromium.org/11359097

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171902 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
raymes@chromium.org committed Dec 8, 2012
1 parent e61449d commit 0c92b0d
Show file tree
Hide file tree
Showing 65 changed files with 1,256 additions and 1,637 deletions.
5 changes: 0 additions & 5 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1826,11 +1826,6 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI(
return false;
}

bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kPpapiFlashInProcess);
}

FilePath ChromeContentBrowserClient::GetHyphenDictionaryDirectory() {
FilePath directory;
PathService::Get(chrome::DIR_APP_DICTIONARIES, &directory);
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chrome_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* browser_context,
const GURL& url,
const content::SocketPermissionRequest& params) OVERRIDE;
virtual bool AllowPepperPrivateFileAPI() OVERRIDE;
virtual FilePath GetHyphenDictionaryDirectory() OVERRIDE;

#if defined(OS_POSIX) && !defined(OS_MACOSX)
Expand Down
4 changes: 4 additions & 0 deletions chrome/nacl/nacl_ipc_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
base::Passed(&response)));
break;
}
case ppapi::proxy::SerializedHandle::FILE:
// TODO(raymes): Handle file handles for NaCl.
NOTIMPLEMENTED();
break;
case ppapi::proxy::SerializedHandle::INVALID: {
// Nothing to do. TODO(dmichael): Should we log this? Or is it
// sometimes okay to pass an INVALID handle?
Expand Down
5 changes: 2 additions & 3 deletions chrome/test/ppapi/ppapi_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ TEST_PPAPI_OUT_OF_PROCESS(Flash_SetInstanceAlwaysOnTop)
TEST_PPAPI_OUT_OF_PROCESS(Flash_GetLocalTimeZoneOffset)
TEST_PPAPI_OUT_OF_PROCESS(Flash_GetCommandLineArgs)
TEST_PPAPI_OUT_OF_PROCESS(Flash_GetSetting)
// No in-process test for SetCrashData.
TEST_PPAPI_OUT_OF_PROCESS(Flash_SetCrashData)

// NaCl based PPAPI tests with WebSocket server
TEST_PPAPI_IN_PROCESS(WebSocket_IsWebSocket)
Expand Down Expand Up @@ -886,8 +884,9 @@ TEST_PPAPI_OUT_OF_PROCESS(MessageLoop_Post)

// Going forward, Flash APIs will only work out-of-process.
TEST_PPAPI_OUT_OF_PROCESS(Flash_GetProxyForURL)
TEST_PPAPI_OUT_OF_PROCESS(Flash_SetCrashData)
TEST_PPAPI_OUT_OF_PROCESS(FlashClipboard)
TEST_PPAPI_OUT_OF_PROCESS(FlashFile_CreateTemporaryFile)
TEST_PPAPI_OUT_OF_PROCESS(FlashFile)
// Mac/Aura reach NOTIMPLEMENTED/time out.
// mac: http://crbug.com/96767
// aura: http://crbug.com/104384
Expand Down
4 changes: 2 additions & 2 deletions content/browser/plugin_data_remover_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "base/version.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service_impl.h"
#include "content/browser/renderer_host/pepper/pepper_file_message_filter.h"
#include "content/browser/renderer_host/pepper/pepper_flash_file_host.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/plugin_messages.h"
#include "content/public/browser/browser_context.h"
Expand Down Expand Up @@ -202,7 +202,7 @@ class PluginDataRemoverImpl::Context

IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) {
FilePath profile_path =
PepperFileMessageFilter::GetDataDirName(browser_context_path_);
PepperFlashFileHost::GetDataDirName(browser_context_path_);
// TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc
// (which prepends the plugin name to the relative part of the path
// instead, with the absolute, profile-dependent part being enforced by
Expand Down
14 changes: 8 additions & 6 deletions content/browser/ppapi_plugin_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,10 @@ PpapiPluginProcessHost::PpapiPluginProcessHost(
permissions_,
host_resolver);

host_impl_.reset(new BrowserPpapiHostImpl(this, permissions_));

file_filter_ = new PepperTrustedFileMessageFilter(
process_->GetData().id, info.name, profile_data_directory);
host_impl_.reset(new BrowserPpapiHostImpl(this, permissions_, info.name,
profile_data_directory));

process_->GetHost()->AddFilter(filter_.get());
process_->GetHost()->AddFilter(file_filter_.get());
process_->GetHost()->AddFilter(host_impl_->message_filter());

GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_.get());
Expand All @@ -190,7 +187,12 @@ PpapiPluginProcessHost::PpapiPluginProcessHost()
PROCESS_TYPE_PPAPI_BROKER, this));

ppapi::PpapiPermissions permissions; // No permissions.
host_impl_.reset(new BrowserPpapiHostImpl(this, permissions));
// The plugin name and profile data directory shouldn't be needed for the
// broker.
std::string plugin_name;
FilePath profile_data_directory;
host_impl_.reset(new BrowserPpapiHostImpl(this, permissions, plugin_name,
profile_data_directory));
}

bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
Expand Down
4 changes: 0 additions & 4 deletions content/browser/ppapi_plugin_process_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "content/browser/renderer_host/pepper/pepper_file_message_filter.h"
#include "content/browser/renderer_host/pepper/pepper_message_filter.h"
#include "content/public/browser/browser_child_process_host_delegate.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
Expand Down Expand Up @@ -140,9 +139,6 @@ class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
ppapi::PpapiPermissions permissions_;
scoped_ptr<BrowserPpapiHostImpl> host_impl_;

// 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_;

Expand Down
26 changes: 22 additions & 4 deletions content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// found in the LICENSE file.

#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "content/browser/renderer_host/pepper/pepper_message_filter.h"

#include "content/browser/renderer_host/pepper/pepper_message_filter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "ipc/ipc_message_macros.h"
Expand All @@ -20,8 +20,14 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
net::HostResolver* host_resolver,
int render_process_id,
int render_view_id) {
// TODO(raymes): Figure out how to plumb plugin_name and
// profile_data_directory through for NaCl. They are currently only needed for
// PPB_Flash_File interfaces so it doesn't matter.
std::string plugin_name;
FilePath profile_data_directory;
BrowserPpapiHostImpl* browser_ppapi_host =
new BrowserPpapiHostImpl(sender, permissions);
new BrowserPpapiHostImpl(sender, permissions, plugin_name,
profile_data_directory);
browser_ppapi_host->set_plugin_process_handle(plugin_child_process);

channel->AddFilter(
Expand All @@ -37,9 +43,13 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(

BrowserPpapiHostImpl::BrowserPpapiHostImpl(
IPC::Sender* sender,
const ppapi::PpapiPermissions& permissions)
const ppapi::PpapiPermissions& permissions,
const std::string& plugin_name,
const FilePath& profile_data_directory)
: ppapi_host_(sender, permissions),
plugin_process_handle_(base::kNullProcessHandle) {
plugin_process_handle_(base::kNullProcessHandle),
plugin_name_(plugin_name),
profile_data_directory_(profile_data_directory) {
message_filter_ = new HostMessageFilter(&ppapi_host_);
ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
new ContentBrowserPepperHostFactory(this)));
Expand Down Expand Up @@ -80,6 +90,14 @@ bool BrowserPpapiHostImpl::GetRenderViewIDsForInstance(
return true;
}

const std::string& BrowserPpapiHostImpl::GetPluginName() {
return plugin_name_;
}

const FilePath& BrowserPpapiHostImpl::GetProfileDataDirectory() {
return profile_data_directory_;
}

void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance,
int render_process_id,
int render_view_id) {
Expand Down
10 changes: 9 additions & 1 deletion content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_

#include <map>
#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_ppapi_host.h"
Expand All @@ -23,7 +25,9 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
// as it is known (we start the process asynchronously so it won't be known
// when this object is created).
BrowserPpapiHostImpl(IPC::Sender* sender,
const ppapi::PpapiPermissions& permissions);
const ppapi::PpapiPermissions& permissions,
const std::string& plugin_name,
const FilePath& profile_data_directory);
virtual ~BrowserPpapiHostImpl();

// BrowserPpapiHost.
Expand All @@ -33,6 +37,8 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
virtual bool GetRenderViewIDsForInstance(PP_Instance instance,
int* render_process_id,
int* render_view_id) const OVERRIDE;
virtual const std::string& GetPluginName() OVERRIDE;
virtual const FilePath& GetProfileDataDirectory() OVERRIDE;

void set_plugin_process_handle(base::ProcessHandle handle) {
plugin_process_handle_ = handle;
Expand Down Expand Up @@ -79,6 +85,8 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {

ppapi::host::PpapiHost ppapi_host_;
base::ProcessHandle plugin_process_handle_;
std::string plugin_name_;
FilePath profile_data_directory_;

// Tracks all PP_Instances in this plugin and maps them to
// RenderProcess/RenderView IDs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ BrowserPpapiHostTest::BrowserPpapiHostTest()
: sink_() {
ppapi_host_.reset(new BrowserPpapiHostImpl(
&sink_,
ppapi::PpapiPermissions::AllPermissions()));
ppapi::PpapiPermissions::AllPermissions(),
std::string(),
FilePath()));
ppapi_host_->set_plugin_process_handle(base::GetCurrentProcessHandle());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "content/browser/renderer_host/pepper/pepper_flash_browser_host.h"
#include "content/browser/renderer_host/pepper/pepper_flash_file_host.h"
#include "content/browser/renderer_host/pepper/pepper_gamepad_host.h"
#include "content/browser/renderer_host/pepper/pepper_print_settings_manager.h"
#include "content/browser/renderer_host/pepper/pepper_printing_host.h"
Expand Down Expand Up @@ -62,6 +63,9 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
case PpapiHostMsg_Flash_Create::ID:
return scoped_ptr<ResourceHost>(new PepperFlashBrowserHost(
host_, instance, params.pp_resource()));
case PpapiHostMsg_FlashFile_Create::ID:
return scoped_ptr<ResourceHost>(new PepperFlashFileHost(
host_, instance, params.pp_resource()));
}
}

Expand Down
Loading

0 comments on commit 0c92b0d

Please sign in to comment.