0

[Flash] Delete PPB_Broker_Trusted, PPP_Broker APIs

- Removes PPB_Broker_Trusted and PPP_Broker APIs.
- Removes Broker related messages and browser implementation.
- Removes kPpapiBrokerProcess and kPpapiFlashArgs content flags.
- Removes kPpapiBrokerProcess Sandbox flag. No plugin processes
  can generate executable code.
- Removes PluginGlobals::GetCmdLine method.

Bug: chromium:1064652,chromium:1133894,chromium:1133887
Change-Id: I697aeae388f1d14edcb737579830a35fcac390f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2473438
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817905}
This commit is contained in:
Bill Budge
2020-10-16 14:00:26 +00:00
committed by Commit Bot
parent 5d9677f230
commit 1d71c85d74
86 changed files with 52 additions and 2915 deletions
chrome
components/metrics
content
ppapi
sandbox/policy

@ -266,8 +266,7 @@ void AdjustLinuxOOMScore(const std::string& process_type) {
score = content::kPluginOomScore;
} else if (process_type == switches::kUtilityProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kCloudPrintServiceProcess ||
process_type == switches::kPpapiBrokerProcess) {
process_type == switches::kCloudPrintServiceProcess) {
score = content::kMiscOomScore;
#if BUILDFLAG(ENABLE_NACL)
} else if (process_type == switches::kNaClLoaderProcess ||
@ -311,7 +310,6 @@ bool SubprocessNeedsResourceBundle(const std::string& process_type) {
process_type == switches::kNaClLoaderProcess ||
#endif
process_type == switches::kPpapiPluginProcess ||
process_type == switches::kPpapiBrokerProcess ||
process_type == switches::kGpuProcess ||
#endif
process_type == switches::kRendererProcess ||
@ -980,14 +978,12 @@ void ChromeMainDelegate::PreSandboxStartup() {
DCHECK(command_line.HasSwitch(switches::kLang) ||
process_type == switches::kZygoteProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kPpapiBrokerProcess ||
process_type == switches::kPpapiPluginProcess);
#else
DCHECK(command_line.HasSwitch(switches::kLang) ||
process_type == switches::kZygoteProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kNaClLoaderProcess ||
process_type == switches::kPpapiBrokerProcess ||
process_type == switches::kPpapiPluginProcess);
#endif

@ -5825,8 +5825,6 @@ static_library("browser") {
"renderer_host/pepper/device_id_fetcher.h",
"renderer_host/pepper/monitor_finder_mac.h",
"renderer_host/pepper/monitor_finder_mac.mm",
"renderer_host/pepper/pepper_broker_message_filter.cc",
"renderer_host/pepper/pepper_broker_message_filter.h",
"renderer_host/pepper/pepper_isolated_file_system_message_filter.cc",
"renderer_host/pepper/pepper_isolated_file_system_message_filter.h",
]

@ -2359,7 +2359,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
embedder_support::kOriginTrialDisabledFeatures,
embedder_support::kOriginTrialDisabledTokens,
embedder_support::kOriginTrialPublicKey,
switches::kPpapiFlashArgs,
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kReaderModeHeuristics,

@ -125,7 +125,6 @@ void DeriveCommandLine(const GURL& start_url,
::switches::kGpuSandboxStartEarly,
::switches::kNumRasterThreads,
::switches::kPlatformDisallowsChromeOSDirectVideoDecoder,
::switches::kPpapiFlashArgs,
::switches::kPpapiFlashPath,
::switches::kPpapiFlashVersion,
::switches::kPpapiInProcess,

@ -105,8 +105,6 @@ std::map<uint32_t, Process> ProcessTypeCollector::ParseProcessTypes(
process = Process::ZYGOTE_PROCESS;
} else if (type == switches::kPpapiPluginProcess) {
process = Process::PPAPI_PLUGIN_PROCESS;
} else if (type == switches::kPpapiBrokerProcess) {
process = Process::PPAPI_BROKER_PROCESS;
}
process_types.emplace(pid, process);

@ -22,7 +22,6 @@ void GetExampleProcessTypeDataset(std::string* ps_output,
4000 /opt/google/chrome/chrome --log-level=1 --type=utility
5000 /opt/google/chrome/chrome --type=zygote
6000 /opt/google/chrome/chrome --type=ppapi
7000 /opt/google/chrome/chrome --type=ppapi-broker
7100 /opt/google/chrome/chrome --type=random-type
7200 /opt/google/chrome/chrome --no_type
129000 /opt/google/chrome/chrome --ppapi-flash-path=..../libpepflashplayer.so
@ -41,8 +40,6 @@ void GetExampleProcessTypeDataset(std::string* ps_output,
5000, Process::ZYGOTE_PROCESS));
process_types->insert(google::protobuf::MapPair<uint32_t, Process>(
6000, Process::PPAPI_PLUGIN_PROCESS));
process_types->insert(google::protobuf::MapPair<uint32_t, Process>(
7000, Process::PPAPI_BROKER_PROCESS));
process_types->insert(google::protobuf::MapPair<uint32_t, Process>(
7100, Process::OTHER_PROCESS));
process_types->insert(google::protobuf::MapPair<uint32_t, Process>(

@ -5,7 +5,6 @@
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h"
#include "chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "ppapi/host/message_filter_host.h"
@ -36,19 +35,6 @@ ChromeBrowserPepperHostFactory::CreateResourceHost(
if (!host_->IsValidInstance(instance))
return std::unique_ptr<ResourceHost>();
// Private interfaces.
if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PRIVATE)) {
switch (message.type()) {
case PpapiHostMsg_Broker_Create::ID: {
scoped_refptr<ResourceMessageFilter> broker_filter(
new PepperBrokerMessageFilter(instance, host_));
return std::unique_ptr<ResourceHost>(new MessageFilterHost(
host_->GetPpapiHost(), instance, resource, broker_filter));
}
}
}
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's methods calls (because
// permission check can be performed only on the UI

@ -1,71 +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 "chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h"
#include <string>
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_message_macros.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "url/gurl.h"
using content::BrowserPpapiHost;
using content::BrowserThread;
using content::RenderProcessHost;
PepperBrokerMessageFilter::PepperBrokerMessageFilter(PP_Instance instance,
BrowserPpapiHost* host)
: document_url_(host->GetDocumentURLForInstance(instance)) {
int unused;
host->GetRenderFrameIDsForInstance(instance, &render_process_id_, &unused);
}
PepperBrokerMessageFilter::~PepperBrokerMessageFilter() {}
scoped_refptr<base::SequencedTaskRunner>
PepperBrokerMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& message) {
return content::GetUIThreadTaskRunner({});
}
int32_t PepperBrokerMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
PPAPI_BEGIN_MESSAGE_MAP(PepperBrokerMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Broker_IsAllowed,
OnIsAllowed)
PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
int32_t PepperBrokerMessageFilter::OnIsAllowed(
ppapi::host::HostMessageContext* context) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!document_url_.is_valid())
return PP_ERROR_FAILED;
RenderProcessHost* render_process_host =
RenderProcessHost::FromID(render_process_id_);
if (!render_process_host)
return PP_ERROR_FAILED;
Profile* profile =
Profile::FromBrowserContext(render_process_host->GetBrowserContext());
HostContentSettingsMap* content_settings =
HostContentSettingsMapFactory::GetForProfile(profile);
ContentSetting setting = content_settings->GetContentSetting(
document_url_, document_url_, ContentSettingsType::PPAPI_BROKER,
std::string());
if (setting == CONTENT_SETTING_ALLOW)
return PP_OK;
return PP_ERROR_FAILED;
}

@ -1,50 +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.
#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_
#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/host/resource_message_filter.h"
#include "url/gurl.h"
namespace content {
class BrowserPpapiHost;
}
namespace ppapi {
namespace host {
struct HostMessageContext;
}
}
// This filter handles messages for the PepperBrokerHost on the UI thread.
class PepperBrokerMessageFilter : public ppapi::host::ResourceMessageFilter {
public:
PepperBrokerMessageFilter(PP_Instance instance,
content::BrowserPpapiHost* host);
private:
~PepperBrokerMessageFilter() override;
// ppapi::host::ResourceMessageFilter overrides.
scoped_refptr<base::SequencedTaskRunner> OverrideTaskRunnerForMessage(
const IPC::Message& message) override;
int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) override;
int32_t OnIsAllowed(ppapi::host::HostMessageContext* context);
int render_process_id_;
GURL document_url_;
DISALLOW_COPY_AND_ASSIGN(PepperBrokerMessageFilter);
};
#endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_

@ -43,7 +43,6 @@ static bool IsBoringSwitch(const std::string& flag) {
// crash_reporter separately informs the crash server if it is doing
// crash-loop handling.
crash_reporter::switches::kCrashLoopBefore,
switches::kPpapiFlashArgs,
switches::kPpapiFlashPath,
switches::kRegisterPepperPlugins,
switches::kUseGL,

@ -85,7 +85,6 @@
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/private/ppb_x509_certificate_private.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
#include "ppapi/c/trusted/ppb_char_set_trusted.h"
#include "ppapi/c/trusted/ppb_file_chooser_trusted.h"

@ -55,8 +55,5 @@ metrics::CallStackProfileParams::Process GetProfileParamsProcess(
if (process_type == switches::kPpapiPluginProcess)
return metrics::CallStackProfileParams::PPAPI_PLUGIN_PROCESS;
if (process_type == switches::kPpapiBrokerProcess)
return metrics::CallStackProfileParams::PPAPI_BROKER_PROCESS;
return metrics::CallStackProfileParams::UNKNOWN_PROCESS;
}

@ -88,10 +88,3 @@ TEST_F(ThreadProfilerProcessTypeTest, GetProfileParamsProcess_PpapiPlugin) {
EXPECT_EQ(metrics::CallStackProfileParams::PPAPI_PLUGIN_PROCESS,
GetProfileParamsProcess(command_line()));
}
TEST_F(ThreadProfilerProcessTypeTest, GetProfileParamsProcess_PpapiBroker) {
command_line().AppendSwitchASCII(switches::kProcessType,
switches::kPpapiBrokerProcess);
EXPECT_EQ(metrics::CallStackProfileParams::PPAPI_BROKER_PROCESS,
GetProfileParamsProcess(command_line()));
}

@ -27,8 +27,6 @@ Process ToExecutionContextProcess(CallStackProfileParams::Process process) {
return SANDBOX_HELPER_PROCESS;
case CallStackProfileParams::PPAPI_PLUGIN_PROCESS:
return PPAPI_PLUGIN_PROCESS;
case CallStackProfileParams::PPAPI_BROKER_PROCESS:
return PPAPI_BROKER_PROCESS;
}
NOTREACHED();
return UNKNOWN_PROCESS;

@ -21,7 +21,6 @@ struct CallStackProfileParams {
ZYGOTE_PROCESS,
SANDBOX_HELPER_PROCESS,
PPAPI_PLUGIN_PROCESS,
PPAPI_BROKER_PROCESS,
NETWORK_SERVICE_PROCESS,
MAX_PROCESS = NETWORK_SERVICE_PROCESS,

@ -135,7 +135,6 @@ bool IsSubprocess() {
auto type = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
return type == switches::kGpuProcess ||
type == switches::kPpapiBrokerProcess ||
type == switches::kPpapiPluginProcess ||
type == switches::kRendererProcess ||
type == switches::kUtilityProcess || type == switches::kZygoteProcess;

@ -172,7 +172,6 @@ namespace content {
extern int GpuMain(const content::MainFunctionParams&);
#if BUILDFLAG(ENABLE_PLUGINS)
extern int PpapiPluginMain(const MainFunctionParams&);
extern int PpapiBrokerMain(const MainFunctionParams&);
#endif
extern int RendererMain(const content::MainFunctionParams&);
extern int UtilityMain(const MainFunctionParams&);
@ -515,7 +514,6 @@ int RunOtherNamedProcessTypeMain(const std::string& process_type,
static const MainFunction kMainFunctions[] = {
#if BUILDFLAG(ENABLE_PLUGINS)
{switches::kPpapiPluginProcess, PpapiPluginMain},
{switches::kPpapiBrokerProcess, PpapiBrokerMain},
#endif // ENABLE_PLUGINS
{switches::kUtilityProcess, UtilityMain},
{switches::kRendererProcess, RendererMain},

@ -69,18 +69,6 @@ void WillLoadPluginsCallback(base::SequenceChecker* sequence_checker) {
} // namespace
// static
void PluginServiceImpl::RecordBrokerUsage(int render_process_id,
int render_frame_id) {
RenderFrameHostImpl* rfh =
RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
if (!rfh)
return;
ukm::SourceId source_id = rfh->GetPageUkmSourceId();
ukm::builders::Pepper_Broker(source_id).Record(ukm::UkmRecorder::Get());
}
// static
PluginService* PluginService::GetInstance() {
return PluginServiceImpl::GetInstance();
@ -156,16 +144,6 @@ int PluginServiceImpl::CountPpapiPluginProcessesForProfile(
return count;
}
PpapiPluginProcessHost* PluginServiceImpl::FindPpapiBrokerProcess(
const base::FilePath& broker_path) {
for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) {
if (iter->plugin_path() == broker_path)
return *iter;
}
return nullptr;
}
PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
int render_process_id,
const url::Origin& embedder_origin,
@ -268,29 +246,6 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
return plugin_host;
}
PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess(
int render_process_id,
const base::FilePath& plugin_path) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
return nullptr;
PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path);
if (plugin_host)
return plugin_host;
// Validate that the plugin is actually registered.
const PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path);
if (!info)
return nullptr;
DCHECK(info->is_out_of_process);
// This broker isn't loaded by any broker process, so create a new process.
return PpapiPluginProcessHost::CreateBrokerHost(*info);
}
void PluginServiceImpl::OpenChannelToPpapiPlugin(
int render_process_id,
const url::Origin& embedder_origin,
@ -309,25 +264,6 @@ void PluginServiceImpl::OpenChannelToPpapiPlugin(
}
}
void PluginServiceImpl::OpenChannelToPpapiBroker(
int render_process_id,
int render_frame_id,
const base::FilePath& path,
PpapiPluginProcessHost::BrokerClient* client) {
GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&PluginServiceImpl::RecordBrokerUsage,
render_process_id, render_frame_id));
PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(
render_process_id, path);
if (plugin_host) {
plugin_host->OpenChannelToPlugin(client);
} else {
// Send error.
client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
}
}
bool PluginServiceImpl::GetPluginInfoArray(
const GURL& url,
const std::string& mime_type,

@ -91,8 +91,6 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService {
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess(
int render_process_id, const base::FilePath& plugin_path);
// Opens a channel to a plugin process for the given mime type, starting
// a new plugin process if necessary. This must be called on the IO thread
@ -103,10 +101,6 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService {
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock,
PpapiPluginProcessHost::PluginClient* client);
void OpenChannelToPpapiBroker(int render_process_id,
int render_frame_id,
const base::FilePath& path,
PpapiPluginProcessHost::BrokerClient* client);
// Used to monitor plugin stability.
void RegisterPluginCrash(const base::FilePath& plugin_path);
@ -122,9 +116,6 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService {
// Pulled out of the air, seems reasonable.
static constexpr int kDefaultMaxPpapiProcessesPerProfile = 15;
// Helper for recording URLs to UKM.
static void RecordBrokerUsage(int render_process_id, int render_frame_id);
// Creates the PluginServiceImpl object, but doesn't actually build the plugin
// list yet. It's generated lazily.
PluginServiceImpl();
@ -137,8 +128,6 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService {
const base::FilePath& plugin_path,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
PpapiPluginProcessHost* FindPpapiBrokerProcess(
const base::FilePath& broker_path);
void RegisterPepperPlugins();

@ -1,114 +0,0 @@
// Copyright 2017 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/browser/plugin_service_impl.h"
#include <memory>
#include "build/build_config.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_utils.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
namespace {
constexpr char kURL1[] = "http://google.com/";
constexpr char kURL2[] = "http://youtube.com/";
constexpr char kPepperBrokerEvent[] = "Pepper.Broker";
class TestBrokerClient : public PpapiPluginProcessHost::BrokerClient {
public:
void GetPpapiChannelInfo(base::ProcessHandle* renderer_handle,
int* renderer_id) override {}
void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
base::ProcessId plugin_pid,
int plugin_child_id) override {}
bool Incognito() override { return false; }
};
} // anonymous namespace
class PluginServiceImplTest : public RenderViewHostTestHarness {
public:
PluginServiceImplTest() = default;
~PluginServiceImplTest() override = default;
void SetUp() override {
RenderViewHostTestHarness::SetUp();
test_ukm_recorder_ = std::make_unique<ukm::TestAutoSetUkmRecorder>();
}
// Check if count events were recorded and if they were all recorded with
// the specified source_id.
bool RecordedBrokerEvents(ukm::SourceId source_id, size_t count) {
RunAllPendingInMessageLoop(BrowserThread::UI);
auto entries = test_ukm_recorder_->GetEntriesByName(kPepperBrokerEvent);
if (entries.size() != count)
return false;
for (const auto* const entry : entries) {
if (entry->source_id != source_id)
return false;
}
return true;
}
void ResetUKM() {
test_ukm_recorder_ = std::make_unique<ukm::TestAutoSetUkmRecorder>();
}
private:
std::unique_ptr<ukm::TestUkmRecorder> test_ukm_recorder_;
DISALLOW_COPY_AND_ASSIGN(PluginServiceImplTest);
};
TEST_F(PluginServiceImplTest, RecordBrokerUsage) {
TestBrokerClient client;
NavigateAndCommit(GURL(kURL1));
ukm::SourceId source_id = static_cast<WebContentsImpl*>(web_contents())
->GetMainFrame()
->GetPageUkmSourceId();
PluginServiceImpl* service = PluginServiceImpl::GetInstance();
// Internal usage of the broker should not record metrics. Internal usage will
// not pass a RFH.
service->OpenChannelToPpapiBroker(0, 0, base::FilePath(), &client);
EXPECT_TRUE(RecordedBrokerEvents(source_id, 0));
// Top level frame usage should be recorded.
int render_process_id = main_rfh()->GetProcess()->GetID();
int render_frame_id = main_rfh()->GetRoutingID();
service->OpenChannelToPpapiBroker(render_process_id, render_frame_id,
base::FilePath(), &client);
EXPECT_TRUE(RecordedBrokerEvents(source_id, 1));
ResetUKM();
// Iframe usage should be recorded under the top level frame origin.
RenderFrameHost* child_frame =
RenderFrameHostTester::For(main_rfh())->AppendChild("child");
child_frame = NavigationSimulator::NavigateAndCommitFromDocument(GURL(kURL2),
child_frame);
EXPECT_EQ(GURL(kURL2), child_frame->GetLastCommittedURL());
render_process_id = child_frame->GetProcess()->GetID();
render_frame_id = child_frame->GetRoutingID();
service->OpenChannelToPpapiBroker(render_process_id, render_frame_id,
base::FilePath(), &client);
EXPECT_TRUE(RecordedBrokerEvents(source_id, 1));
}
} // namespace content

@ -61,14 +61,9 @@ class PpapiPluginSandboxedProcessLauncherDelegate
: public content::SandboxedProcessLauncherDelegate {
public:
PpapiPluginSandboxedProcessLauncherDelegate(
bool is_broker,
const ppapi::PpapiPermissions& permissions)
#if BUILDFLAG(USE_ZYGOTE_HANDLE) || defined(OS_WIN)
: is_broker_(is_broker)
#endif
#if defined(OS_WIN)
,
permissions_(permissions)
: permissions_(permissions)
#endif
{
}
@ -77,9 +72,6 @@ class PpapiPluginSandboxedProcessLauncherDelegate
#if defined(OS_WIN)
bool PreSpawnTarget(sandbox::TargetPolicy* policy) override {
if (is_broker_)
return true;
// The Pepper process is as locked-down as a renderer except that it can
// create the server side of Chrome pipes.
sandbox::ResultCode result;
@ -106,13 +98,11 @@ class PpapiPluginSandboxedProcessLauncherDelegate
if (!sid.empty())
sandbox::policy::SandboxWin::AddAppContainerPolicy(policy, sid.c_str());
// Only Flash needs to be able to execute dynamic code.
if (!permissions_.HasPermission(ppapi::PERMISSION_FLASH)) {
sandbox::MitigationFlags flags = policy->GetDelayedProcessMitigations();
flags |= sandbox::MITIGATION_DYNAMIC_CODE_DISABLE;
if (sandbox::SBOX_ALL_OK != policy->SetDelayedProcessMitigations(flags))
return false;
}
// No plugins can generate executable code.
sandbox::MitigationFlags flags = policy->GetDelayedProcessMitigations();
flags |= sandbox::MITIGATION_DYNAMIC_CODE_DISABLE;
if (sandbox::SBOX_ALL_OK != policy->SetDelayedProcessMitigations(flags))
return false;
return true;
}
@ -124,17 +114,13 @@ class PpapiPluginSandboxedProcessLauncherDelegate
*base::CommandLine::ForCurrentProcess();
base::CommandLine::StringType plugin_launcher = browser_command_line
.GetSwitchValueNative(switches::kPpapiPluginLauncher);
if (is_broker_ || !plugin_launcher.empty())
if (!plugin_launcher.empty())
return nullptr;
return GetGenericZygote();
}
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
sandbox::policy::SandboxType GetSandboxType() override {
#if defined(OS_WIN)
if (is_broker_)
return sandbox::policy::SandboxType::kNoSandbox;
#endif // OS_WIN
return sandbox::policy::SandboxType::kPpapi;
}
@ -143,9 +129,6 @@ class PpapiPluginSandboxedProcessLauncherDelegate
#endif
private:
#if BUILDFLAG(USE_ZYGOTE_HANDLE) || defined(OS_WIN)
const bool is_broker_;
#endif
#if defined(OS_WIN)
const ppapi::PpapiPermissions permissions_;
#endif
@ -187,7 +170,7 @@ class PpapiPluginProcessHost::PluginNetworkObserver
};
PpapiPluginProcessHost::~PpapiPluginProcessHost() {
DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
DVLOG(1) << "PpapiPluginProcessHost"
<< "~PpapiPluginProcessHost()";
CancelRequests();
}
@ -206,18 +189,6 @@ PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost(
return nullptr;
}
// static
PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost(
const PepperPluginInfo& info) {
PpapiPluginProcessHost* plugin_host =
new PpapiPluginProcessHost();
if (plugin_host->Init(info))
return plugin_host;
NOTREACHED(); // Init is not expected to fail.
return nullptr;
}
// static
void PpapiPluginProcessHost::DidCreateOutOfProcessInstance(
int plugin_process_id,
@ -308,8 +279,7 @@ PpapiPluginProcessHost::PpapiPluginProcessHost(
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock)
: profile_data_directory_(profile_data_directory),
origin_lock_(origin_lock),
is_broker_(false) {
origin_lock_(origin_lock) {
uint32_t base_permissions = info.permissions;
// We don't have to do any whitelisting for APIs in this process host, so
@ -337,18 +307,6 @@ PpapiPluginProcessHost::PpapiPluginProcessHost(
network_observer_ = std::make_unique<PluginNetworkObserver>(this);
}
PpapiPluginProcessHost::PpapiPluginProcessHost() : is_broker_(true) {
process_ = std::make_unique<BrowserChildProcessHostImpl>(
PROCESS_TYPE_PPAPI_BROKER, this, ChildProcessHost::IpcMode::kNormal);
ppapi::PpapiPermissions permissions; // No permissions.
// The plugin name, path and profile data directory shouldn't be needed for
// the broker.
host_impl_ = std::make_unique<BrowserPpapiHostImpl>(
this, permissions, std::string(), base::FilePath(), base::FilePath(),
false /* in_process */, false /* external_plugin */);
}
bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
plugin_path_ = info.path;
if (info.name.empty()) {
@ -367,12 +325,8 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF :
ChildProcessHost::CHILD_NORMAL;
#elif defined(OS_MAC)
// Flash needs to JIT, but other plugins do not.
int flags = permissions_.HasPermission(ppapi::PERMISSION_FLASH)
? ChildProcessHost::CHILD_PLUGIN
: ChildProcessHost::CHILD_NORMAL;
#else
// Plugins can't generate executable code.
int flags = ChildProcessHost::CHILD_NORMAL;
#endif
base::FilePath exe_path = ChildProcessHost::GetChildPath(flags);
@ -384,42 +338,31 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
std::unique_ptr<base::CommandLine> cmd_line =
std::make_unique<base::CommandLine>(exe_path);
cmd_line->AppendSwitchASCII(switches::kProcessType,
is_broker_ ? switches::kPpapiBrokerProcess
: switches::kPpapiPluginProcess);
switches::kPpapiPluginProcess);
BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line.get());
BrowserChildProcessHostImpl::CopyTraceStartupFlags(cmd_line.get());
#if defined(OS_WIN)
cmd_line->AppendArg(is_broker_ ? switches::kPrefetchArgumentPpapiBroker
: switches::kPrefetchArgumentPpapi);
cmd_line->AppendArg(switches::kPrefetchArgumentPpapi);
#endif // defined(OS_WIN)
// These switches are forwarded to both plugin and broker pocesses.
// These switches are forwarded to plugin pocesses.
static const char* const kCommonForwardSwitches[] = {
switches::kVModule
};
cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches,
base::size(kCommonForwardSwitches));
if (!is_broker_) {
static const char* const kPluginForwardSwitches[] = {
sandbox::policy::switches::kDisableSeccompFilterSandbox,
sandbox::policy::switches::kNoSandbox,
static const char* const kPluginForwardSwitches[] = {
sandbox::policy::switches::kDisableSeccompFilterSandbox,
sandbox::policy::switches::kNoSandbox,
#if defined(OS_MAC)
sandbox::policy::switches::kEnableSandboxLogging,
sandbox::policy::switches::kEnableSandboxLogging,
#endif
switches::kPpapiStartupDialog,
};
cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches,
base::size(kPluginForwardSwitches));
// Copy any flash args over if necessary.
// TODO(vtl): Stop passing flash args in the command line, or windows is
// going to explode.
std::string existing_args =
browser_command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs);
cmd_line->AppendSwitchASCII(switches::kPpapiFlashArgs, existing_args);
}
switches::kPpapiStartupDialog,
};
cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches,
base::size(kPluginForwardSwitches));
std::string locale = GetContentClient()->browser()->GetApplicationLocale();
if (!locale.empty()) {
@ -443,12 +386,12 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
if (!plugin_launcher.empty())
cmd_line->PrependWrapper(plugin_launcher);
// On posix, never use the zygote for the broker. Also, only use the zygote if
// we are not using a plugin launcher - having a plugin launcher means we need
// to use another process instead of just forking the zygote.
// On posix, only use the zygote if we are not using a plugin launcher -
// having a plugin launcher means we need to use another process instead of
// just forking the zygote.
process_->Launch(
std::make_unique<PpapiPluginSandboxedProcessLauncherDelegate>(
is_broker_, permissions_),
permissions_),
std::move(cmd_line), true);
return true;
}
@ -518,7 +461,7 @@ void PpapiPluginProcessHost::OnChannelConnected(int32_t peer_pid) {
// Called when the browser <--> plugin channel has an error. This normally
// means the plugin has crashed.
void PpapiPluginProcessHost::OnChannelError() {
VLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
VLOG(1) << "PpapiPluginProcessHost"
<< "::OnChannelError()";
// We don't need to notify the renderers that were communicating with the
// plugin since they have their own channels which will go into the error
@ -528,7 +471,7 @@ void PpapiPluginProcessHost::OnChannelError() {
}
void PpapiPluginProcessHost::CancelRequests() {
DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
DVLOG(1) << "PpapiPluginProcessHost"
<< "CancelRequests()";
for (size_t i = 0; i < pending_requests_.size(); i++) {
pending_requests_[i]->OnPpapiChannelOpened(IPC::ChannelHandle(),

@ -30,8 +30,7 @@ namespace content {
class BrowserChildProcessHostImpl;
struct PepperPluginInfo;
// Process host for PPAPI plugin and broker processes.
// When used for the broker, interpret all references to "plugin" with "broker".
// Process host for PPAPI plugin processes.
class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
public IPC::Sender {
public:
@ -65,11 +64,6 @@ class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
~PluginClient() override {}
};
class BrokerClient : public Client {
protected:
~BrokerClient() override {}
};
~PpapiPluginProcessHost() override;
static PpapiPluginProcessHost* CreatePluginHost(
@ -77,9 +71,6 @@ class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
static PpapiPluginProcessHost* CreateBrokerHost(
const PepperPluginInfo& info);
// Notification that a PP_Instance has been created and the associated
// renderer related data including the RenderView/Process pair for the given
// plugin. This is necessary so that when the plugin calls us with a
@ -126,12 +117,11 @@ class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
private:
class PluginNetworkObserver;
// Constructors for plugin and broker process hosts, respectively.
// Constructors for plugin process hosts.
// You must call Init before doing anything else.
PpapiPluginProcessHost(const PepperPluginInfo& info,
const base::FilePath& profile_data_directory,
const base::Optional<url::Origin>& origin_lock);
PpapiPluginProcessHost();
// Actually launches the process with the given plugin info. Returns true
// on success (the process was spawned).
@ -178,8 +168,6 @@ class PpapiPluginProcessHost : public BrowserChildProcessHostDelegate,
// re-use the plugin host.
const base::Optional<url::Origin> origin_lock_;
const bool is_broker_;
std::unique_ptr<BrowserChildProcessHostImpl> process_;
DISALLOW_COPY_AND_ASSIGN(PpapiPluginProcessHost);
@ -194,15 +182,6 @@ class PpapiPluginProcessHostIterator
PpapiPluginProcessHost>(PROCESS_TYPE_PPAPI_PLUGIN) {}
};
class PpapiBrokerProcessHostIterator
: public BrowserChildProcessHostTypeIterator<
PpapiPluginProcessHost> {
public:
PpapiBrokerProcessHostIterator()
: BrowserChildProcessHostTypeIterator<
PpapiPluginProcessHost>(PROCESS_TYPE_PPAPI_BROKER) {}
};
} // namespace content
#endif // CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_

@ -135,39 +135,6 @@ class RenderMessageCompletionCallback {
#if BUILDFLAG(ENABLE_PLUGINS)
class RenderFrameMessageFilter::OpenChannelToPpapiBrokerCallback
: public PpapiPluginProcessHost::BrokerClient {
public:
OpenChannelToPpapiBrokerCallback(RenderFrameMessageFilter* filter,
int routing_id)
: filter_(filter), routing_id_(routing_id) {}
~OpenChannelToPpapiBrokerCallback() override {}
void GetPpapiChannelInfo(base::ProcessHandle* renderer_handle,
int* renderer_id) override {
// base::kNullProcessHandle indicates that the channel will be used by the
// browser itself. Make sure we never output that value here.
CHECK_NE(base::kNullProcessHandle, filter_->PeerHandle());
*renderer_handle = filter_->PeerHandle();
*renderer_id = filter_->render_process_id_;
}
void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
base::ProcessId plugin_pid,
int /* plugin_child_id */) override {
filter_->Send(new ViewMsg_PpapiBrokerChannelCreated(routing_id_, plugin_pid,
channel_handle));
delete this;
}
bool Incognito() override { return filter_->incognito_; }
private:
scoped_refptr<RenderFrameMessageFilter> filter_;
int routing_id_;
};
class RenderFrameMessageFilter::OpenChannelToPpapiPluginCallback
: public RenderMessageCompletionCallback,
public PpapiPluginProcessHost::PluginClient {
@ -236,8 +203,6 @@ bool RenderFrameMessageFilter::OnMessageReceived(const IPC::Message& message) {
OnDidCreateOutOfProcessPepperInstance)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidDeleteOutOfProcessPepperInstance,
OnDidDeleteOutOfProcessPepperInstance)
IPC_MESSAGE_HANDLER(FrameHostMsg_OpenChannelToPpapiBroker,
OnOpenChannelToPpapiBroker)
IPC_MESSAGE_HANDLER(FrameHostMsg_PluginInstanceThrottleStateChange,
OnPluginInstanceThrottleStateChange)
#endif // ENABLE_PLUGINS
@ -374,14 +339,6 @@ void RenderFrameMessageFilter::OnDidDeleteOutOfProcessPepperInstance(
}
}
void RenderFrameMessageFilter::OnOpenChannelToPpapiBroker(
int routing_id,
const base::FilePath& path) {
plugin_service_->OpenChannelToPpapiBroker(
render_process_id_, routing_id, path,
new OpenChannelToPpapiBrokerCallback(this, routing_id));
}
void RenderFrameMessageFilter::OnPluginInstanceThrottleStateChange(
int plugin_child_id,
int32_t pp_instance,

@ -1143,17 +1143,7 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHostImpl* render_view_host,
return true;
}
#if BUILDFLAG(ENABLE_PLUGINS)
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_view_host)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
OnRequestPpapiBrokerPermission)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
#else
return false;
#endif
}
bool WebContentsImpl::OnMessageReceived(RenderFrameHostImpl* render_frame_host,
@ -6176,40 +6166,6 @@ void WebContentsImpl::OnPluginCrashed(RenderFrameHostImpl* source,
});
}
void WebContentsImpl::OnRequestPpapiBrokerPermission(
RenderViewHostImpl* source,
int ppb_broker_route_id,
const GURL& url,
const base::FilePath& plugin_path) {
OPTIONAL_TRACE_EVENT1("content",
"WebContentsImpl::OnRequestPpapiBrokerPermission",
"render_view_host", source);
base::OnceCallback<void(bool)> permission_result_callback = base::BindOnce(
&WebContentsImpl::SendPpapiBrokerPermissionResult, base::Unretained(this),
source->GetProcess()->GetID(), ppb_broker_route_id);
if (!delegate_) {
std::move(permission_result_callback).Run(false);
return;
}
delegate_->RequestPpapiBrokerPermission(
this, url, plugin_path, std::move(permission_result_callback));
}
void WebContentsImpl::SendPpapiBrokerPermissionResult(int process_id,
int ppb_broker_route_id,
bool result) {
OPTIONAL_TRACE_EVENT2(
"content", "WebContentsImpl::SendPpapiBrokerPermissionResult",
"process_id", process_id, "ppb_broker_route_id", ppb_broker_route_id);
RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
if (rph) {
// TODO(nick): Convert this from ViewMsg_ to a Ppapi msg, since it
// is not routed to a RenderView.
rph->Send(
new ViewMsg_PpapiBrokerPermissionResult(ppb_broker_route_id, result));
}
}
#endif // BUILDFLAG(ENABLE_PLUGINS)
void WebContentsImpl::UpdateFaviconURL(

@ -1512,16 +1512,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
void OnPluginCrashed(RenderFrameHostImpl* source,
const base::FilePath& plugin_path,
base::ProcessId plugin_pid);
void OnRequestPpapiBrokerPermission(RenderViewHostImpl* source,
int ppb_broker_route_id,
const GURL& url,
const base::FilePath& plugin_path);
// Callback function when requesting permission to access the PPAPI broker.
// |result| is true if permission was granted.
void SendPpapiBrokerPermissionResult(int process_id,
int ppb_broker_route_id,
bool result);
#endif // BUILDFLAG(ENABLE_PLUGINS)
void OnShowValidationMessage(RenderViewHostImpl* source,
const gfx::Rect& anchor_in_root_view,

@ -74,8 +74,6 @@ ProcessTypeForUma CurrentProcessType() {
return ProcessTypeForUma::kGpu;
if (process_type == switches::kPpapiPluginProcess)
return ProcessTypeForUma::kPpapiPlugin;
if (process_type == switches::kPpapiBrokerProcess)
return ProcessTypeForUma::kPpapiBroker;
NOTREACHED() << "Unexpected process type: " << process_type;
return ProcessTypeForUma::kUnknown;
}

@ -31,7 +31,6 @@ source_set("ppapi_plugin_sources") {
"plugin_process_dispatcher.h",
"ppapi_blink_platform_impl.cc",
"ppapi_blink_platform_impl.h",
"ppapi_broker_main.cc",
"ppapi_plugin_main.cc",
"ppapi_thread.cc",
"ppapi_thread.h",

@ -1,41 +0,0 @@
// Copyright (c) 2011 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 "base/run_loop.h"
#include "base/task/single_thread_task_executor.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "content/child/child_process.h"
#include "content/common/content_constants_internal.h"
#include "content/common/content_switches_internal.h"
#include "content/ppapi_plugin/ppapi_thread.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
namespace content {
// Main function for starting the PPAPI broker process.
int PpapiBrokerMain(const MainFunctionParams& parameters) {
const base::CommandLine& command_line = parameters.command_line;
if (command_line.HasSwitch(switches::kPpapiStartupDialog))
WaitForDebugger("PpapiBroker");
base::SingleThreadTaskExecutor main_thread_task_executor;
base::PlatformThread::SetName("CrPPAPIBrokerMain");
base::trace_event::TraceLog::GetInstance()->set_process_name(
"PPAPI Broker Process");
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
kTraceEventPpapiBrokerProcessSortIndex);
ChildProcess ppapi_broker_process;
base::RunLoop run_loop;
ppapi_broker_process.set_main_thread(new PpapiThread(
run_loop.QuitClosure(), parameters.command_line, true /* Broker */));
run_loop.Run();
DVLOG(1) << "PpapiBrokerMain exiting";
return 0;
}
} // namespace content

@ -128,9 +128,8 @@ int PpapiPluginMain(const MainFunctionParams& parameters) {
ChildProcess ppapi_process;
base::RunLoop run_loop;
ppapi_process.set_main_thread(new PpapiThread(run_loop.QuitClosure(),
parameters.command_line,
false /* Not a broker */));
ppapi_process.set_main_thread(
new PpapiThread(run_loop.QuitClosure(), parameters.command_line));
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MAC)
// Startup tracing is usually enabled earlier, but if we forked from a zygote,

@ -86,32 +86,22 @@ static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) {
namespace content {
typedef int32_t (*InitializeBrokerFunc)
(PP_ConnectInstance_Func* connect_instance_func);
PpapiThread::PpapiThread(base::RepeatingClosure quit_closure,
const base::CommandLine& command_line,
bool is_broker)
const base::CommandLine& command_line)
: ChildThreadImpl(std::move(quit_closure)),
is_broker_(is_broker),
plugin_globals_(GetIOTaskRunner()),
connect_instance_func_(nullptr),
local_pp_module_(base::RandInt(0, std::numeric_limits<PP_Module>::max())),
next_plugin_dispatcher_id_(1) {
plugin_globals_.SetPluginProxyDelegate(this);
plugin_globals_.set_command_line(
command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs));
blink_platform_impl_.reset(new PpapiBlinkPlatformImpl);
blink::Platform::CreateMainThreadAndInitialize(blink_platform_impl_.get());
if (!is_broker_) {
scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter(
new ppapi::proxy::PluginMessageFilter(
nullptr, plugin_globals_.resource_reply_thread_registrar()));
channel()->AddFilter(plugin_filter.get());
plugin_globals_.RegisterResourceMessageFilters(plugin_filter.get());
}
scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter(
new ppapi::proxy::PluginMessageFilter(
nullptr, plugin_globals_.resource_reply_thread_registrar()));
channel()->AddFilter(plugin_filter.get());
plugin_globals_.RegisterResourceMessageFilters(plugin_filter.get());
// In single process, browser main loop set up the discardable memory
// allocator.
@ -167,10 +157,6 @@ bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) {
void PpapiThread::OnChannelConnected(int32_t peer_pid) {
ChildThreadImpl::OnChannelConnected(peer_pid);
#if defined(OS_WIN)
if (is_broker_)
peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid));
#endif
}
base::SingleThreadTaskRunner* PpapiThread::GetIPCTaskRunner() {
@ -313,23 +299,18 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path,
return;
}
// The ShutdownModule/ShutdownBroker function is optional.
// The ShutdownModule function is optional.
plugin_entry_points_.shutdown_module =
is_broker_ ?
reinterpret_cast<PP_ShutdownModule_Func>(
library.GetFunctionPointer("PPP_ShutdownBroker")) :
reinterpret_cast<PP_ShutdownModule_Func>(
library.GetFunctionPointer("PPP_ShutdownModule"));
if (!is_broker_) {
// Get the InitializeModule function (required for non-broker code).
plugin_entry_points_.initialize_module =
reinterpret_cast<PP_InitializeModule_Func>(
library.GetFunctionPointer("PPP_InitializeModule"));
if (!plugin_entry_points_.initialize_module) {
LOG(WARNING) << "No PPP_InitializeModule in plugin library";
return;
}
// Get the InitializeModule function.
plugin_entry_points_.initialize_module =
reinterpret_cast<PP_InitializeModule_Func>(
library.GetFunctionPointer("PPP_InitializeModule"));
if (!plugin_entry_points_.initialize_module) {
LOG(WARNING) << "No PPP_InitializeModule in plugin library";
return;
}
}
@ -372,32 +353,11 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path,
}
#endif
if (is_broker_) {
// Get the InitializeBroker function (required).
InitializeBrokerFunc init_broker =
reinterpret_cast<InitializeBrokerFunc>(
library.GetFunctionPointer("PPP_InitializeBroker"));
if (!init_broker) {
LOG(WARNING) << "No PPP_InitializeBroker in plugin library";
return;
}
int32_t init_error = init_broker(&connect_instance_func_);
if (init_error != PP_OK) {
LOG(WARNING) << "InitBroker failed with error " << init_error;
return;
}
if (!connect_instance_func_) {
LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func";
return;
}
} else {
int32_t init_error = plugin_entry_points_.initialize_module(
local_pp_module_, &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
if (init_error != PP_OK) {
LOG(WARNING) << "InitModule failed with error " << init_error;
return;
}
int32_t init_error = plugin_entry_points_.initialize_module(
local_pp_module_, &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
if (init_error != PP_OK) {
LOG(WARNING) << "InitModule failed with error " << init_error;
return;
}
// Initialization succeeded, so keep the plugin DLL loaded.
@ -453,12 +413,10 @@ bool PpapiThread::SetupChannel(base::ProcessId renderer_pid,
int renderer_child_id,
bool incognito,
IPC::ChannelHandle* handle) {
DCHECK(is_broker_ == (connect_instance_func_ != nullptr));
mojo::MessagePipe pipe;
ppapi::proxy::ProxyChannel* dispatcher = nullptr;
bool init_result = false;
DCHECK(!is_broker_);
DCHECK_NE(base::kNullProcessId, renderer_pid);
PluginProcessDispatcher* plugin_dispatcher = new PluginProcessDispatcher(
plugin_entry_points_.get_interface, permissions_, incognito);

@ -19,7 +19,6 @@
#include "content/child/child_thread_impl.h"
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/trusted/ppp_broker.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
@ -51,8 +50,7 @@ class PpapiThread : public ChildThreadImpl,
public ppapi::proxy::PluginProxyDelegate {
public:
PpapiThread(base::RepeatingClosure quit_closure,
const base::CommandLine& command_line,
bool is_broker);
const base::CommandLine& command_line);
~PpapiThread() override;
void Shutdown() override;
@ -113,9 +111,6 @@ class PpapiThread : public ChildThreadImpl,
// Sets up the name of the plugin for logging using the given path.
void SavePluginName(const base::FilePath& path);
// True if running in a broker process rather than a normal plugin process.
bool is_broker_;
base::ScopedNativeLibrary library_;
ppapi::PpapiPermissions permissions_;
@ -126,10 +121,6 @@ class PpapiThread : public ChildThreadImpl,
// Storage for plugin entry points.
PepperPluginInfo::EntryPoints plugin_entry_points_;
// Callback to call when a new instance connects to the broker.
// Used only when is_broker_.
PP_ConnectInstance_Func connect_instance_func_;
// Local concept of the module ID. Some functions take this. It's necessary
// for the in-process PPAPI to handle this properly, but for proxied it's
// unnecessary. The proxy talking to multiple renderers means that each
@ -148,11 +139,6 @@ class PpapiThread : public ChildThreadImpl,
// The BlinkPlatformImpl implementation.
std::unique_ptr<PpapiBlinkPlatformImpl> blink_platform_impl_;
#if defined(OS_WIN)
// Caches the handle to the peer process if this is a broker.
base::win::ScopedHandle peer_handle_;
#endif
std::unique_ptr<discardable_memory::ClientDiscardableSharedMemoryManager>
discardable_shared_memory_manager_;

@ -584,12 +584,6 @@ const char kNumRasterThreads[] = "num-raster-threads";
const char kOverridePluginPowerSaverForTesting[] =
"override-plugin-power-saver-for-testing";
// Argument to the process type that indicates a PPAPI broker process type.
const char kPpapiBrokerProcess[] = "ppapi-broker";
// "Command-line" arguments for the PPAPI Flash; used for debugging options.
const char kPpapiFlashArgs[] = "ppapi-flash-args";
// Runs PPAPI (Pepper) plugins in-process.
const char kPpapiInProcess[] = "ppapi-in-process";

@ -172,8 +172,6 @@ CONTENT_EXPORT extern const char kNoZygote[];
extern const char kNoV8UntrustedCodeMitigations[];
CONTENT_EXPORT extern const char kNumRasterThreads[];
CONTENT_EXPORT extern const char kOverridePluginPowerSaverForTesting[];
CONTENT_EXPORT extern const char kPpapiBrokerProcess[];
CONTENT_EXPORT extern const char kPpapiFlashArgs[];
CONTENT_EXPORT extern const char kPpapiInProcess[];
extern const char kPpapiPluginLauncher[];
CONTENT_EXPORT extern const char kPpapiPluginProcess[];

@ -466,8 +466,6 @@ target(link_target_type, "renderer") {
"pepper/pepper_audio_input_host.h",
"pepper/pepper_audio_output_host.cc",
"pepper/pepper_audio_output_host.h",
"pepper/pepper_broker.cc",
"pepper/pepper_broker.h",
"pepper/pepper_browser_connection.cc",
"pepper/pepper_browser_connection.h",
"pepper/pepper_camera_device_host.cc",
@ -532,8 +530,6 @@ target(link_target_type, "renderer") {
"pepper/ppapi_preferences_builder.h",
"pepper/ppb_audio_impl.cc",
"pepper/ppb_audio_impl.h",
"pepper/ppb_broker_impl.cc",
"pepper/ppb_broker_impl.h",
"pepper/ppb_buffer_impl.cc",
"pepper/ppb_buffer_impl.h",
"pepper/ppb_graphics_3d_impl.cc",

@ -133,11 +133,6 @@ PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) {
return inst->module()->pp_module();
}
std::string HostGlobals::GetCmdLine() {
return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kPpapiFlashArgs);
}
void HostGlobals::PreCacheFontForFlash(const void* logfontw) {
// Not implemented in-process.
}

@ -40,7 +40,6 @@ class HostGlobals : public ppapi::PpapiGlobals {
ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI(
PP_Instance instance) override;
PP_Module GetModuleForInstance(PP_Instance instance) override;
std::string GetCmdLine() override;
void PreCacheFontForFlash(const void* logfontw) override;
void LogWithSource(PP_Instance instance,
PP_LogLevel level,

@ -1,254 +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/renderer/pepper/pepper_broker.h"
#include "build/build_config.h"
#include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/ppb_broker_impl.h"
#include "content/renderer/pepper/renderer_restrict_dispatch_group.h"
#include "ipc/ipc_channel_handle.h"
#include "ppapi/proxy/broker_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/platform_file.h"
#if defined(OS_POSIX)
#include "base/posix/eintr_wrapper.h"
#endif
#if defined(OS_WIN)
#include <windows.h>
#endif
namespace content {
namespace {
base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) {
base::SyncSocket::Handle out_handle = base::SyncSocket::kInvalidHandle;
#if defined(OS_WIN)
DWORD options = DUPLICATE_SAME_ACCESS;
if (!::DuplicateHandle(::GetCurrentProcess(),
handle,
::GetCurrentProcess(),
&out_handle,
0,
FALSE,
options)) {
out_handle = base::SyncSocket::kInvalidHandle;
}
#elif defined(OS_POSIX)
// If asked to close the source, we can simply re-use the source fd instead of
// dup()ing and close()ing.
out_handle = HANDLE_EINTR(::dup(handle));
#else
#error Not implemented.
#endif
return out_handle;
}
} // namespace
PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() {}
PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() {}
bool PepperBrokerDispatcherWrapper::Init(
base::ProcessId broker_pid,
const IPC::ChannelHandle& channel_handle) {
if (!channel_handle.is_mojo_channel_handle())
return false;
dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
dispatcher_.reset(new ppapi::proxy::BrokerHostDispatcher());
if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(),
broker_pid,
channel_handle,
true)) { // Client.
dispatcher_.reset();
dispatcher_delegate_.reset();
return false;
}
dispatcher_->channel()->SetRestrictDispatchChannelGroup(
kRendererRestrictDispatchGroup_Pepper);
return true;
}
// Does not take ownership of the local pipe.
int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker(
PP_Instance instance,
base::SyncSocket::Handle handle) {
IPC::PlatformFileForTransit foreign_socket_handle =
dispatcher_->ShareHandleWithRemote(handle, false);
if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit())
return PP_ERROR_FAILED;
int32_t result = PP_ERROR_FAILED;
if (!dispatcher_->Send(new PpapiMsg_ConnectToPlugin(
instance, foreign_socket_handle, &result))) {
// The plugin did not receive the handle, so it must be closed.
// The easiest way to clean it up is to just put it in an object
// and then close it. This failure case is not performance critical.
// The handle could still leak if Send succeeded but the IPC later failed.
base::SyncSocket temp_socket(
IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle));
return PP_ERROR_FAILED;
}
return result;
}
PepperBroker::PepperBroker(PluginModule* plugin_module)
: plugin_module_(plugin_module) {
DCHECK(plugin_module_);
plugin_module_->SetBroker(this);
}
PepperBroker::~PepperBroker() {
ReportFailureToClients(PP_ERROR_ABORTED);
plugin_module_->SetBroker(nullptr);
plugin_module_ = nullptr;
}
// If the channel is not ready, queue the connection.
void PepperBroker::AddPendingConnect(PPB_Broker_Impl* client) {
DCHECK(pending_connects_.find(client) == pending_connects_.end())
<< "Connect was already called for this client";
// Ensure this object and the associated broker exist as long as the
// client exists. There is a corresponding Release() call in Disconnect(),
// which is called when the PPB_Broker_Impl is destroyed. The only other
// possible reference is in pending_connect_broker_, which only holds a
// transient reference. This ensures the broker is available as long as the
// plugin needs it and allows the plugin to release the broker when it is no
// longer using it.
AddRef();
pending_connects_[client].client = client->AsWeakPtr();
}
void PepperBroker::Disconnect(PPB_Broker_Impl* client) {
// Remove the pending connect if one exists. This class will not call client's
// callback.
pending_connects_.erase(client);
// TODO(ddorwin): Send message disconnect message using dispatcher_.
// Release the reference added in Connect().
// This must be the last statement because it may delete this object.
Release();
}
void PepperBroker::OnBrokerChannelConnected(
base::ProcessId broker_pid,
const IPC::ChannelHandle& channel_handle) {
std::unique_ptr<PepperBrokerDispatcherWrapper> dispatcher(
new PepperBrokerDispatcherWrapper);
if (!dispatcher->Init(broker_pid, channel_handle)) {
ReportFailureToClients(PP_ERROR_FAILED);
return;
}
dispatcher_.reset(dispatcher.release());
// Process all pending channel requests from the plugins.
for (auto i = pending_connects_.begin(); i != pending_connects_.end();) {
base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client;
if (!i->second.is_authorized) {
++i;
continue;
}
if (weak_ptr.get())
ConnectPluginToBroker(weak_ptr.get());
pending_connects_.erase(i++);
}
}
void PepperBroker::OnBrokerPermissionResult(PPB_Broker_Impl* client,
bool result) {
auto entry = pending_connects_.find(client);
if (entry == pending_connects_.end())
return;
if (!entry->second.client.get()) {
// Client has gone away.
pending_connects_.erase(entry);
return;
}
if (!result) {
// Report failure.
client->BrokerConnected(
ppapi::PlatformFileToInt(base::SyncSocket::kInvalidHandle),
PP_ERROR_NOACCESS);
pending_connects_.erase(entry);
return;
}
if (dispatcher_) {
ConnectPluginToBroker(client);
pending_connects_.erase(entry);
return;
}
// Mark the request as authorized, continue waiting for the broker
// connection.
DCHECK(!entry->second.is_authorized);
entry->second.is_authorized = true;
}
PepperBroker::PendingConnection::PendingConnection() : is_authorized(false) {}
PepperBroker::PendingConnection::PendingConnection(
const PendingConnection& other) = default;
PepperBroker::PendingConnection::~PendingConnection() {}
void PepperBroker::ReportFailureToClients(int error_code) {
DCHECK_NE(PP_OK, error_code);
for (auto i = pending_connects_.begin(); i != pending_connects_.end(); ++i) {
base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client;
if (weak_ptr.get()) {
weak_ptr->BrokerConnected(
ppapi::PlatformFileToInt(base::SyncSocket::kInvalidHandle),
error_code);
}
}
pending_connects_.clear();
}
void PepperBroker::ConnectPluginToBroker(PPB_Broker_Impl* client) {
base::SyncSocket::Handle plugin_handle = base::SyncSocket::kInvalidHandle;
int32_t result = PP_OK;
// The socket objects will be deleted when this function exits, closing the
// handles. Any uses of the socket must duplicate them.
std::unique_ptr<base::SyncSocket> broker_socket(new base::SyncSocket());
std::unique_ptr<base::SyncSocket> plugin_socket(new base::SyncSocket());
if (base::SyncSocket::CreatePair(broker_socket.get(), plugin_socket.get())) {
result = dispatcher_->SendHandleToBroker(client->pp_instance(),
broker_socket->handle());
// If the broker has its pipe handle, duplicate the plugin's handle.
// Otherwise, the plugin's handle will be automatically closed.
if (result == PP_OK)
plugin_handle = DuplicateHandle(plugin_socket->handle());
} else {
result = PP_ERROR_FAILED;
}
// TODO(ddorwin): Change the IPC to asynchronous: Queue an object containing
// client and plugin_socket.release(), then return.
// That message handler will then call client->BrokerConnected() with the
// saved pipe handle.
// Temporarily, just call back.
client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result);
}
} // namespace content

@ -1,107 +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.
#ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/process/process.h"
#include "base/sync_socket.h"
#include "content/common/content_export.h"
#include "content/renderer/pepper/ppb_broker_impl.h"
#include "ppapi/proxy/proxy_channel.h"
namespace IPC {
struct ChannelHandle;
}
namespace ppapi {
namespace proxy {
class BrokerDispatcher;
}
}
namespace content {
class PluginModule;
// This object is NOT thread-safe.
class CONTENT_EXPORT PepperBrokerDispatcherWrapper {
public:
PepperBrokerDispatcherWrapper();
~PepperBrokerDispatcherWrapper();
bool Init(base::ProcessId broker_pid,
const IPC::ChannelHandle& channel_handle);
int32_t SendHandleToBroker(PP_Instance instance,
base::SyncSocket::Handle handle);
private:
std::unique_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_;
std::unique_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_;
};
class PepperBroker : public base::RefCountedThreadSafe<PepperBroker> {
public:
explicit PepperBroker(PluginModule* plugin_module);
// Decrements the references to the broker.
// When there are no more references, this renderer's dispatcher is
// destroyed, allowing the broker to shutdown if appropriate.
// Callers should not reference this object after calling Disconnect().
void Disconnect(PPB_Broker_Impl* client);
// Adds a pending connection to the broker. Balances out Disconnect() calls.
void AddPendingConnect(PPB_Broker_Impl* client);
// Called when the channel to the broker has been established.
void OnBrokerChannelConnected(base::ProcessId broker_pid,
const IPC::ChannelHandle& channel_handle);
// Called when we know whether permission to access the PPAPI broker was
// granted.
void OnBrokerPermissionResult(PPB_Broker_Impl* client, bool result);
private:
friend class base::RefCountedThreadSafe<PepperBroker>;
struct PendingConnection {
PendingConnection();
PendingConnection(const PendingConnection& other);
~PendingConnection();
bool is_authorized;
base::WeakPtr<PPB_Broker_Impl> client;
};
virtual ~PepperBroker();
// Reports failure to all clients that had pending operations.
void ReportFailureToClients(int error_code);
// Connects the plugin to the broker via a pipe.
void ConnectPluginToBroker(PPB_Broker_Impl* client);
std::unique_ptr<PepperBrokerDispatcherWrapper> dispatcher_;
// A map of pointers to objects that have requested a connection to the weak
// pointer we can use to reference them. The mapping is needed so we can clean
// up entries for objects that may have been deleted.
typedef std::map<PPB_Broker_Impl*, PendingConnection> ClientMap;
ClientMap pending_connects_;
// Pointer to the associated plugin module.
// Always set and cleared at the same time as the module's pointer to this.
PluginModule* plugin_module_;
DISALLOW_COPY_AND_ASSIGN(PepperBroker);
};
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_

@ -1,51 +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/renderer/pepper/pepper_broker.h"
#if defined(OS_POSIX)
#include <fcntl.h>
#include <sys/socket.h>
#endif // defined(OS_POSIX)
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "content/renderer/render_process.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class PepperBrokerTest : public ::testing::Test {
protected:
PepperBrokerTest()
: task_environment_(base::test::TaskEnvironment::MainThreadType::IO) {}
base::test::TaskEnvironment task_environment_;
// We need a render process for ppapi::proxy::ProxyChannel to work.
RenderProcess process_;
};
// Try to initialize PepperBrokerDispatcherWrapper with invalid ChannelHandle.
// Initialization should fail.
TEST_F(PepperBrokerTest, InitFailure) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
IPC::ChannelHandle invalid_channel; // Invalid by default.
// An invalid handle should result in a failure (false) without a LOG(FATAL),
// such as the one in CreatePipe(). Call it twice because without the invalid
// handle check, the posix code would hit a one-time path due to a static
// variable and go through the LOG(FATAL) path.
EXPECT_FALSE(dispatcher_wrapper.Init(base::kNullProcessId, invalid_channel));
EXPECT_FALSE(dispatcher_wrapper.Init(base::kNullProcessId, invalid_channel));
}
// On valid ChannelHandle, initialization should succeed.
TEST_F(PepperBrokerTest, InitSuccess) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
mojo::MessagePipe pipe;
IPC::ChannelHandle valid_channel(pipe.handle0.release());
EXPECT_TRUE(dispatcher_wrapper.Init(base::kNullProcessId, valid_channel));
}
} // namespace content

@ -2544,7 +2544,6 @@ ppapi::Resource* PepperPluginInstanceImpl::GetSingletonResource(
ppapi::SingletonResourceID id) {
// Flash APIs and some others aren't implemented in-process.
switch (id) {
case ppapi::BROKER_SINGLETON_ID:
case ppapi::BROWSER_FONT_SINGLETON_ID:
case ppapi::FLASH_FULLSCREEN_SINGLETON_ID:
case ppapi::ISOLATED_FILESYSTEM_SINGLETON_ID:

@ -118,7 +118,6 @@
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/private/ppb_x509_certificate_private.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
#include "ppapi/c/trusted/ppb_char_set_trusted.h"
#include "ppapi/c/trusted/ppb_file_chooser_trusted.h"
@ -485,7 +484,6 @@ PluginModule::PluginModule(const std::string& name,
: callback_tracker_(new ppapi::CallbackTracker),
is_in_destructor_(false),
is_crashed_(false),
broker_(nullptr),
library_(nullptr),
name_(name),
version_(version),
@ -690,13 +688,6 @@ bool PluginModule::ReserveInstanceID(PP_Instance instance) {
return true; // Instance ID is usable.
}
void PluginModule::SetBroker(PepperBroker* broker) {
DCHECK(!broker_ || !broker);
broker_ = broker;
}
PepperBroker* PluginModule::GetBroker() { return broker_; }
RendererPpapiHostImpl* PluginModule::CreateOutOfProcessModule(
RenderFrameImpl* render_frame,
const base::FilePath& path,

@ -50,7 +50,6 @@ class WebPluginContainer;
namespace content {
class HostDispatcherWrapper;
class PepperPluginInstanceImpl;
class PepperBroker;
class RendererPpapiHostImpl;
class RenderFrameImpl;
struct WebPluginInfo;
@ -183,10 +182,6 @@ class CONTENT_EXPORT PluginModule : public base::RefCounted<PluginModule>,
void SetReserveInstanceIDCallback(PP_Bool (*reserve)(PP_Module, PP_Instance));
bool ReserveInstanceID(PP_Instance instance);
// These should only be called from the main thread.
void SetBroker(PepperBroker* broker);
PepperBroker* GetBroker();
// Create a new HostDispatcher for proxying, hook it to the PluginModule,
// and perform other common initialization.
RendererPpapiHostImpl* CreateOutOfProcessModule(
@ -249,10 +244,6 @@ class CONTENT_EXPORT PluginModule : public base::RefCounted<PluginModule>,
// entry_points_ aren't valid.
std::unique_ptr<HostDispatcherWrapper> host_dispatcher_wrapper_;
// Non-owning pointer to the broker for this plugin module, if one exists.
// It is populated and cleared in the main thread.
PepperBroker* broker_;
// Holds a reference to the base::NativeLibrary handle if this PluginModule
// instance wraps functions loaded from a library. Can be NULL. If
// |library_| is non-NULL, PluginModule will attempt to unload the library

@ -1,151 +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/renderer/pepper/ppb_broker_impl.h"
#include "base/check.h"
#include "base/metrics/histogram_macros.h"
#include "content/common/frame_messages.h"
#include "content/common/view_messages.h"
#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_broker.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/platform_file.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_plugin_container.h"
using ppapi::PlatformFileToInt;
using ppapi::thunk::PPB_Broker_API;
using ppapi::TrackedCallback;
namespace content {
enum class PepperBrokerAction { CREATE = 0, CONNECT = 1, NUM };
// PPB_Broker_Impl ------------------------------------------------------
PPB_Broker_Impl::PPB_Broker_Impl(PP_Instance instance)
: Resource(ppapi::OBJECT_IS_IMPL, instance),
broker_(nullptr),
connect_callback_(),
pipe_handle_(PlatformFileToInt(base::SyncSocket::kInvalidHandle)),
routing_id_(RenderThreadImpl::current()->GenerateRoutingID()) {
ChildThreadImpl::current()->GetRouter()->AddRoute(routing_id_, this);
UMA_HISTOGRAM_ENUMERATION("Pepper.BrokerAction", PepperBrokerAction::CREATE,
PepperBrokerAction::NUM);
}
PPB_Broker_Impl::~PPB_Broker_Impl() {
if (broker_) {
broker_->Disconnect(this);
broker_ = nullptr;
}
// The plugin owns the handle.
pipe_handle_ = PlatformFileToInt(base::SyncSocket::kInvalidHandle);
ChildThreadImpl::current()->GetRouter()->RemoveRoute(routing_id_);
}
PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { return this; }
int32_t PPB_Broker_Impl::Connect(
scoped_refptr<TrackedCallback> connect_callback) {
// TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process.
if (broker_) {
// May only be called once.
return PP_ERROR_FAILED;
}
PepperPluginInstanceImpl* plugin_instance =
HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
return PP_ERROR_FAILED;
PluginModule* module = plugin_instance->module();
const base::FilePath& broker_path = module->path();
// The callback must be populated now in case we are connected to the broker
// and BrokerConnected is called before ConnectToBroker returns.
// Because it must be created now, it must be aborted and cleared if
// ConnectToBroker fails.
connect_callback_ = connect_callback;
broker_ = module->GetBroker();
if (!broker_) {
broker_ = new PepperBroker(module);
// Have the browser start the broker process for us.
RenderThreadImpl::current()->Send(
new FrameHostMsg_OpenChannelToPpapiBroker(routing_id_, broker_path));
}
RenderThreadImpl::current()->Send(
new ViewHostMsg_RequestPpapiBrokerPermission(
plugin_instance->render_frame()->render_view()->GetRoutingID(),
routing_id_,
GetDocumentUrl(),
broker_path));
// Adds a reference, ensuring that the broker is not deleted when
// |broker| goes out of scope.
broker_->AddPendingConnect(this);
return PP_OK_COMPLETIONPENDING;
}
int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) {
if (pipe_handle_ == PlatformFileToInt(base::SyncSocket::kInvalidHandle))
return PP_ERROR_FAILED; // Handle not set yet.
*handle = pipe_handle_;
return PP_OK;
}
GURL PPB_Broker_Impl::GetDocumentUrl() {
PepperPluginInstanceImpl* plugin_instance =
HostGlobals::Get()->GetInstance(pp_instance());
return plugin_instance->container()->GetDocument().Url();
}
// Transfers ownership of the handle to the plugin.
void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) {
DCHECK(pipe_handle_ == PlatformFileToInt(base::SyncSocket::kInvalidHandle));
DCHECK(result == PP_OK ||
handle == PlatformFileToInt(base::SyncSocket::kInvalidHandle));
pipe_handle_ = handle;
// Synchronous calls are not supported.
DCHECK(TrackedCallback::IsPending(connect_callback_));
connect_callback_->Run(result);
}
bool PPB_Broker_Impl::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPB_Broker_Impl, message)
IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated,
OnPpapiBrokerChannelCreated)
IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult,
OnPpapiBrokerPermissionResult)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void PPB_Broker_Impl::OnPpapiBrokerChannelCreated(
base::ProcessId broker_pid,
const IPC::ChannelHandle& handle) {
broker_->OnBrokerChannelConnected(broker_pid, handle);
}
void PPB_Broker_Impl::OnPpapiBrokerPermissionResult(bool result) {
broker_->OnBrokerPermissionResult(this, result);
}
} // namespace content

@ -1,79 +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.
#ifndef CONTENT_RENDERER_PEPPER_PPB_BROKER_IMPL_H_
#define CONTENT_RENDERER_PEPPER_PPB_BROKER_IMPL_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process.h"
#include "ipc/ipc_listener.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/ppb_broker_api.h"
class GURL;
namespace IPC {
struct ChannelHandle;
}
namespace content {
class PepperBroker;
class PPB_Broker_Impl : public ppapi::Resource,
public ppapi::thunk::PPB_Broker_API,
public IPC::Listener,
public base::SupportsWeakPtr<PPB_Broker_Impl> {
public:
explicit PPB_Broker_Impl(PP_Instance instance);
// Resource override.
ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() override;
// PPB_BrokerTrusted implementation.
int32_t Connect(
scoped_refptr<ppapi::TrackedCallback> connect_callback) override;
int32_t GetHandle(int32_t* handle) override;
// Returns the URL of the document this plugin runs in. This is necessary to
// decide whether to grant access to the PPAPI broker.
GURL GetDocumentUrl();
void BrokerConnected(int32_t handle, int32_t result);
private:
~PPB_Broker_Impl() override;
// IPC::Listener implementation.
bool OnMessageReceived(const IPC::Message& message) override;
void OnPpapiBrokerChannelCreated(base::ProcessId broker_pid,
const IPC::ChannelHandle& handle);
void OnPpapiBrokerPermissionResult(bool result);
// PluginDelegate ppapi broker object.
// We don't own this pointer but are responsible for calling Disconnect on it.
PepperBroker* broker_;
// Callback invoked from BrokerConnected.
scoped_refptr<ppapi::TrackedCallback> connect_callback_;
// Pipe handle for the plugin instance to use to communicate with the broker.
// Never owned by this object.
int32_t pipe_handle_;
int routing_id_;
DISALLOW_COPY_AND_ASSIGN(PPB_Broker_Impl);
};
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_PPB_BROKER_IMPL_H_

@ -7,7 +7,6 @@
#include "build/build_config.h"
#include "content/common/content_switches_internal.h"
#include "content/renderer/pepper/ppb_audio_impl.h"
#include "content/renderer/pepper/ppb_broker_impl.h"
#include "content/renderer/pepper/ppb_buffer_impl.h"
#include "content/renderer/pepper/ppb_graphics_3d_impl.h"
#include "content/renderer/pepper/ppb_image_data_impl.h"
@ -72,10 +71,6 @@ PP_Resource ResourceCreationImpl::CreateAudioOutput(PP_Instance instance) {
return 0; // Not supported in-process.
}
PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
return (new PPB_Broker_Impl(instance))->GetReference();
}
PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
uint32_t size) {
return PPB_Buffer_Impl::Create(instance, size);

@ -39,7 +39,6 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
uint32_t sample_frame_count) override;
PP_Resource CreateAudioInput(PP_Instance instance) override;
PP_Resource CreateAudioOutput(PP_Instance instance) override;
PP_Resource CreateBroker(PP_Instance instance) override;
PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) override;
PP_Resource CreateCameraDevicePrivate(PP_Instance instance) override;
PP_Resource CreateFlashFontFile(

@ -2285,7 +2285,6 @@ test("content_unittests") {
if (enable_plugins) {
sources += [
"../browser/plugin_content_origin_allowlist_unittest.cc",
"../browser/plugin_service_impl_unittest.cc",
"../browser/renderer_host/pepper/browser_ppapi_host_test.cc",
"../browser/renderer_host/pepper/browser_ppapi_host_test.h",
"../browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc",
@ -2296,7 +2295,6 @@ test("content_unittests") {
"../renderer/pepper/event_conversion_unittest.cc",
"../renderer/pepper/host_var_tracker_unittest.cc",
"../renderer/pepper/mock_resource.h",
"../renderer/pepper/pepper_broker_unittest.cc",
"../renderer/pepper/plugin_instance_throttler_impl_unittest.cc",
"../renderer/pepper/v8_var_converter_unittest.cc",
]

@ -163,8 +163,6 @@ copy("copy_test_files2") {
source_set("ppapi_tests_sources") {
sources = test_common_source_files
sources += [
"tests/test_broker.cc",
"tests/test_broker.h",
"tests/test_browser_font.cc",
"tests/test_browser_font.h",
"tests/test_buffer.cc",

@ -1,77 +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.
*/
/**
* This file defines the PPB_BrokerTrusted interface, which provides
* access to a trusted broker with greater privileges than the plugin.
*/
label Chrome {
M14 = 0.2,
M25 = 0.3
};
/**
* The PPB_BrokerTrusted interface provides access to a trusted broker
* with greater privileges than the plugin. The interface only supports
* out-of-process plugins and is to be used by proxy implementations. All
* functions should be called from the main thread only.
*
* A PPB_BrokerTrusted resource represents a connection to the broker. Its
* lifetime controls the lifetime of the broker, regardless of whether the
* handle is closed. The handle should be closed before the resource is
* released.
*/
[macro="PPB_BROKER_TRUSTED_INTERFACE"]
interface PPB_BrokerTrusted {
/**
* Returns a trusted broker resource.
*/
PP_Resource CreateTrusted([in] PP_Instance instance);
/**
* Returns true if the resource is a trusted broker.
*/
PP_Bool IsBrokerTrusted([in] PP_Resource resource);
/**
* Connects to the trusted broker. It may have already
* been launched by another instance.
* The plugin takes ownership of the handle once the callback has been called
* with a result of PP_OK. The plugin should immediately call GetHandle and
* begin managing it. If the result is not PP_OK, the browser still owns the
* handle.
*
* Returns PP_ERROR_WOULD_BLOCK on success, and invokes
* the |connect_callback| asynchronously to complete.
* As this function should always be invoked from the main thread,
* do not use the blocking variant of PP_CompletionCallback.
* Returns PP_ERROR_FAILED if called from an in-process plugin.
*/
int32_t Connect([in] PP_Resource broker,
[in] PP_CompletionCallback connect_callback);
/**
* Gets the handle to the pipe. Use once Connect has completed. Each instance
* of this interface has its own pipe.
*
* Returns PP_OK on success, and places the result into the given output
* parameter. The handle is only set when returning PP_OK. Calling this
* before connect has completed will return PP_ERROR_FAILED.
*/
int32_t GetHandle([in] PP_Resource broker, [out] int32_t handle);
/**
* Returns PP_TRUE if the plugin has permission to launch the broker. A user
* must explicitly grant permission to launch the broker for a particular
* website. This is done through an infobar that is displayed when |Connect|
* is called. This function returns PP_TRUE if the user has already granted
* permission to launch the broker for the website containing this plugin
* instance. Returns PP_FALSE otherwise.
*/
[version=0.3]
PP_Bool IsAllowed([in] PP_Resource broker);
};

@ -1,94 +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.
*/
/**
* This file defines functions that your module must implement to support a
* broker.
*/
#inline c
// {PENDING: undefine PP_EXPORT?}
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#if __GNUC__ >= 4
#define PP_EXPORT __attribute__ ((visibility("default")))
#elif defined(_MSC_VER)
#define PP_EXPORT __declspec(dllexport)
#endif
/* We don't want name mangling for these external functions. We only need
* 'extern "C"' if we're compiling with a C++ compiler.
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup Typedefs
* @{
*/
/**
* PP_ConnectInstance_Func defines the signature that you implement to
* receive notifications when a plugin instance connects to the broker.
* The broker should listen on the socket before returning.
*
* @param[in] instance The plugin instance connecting to the broker.
* @param[in] handle Handle to a socket the broker can use to communicate with
* the plugin.
* @return PP_OK on success. Any other value on failure.
*/
typedef int32_t (*PP_ConnectInstance_Func)(PP_Instance instance,
int32_t handle);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/**
* PPP_InitializeBroker() is the entry point for a broker and is
* called by the browser when your module loads. Your code must implement this
* function.
*
* Failure indicates to the browser that this broker can not be used. In this
* case, the broker will be unloaded.
*
* @param[out] connect_instance_func A pointer to a connect instance function.
* @return PP_OK on success. Any other value on failure.
*/
PP_EXPORT int32_t PPP_InitializeBroker(
PP_ConnectInstance_Func* connect_instance_func);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/** PPP_ShutdownBroker() is called before the broker is unloaded.
*/
PP_EXPORT void PPP_ShutdownBroker();
/**
* @}
*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endinl

@ -143,11 +143,9 @@ source_set("c") {
"dev/ppp_class_deprecated.h",
# Trusted interfaces.
"trusted/ppb_broker_trusted.h",
"trusted/ppb_browser_font_trusted.h",
"trusted/ppb_char_set_trusted.h",
"trusted/ppb_file_chooser_trusted.h",
"trusted/ppb_url_loader_trusted.h",
"trusted/ppp_broker.h",
]
}

@ -1,103 +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.
*/
/* From trusted/ppb_broker_trusted.idl modified Mon Dec 3 11:10:40 2012. */
#ifndef PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_
#define PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_BROKER_TRUSTED_INTERFACE_0_2 "PPB_BrokerTrusted;0.2"
#define PPB_BROKER_TRUSTED_INTERFACE_0_3 "PPB_BrokerTrusted;0.3"
#define PPB_BROKER_TRUSTED_INTERFACE PPB_BROKER_TRUSTED_INTERFACE_0_3
/**
* @file
* This file defines the PPB_BrokerTrusted interface, which provides
* access to a trusted broker with greater privileges than the plugin.
*/
/**
* @addtogroup Interfaces
* @{
*/
/**
* The PPB_BrokerTrusted interface provides access to a trusted broker
* with greater privileges than the plugin. The interface only supports
* out-of-process plugins and is to be used by proxy implementations. All
* functions should be called from the main thread only.
*
* A PPB_BrokerTrusted resource represents a connection to the broker. Its
* lifetime controls the lifetime of the broker, regardless of whether the
* handle is closed. The handle should be closed before the resource is
* released.
*/
struct PPB_BrokerTrusted_0_3 {
/**
* Returns a trusted broker resource.
*/
PP_Resource (*CreateTrusted)(PP_Instance instance);
/**
* Returns true if the resource is a trusted broker.
*/
PP_Bool (*IsBrokerTrusted)(PP_Resource resource);
/**
* Connects to the trusted broker. It may have already
* been launched by another instance.
* The plugin takes ownership of the handle once the callback has been called
* with a result of PP_OK. The plugin should immediately call GetHandle and
* begin managing it. If the result is not PP_OK, the browser still owns the
* handle.
*
* Returns PP_ERROR_WOULD_BLOCK on success, and invokes
* the |connect_callback| asynchronously to complete.
* As this function should always be invoked from the main thread,
* do not use the blocking variant of PP_CompletionCallback.
* Returns PP_ERROR_FAILED if called from an in-process plugin.
*/
int32_t (*Connect)(PP_Resource broker,
struct PP_CompletionCallback connect_callback);
/**
* Gets the handle to the pipe. Use once Connect has completed. Each instance
* of this interface has its own pipe.
*
* Returns PP_OK on success, and places the result into the given output
* parameter. The handle is only set when returning PP_OK. Calling this
* before connect has completed will return PP_ERROR_FAILED.
*/
int32_t (*GetHandle)(PP_Resource broker, int32_t* handle);
/**
* Returns PP_TRUE if the plugin has permission to launch the broker. A user
* must explicitly grant permission to launch the broker for a particular
* website. This is done through an infobar that is displayed when |Connect|
* is called. This function returns PP_TRUE if the user has already granted
* permission to launch the broker for the website containing this plugin
* instance. Returns PP_FALSE otherwise.
*/
PP_Bool (*IsAllowed)(PP_Resource broker);
};
typedef struct PPB_BrokerTrusted_0_3 PPB_BrokerTrusted;
struct PPB_BrokerTrusted_0_2 {
PP_Resource (*CreateTrusted)(PP_Instance instance);
PP_Bool (*IsBrokerTrusted)(PP_Resource resource);
int32_t (*Connect)(PP_Resource broker,
struct PP_CompletionCallback connect_callback);
int32_t (*GetHandle)(PP_Resource broker, int32_t* handle);
};
/**
* @}
*/
#endif /* PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ */

@ -1,102 +0,0 @@
/* Copyright (c) 2011 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.
*/
/* From trusted/ppp_broker.idl modified Sat Jul 16 16:51:03 2011. */
#ifndef PPAPI_C_TRUSTED_PPP_BROKER_H_
#define PPAPI_C_TRUSTED_PPP_BROKER_H_
#include "ppapi/c/pp_macros.h"
/**
* @file
* This file defines functions that your module must implement to support a
* broker.
*/
// {PENDING: undefine PP_EXPORT?}
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#if __GNUC__ >= 4
#define PP_EXPORT __attribute__ ((visibility("default")))
#elif defined(_MSC_VER)
#define PP_EXPORT __declspec(dllexport)
#endif
/* We don't want name mangling for these external functions. We only need
* 'extern "C"' if we're compiling with a C++ compiler.
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup Typedefs
* @{
*/
/**
* PP_ConnectInstance_Func defines the signature that you implement to
* receive notifications when a plugin instance connects to the broker.
* The broker should listen on the socket before returning.
*
* @param[in] instance The plugin instance connecting to the broker.
* @param[in] handle Handle to a socket the broker can use to communicate with
* the plugin.
* @return PP_OK on success. Any other value on failure.
*/
typedef int32_t (*PP_ConnectInstance_Func)(PP_Instance instance,
int32_t handle);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/**
* PPP_InitializeBroker() is the entry point for a broker and is
* called by the browser when your module loads. Your code must implement this
* function.
*
* Failure indicates to the browser that this broker can not be used. In this
* case, the broker will be unloaded.
*
* @param[out] connect_instance_func A pointer to a connect instance function.
* @return PP_OK on success. Any other value on failure.
*/
PP_EXPORT int32_t PPP_InitializeBroker(
PP_ConnectInstance_Func* connect_instance_func);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/** PPP_ShutdownBroker() is called before the broker is unloaded.
*/
PP_EXPORT void PPP_ShutdownBroker();
/**
* @}
*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PPAPI_C_TRUSTED_PPP_BROKER_H_ */

@ -22,19 +22,6 @@ class Module;
/// failure. Upon failure, the module will be unloaded.
pp::Module* CreateModule();
/// Sets the get interface function in the broker process.
///
/// This function is only relevant when you're using the PPB_Broker interface
/// in a trusted native plugin. In this case, you may need to implement
/// PPP_GetInterface when the plugin is loaded in the unsandboxed process.
/// Normally the C++ wrappers implement PPP_GetInterface for you but this
/// doesn't work in the context of the broker process.
//
/// So if you need to implement PPP_* interfaces in the broker process, call
/// this function in your PPP_InitializeBroker implementation which will set
/// up the given function as implementing PPP_GetInterface.
void SetBrokerGetInterfaceFunc(PP_GetInterface_Func broker_get_interface);
} // namespace pp
#endif // PPAPI_CPP_MODULE_EMBEDDER_H_

@ -2453,10 +2453,6 @@ static void Pnacl_M14_PPP_Messaging_HandleMessage(PP_Instance instance, struct P
/* Not generating wrapper methods for PPP_MouseLock_1_0 */
/* Not generating wrapper methods for PPB_BrokerTrusted_0_2 */
/* Not generating wrapper methods for PPB_BrokerTrusted_0_3 */
/* Not generating wrapper methods for PPB_BrowserFont_Trusted_1_0 */
/* Not generating wrapper methods for PPB_CharSet_Trusted_1_0 */
@ -4399,10 +4395,6 @@ static const struct PPP_Messaging_1_0 Pnacl_Wrappers_PPP_Messaging_1_0 = {
/* Not generating wrapper interface for PPP_MouseLock_1_0 */
/* Not generating wrapper interface for PPB_BrokerTrusted_0_2 */
/* Not generating wrapper interface for PPB_BrokerTrusted_0_3 */
/* Not generating wrapper interface for PPB_BrowserFont_Trusted_1_0 */
/* Not generating wrapper interface for PPB_CharSet_Trusted_1_0 */

@ -21,8 +21,6 @@ component("proxy") {
"../utility/completion_callback_factory.h",
"audio_buffer_resource.cc",
"audio_buffer_resource.h",
"broker_resource.cc",
"broker_resource.h",
"camera_capabilities_resource.cc",
"camera_capabilities_resource.h",
"camera_device_resource.cc",
@ -203,8 +201,6 @@ component("proxy") {
"audio_input_resource.h",
"audio_output_resource.cc",
"audio_output_resource.h",
"broker_dispatcher.cc",
"broker_dispatcher.h",
"browser_font_singleton_resource.cc",
"browser_font_singleton_resource.h",
"device_enumeration_resource_helper.cc",
@ -219,8 +215,6 @@ component("proxy") {
"host_var_serialization_rules.h",
"pdf_resource.cc",
"pdf_resource.h",
"ppb_broker_proxy.cc",
"ppb_broker_proxy.h",
"ppb_buffer_proxy.cc",
"ppb_buffer_proxy.h",
"ppb_var_deprecated_proxy.cc",

@ -1,100 +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 "ppapi/proxy/broker_dispatcher.h"
#include "base/sync_socket.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/platform_file.h"
namespace ppapi {
namespace proxy {
BrokerDispatcher::BrokerDispatcher(PP_ConnectInstance_Func connect_instance)
: connect_instance_(connect_instance) {
}
BrokerDispatcher::~BrokerDispatcher() {
}
bool BrokerDispatcher::InitBrokerWithChannel(
ProxyChannel::Delegate* delegate,
base::ProcessId peer_pid,
const IPC::ChannelHandle& channel_handle,
bool is_client) {
return ProxyChannel::InitWithChannel(delegate, peer_pid, channel_handle,
is_client,
base::ThreadTaskRunnerHandle::Get());
}
bool BrokerDispatcher::OnMessageReceived(const IPC::Message& msg) {
// Control messages.
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BrokerDispatcher, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_ConnectToPlugin, OnMsgConnectToPlugin)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
return false;
}
// Transfers ownership of the handle to the broker module.
void BrokerDispatcher::OnMsgConnectToPlugin(
PP_Instance instance,
IPC::PlatformFileForTransit handle,
int32_t* result) {
if (handle == IPC::InvalidPlatformFileForTransit()) {
*result = PP_ERROR_FAILED;
} else {
base::SyncSocket::Handle socket_handle =
IPC::PlatformFileForTransitToPlatformFile(handle);
if (connect_instance_) {
*result = connect_instance_(instance,
ppapi::PlatformFileToInt(socket_handle));
} else {
*result = PP_ERROR_FAILED;
// Close the handle since there is no other owner.
// The easiest way to clean it up is to just put it in an object
// and then close them. This failure case is not performance critical.
base::SyncSocket temp_socket(socket_handle);
}
}
}
BrokerHostDispatcher::BrokerHostDispatcher()
: BrokerDispatcher(NULL) {
}
void BrokerHostDispatcher::OnChannelError() {
DVLOG(1) << "BrokerHostDispatcher::OnChannelError()";
BrokerDispatcher::OnChannelError(); // Stop using the channel.
// Tell the host about the crash so it can clean up and display notification.
// TODO(ddorwin): Add BrokerCrashed() to PPB_Proxy_Private and call it.
// ppb_proxy_->BrokerCrashed(pp_module());
}
BrokerSideDispatcher::BrokerSideDispatcher(
PP_ConnectInstance_Func connect_instance)
: BrokerDispatcher(connect_instance) {
}
void BrokerSideDispatcher::OnChannelError() {
DVLOG(1) << "BrokerSideDispatcher::OnChannelError()";
BrokerDispatcher::OnChannelError();
// The renderer has crashed or exited. This channel and all instances
// associated with it are no longer valid.
// TODO(ddorwin): This causes the broker process to exit, which may not be
// desirable in some use cases.
delete this;
}
} // namespace proxy
} // namespace ppapi

@ -1,68 +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.
#ifndef PPAPI_PROXY_BROKER_DISPATCHER_H_
#define PPAPI_PROXY_BROKER_DISPATCHER_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ppapi/c/trusted/ppp_broker.h"
#include "ppapi/proxy/proxy_channel.h"
namespace ppapi {
namespace proxy {
class PPAPI_PROXY_EXPORT BrokerDispatcher : public ProxyChannel {
public:
~BrokerDispatcher() override;
// You must call this function before anything else. Returns true on success.
// The delegate pointer must outlive this class, ownership is not
// transferred.
virtual bool InitBrokerWithChannel(ProxyChannel::Delegate* delegate,
base::ProcessId peer_pid,
const IPC::ChannelHandle& channel_handle,
bool is_client);
// IPC::Listener implementation.
bool OnMessageReceived(const IPC::Message& msg) override;
protected:
// You must call InitBrokerWithChannel after the constructor.
explicit BrokerDispatcher(PP_ConnectInstance_Func connect_instance);
void OnMsgConnectToPlugin(PP_Instance instance,
IPC::PlatformFileForTransit handle,
int32_t* result);
PP_ConnectInstance_Func connect_instance_;
private:
DISALLOW_COPY_AND_ASSIGN(BrokerDispatcher);
};
// The dispatcher for the browser side of the broker channel.
class PPAPI_PROXY_EXPORT BrokerHostDispatcher : public BrokerDispatcher {
public:
BrokerHostDispatcher();
// IPC::Listener implementation.
void OnChannelError() override;
};
// The dispatcher for the broker side of the broker channel.
class PPAPI_PROXY_EXPORT BrokerSideDispatcher : public BrokerDispatcher {
public:
explicit BrokerSideDispatcher(PP_ConnectInstance_Func connect_instance);
// IPC::Listener implementation.
void OnChannelError() override;
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_BROKER_DISPATCHER_H_

@ -1,34 +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 "ppapi/proxy/broker_resource.h"
#include <stdint.h>
#include "ppapi/c/pp_bool.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace ppapi {
namespace proxy {
BrokerResource::BrokerResource(Connection connection, PP_Instance instance)
: PluginResource(connection, instance) {
SendCreate(BROWSER, PpapiHostMsg_Broker_Create());
}
BrokerResource::~BrokerResource() {
}
thunk::PPB_Broker_Instance_API* BrokerResource::AsPPB_Broker_Instance_API() {
return this;
}
PP_Bool BrokerResource::IsAllowed() {
int32_t result =
SyncCall<IPC::Message>(BROWSER, PpapiHostMsg_Broker_IsAllowed());
return PP_FromBool(result == PP_OK);
}
} // namespace proxy
} // namespace ppapi

@ -1,36 +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.
#ifndef PPAPI_PROXY_BROKER_RESOURCE_H_
#define PPAPI_PROXY_BROKER_RESOURCE_H_
#include "base/macros.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/thunk/ppb_broker_api.h"
namespace ppapi {
namespace proxy {
class BrokerResource
: public PluginResource,
public thunk::PPB_Broker_Instance_API {
public:
BrokerResource(Connection connection, PP_Instance instance);
~BrokerResource() override;
// Resource override.
thunk::PPB_Broker_Instance_API* AsPPB_Broker_Instance_API() override;
// thunk::PPB_Broker_Instance_API implementation.
PP_Bool IsAllowed() override;
private:
DISALLOW_COPY_AND_ASSIGN(BrokerResource);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_BROKER_RESOURCE_H_

@ -87,7 +87,6 @@
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/private/ppb_x509_certificate_private.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
#include "ppapi/c/trusted/ppb_char_set_trusted.h"
#include "ppapi/c/trusted/ppb_file_chooser_trusted.h"
@ -96,7 +95,6 @@
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_audio_proxy.h"
#include "ppapi/proxy/ppb_broker_proxy.h"
#include "ppapi/proxy/ppb_buffer_proxy.h"
#include "ppapi/proxy/ppb_core_proxy.h"
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"

@ -138,10 +138,6 @@ PP_Module PluginGlobals::GetModuleForInstance(PP_Instance instance) {
return 0;
}
std::string PluginGlobals::GetCmdLine() {
return command_line_;
}
void PluginGlobals::PreCacheFontForFlash(const void* logfontw) {
ProxyAutoUnlock unlock;
plugin_proxy_delegate_->PreCacheFontForFlash(logfontw);

@ -70,7 +70,6 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
thunk::ResourceCreationAPI* GetResourceCreationAPI(
PP_Instance instance) override;
PP_Module GetModuleForInstance(PP_Instance instance) override;
std::string GetCmdLine() override;
void PreCacheFontForFlash(const void* logfontw) override;
void LogWithSource(PP_Instance instance,
PP_LogLevel level,
@ -140,9 +139,6 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
// is known. This will be used for error logging.
void set_plugin_name(const std::string& name) { plugin_name_ = name; }
// The embedder should call this function when the command line is known.
void set_command_line(const std::string& c) { command_line_ = c; }
ResourceReplyThreadRegistrar* resource_reply_thread_registrar() {
return resource_reply_thread_registrar_.get();
}
@ -177,10 +173,6 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
// set_plugin_name is called.
std::string plugin_name_;
// Command line for the plugin. This will be empty until set_command_line is
// called.
std::string command_line_;
std::unique_ptr<BrowserSender> browser_sender_;
scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;

@ -640,11 +640,6 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_LogInterfaceUsage,
IPC_MESSAGE_CONTROL1(PpapiMsg_SetNetworkState,
bool /* online */)
// Broker Process.
IPC_SYNC_MESSAGE_CONTROL2_1(PpapiMsg_ConnectToPlugin,
PP_Instance /* instance */,
IPC::PlatformFileForTransit /* handle */,
int32_t /* result */)
#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Audio.
@ -869,13 +864,6 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPTextInput_RequestSurroundingText,
uint32_t /* desired_number_of_characters */)
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Broker.
IPC_MESSAGE_ROUTED3(
PpapiMsg_PPBBroker_ConnectComplete,
ppapi::HostResource /* broker */,
IPC::PlatformFileForTransit /* handle */,
int32_t /* result */)
// PPP_Instance_Private.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject,
PP_Instance /* instance */,
@ -1207,13 +1195,6 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBVar_CreateObjectDeprecated,
ppapi::proxy::SerializedVar /* result */)
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_Broker.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBBroker_Create,
PP_Instance /* instance */,
ppapi::HostResource /* result_resource */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBBroker_Connect,
ppapi::HostResource /* broker */)
// PPB_Buffer.
IPC_SYNC_MESSAGE_ROUTED2_2(
PpapiHostMsg_PPBBuffer_Create,
@ -1399,14 +1380,6 @@ IPC_MESSAGE_ROUTED2(
//-----------------------------------------------------------------------------
// Messages for resources using call/reply above.
// Broker ----------------------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_Create)
// Queries whether the plugin has permission to connect to the Pepper broker.
// The response is contained in the error value of the
// ResourceMessageReplyParams in the reply message.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_IsAllowed)
// UMA
IPC_MESSAGE_CONTROL0(PpapiHostMsg_UMA_Create)
IPC_MESSAGE_CONTROL5(PpapiHostMsg_UMA_HistogramCustomTimes,

@ -1,236 +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 "ppapi/proxy/ppb_broker_proxy.h"
#include "base/bind.h"
#include "base/macros.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/platform_file.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_broker_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
using ppapi::IntToPlatformFile;
using ppapi::PlatformFileToInt;
using ppapi::thunk::PPB_Broker_API;
namespace ppapi {
namespace proxy {
class Broker : public PPB_Broker_API, public Resource {
public:
explicit Broker(const HostResource& resource);
~Broker() override;
// Resource overrides.
PPB_Broker_API* AsPPB_Broker_API() override;
// PPB_Broker_API implementation.
int32_t Connect(scoped_refptr<TrackedCallback> connect_callback) override;
int32_t GetHandle(int32_t* handle) override;
// Called by the proxy when the host side has completed the request.
void ConnectComplete(IPC::PlatformFileForTransit socket_handle,
int32_t result);
private:
bool called_connect_;
scoped_refptr<TrackedCallback> current_connect_callback_;
// The plugin module owns the handle.
// The host side transfers ownership of the handle to the plugin side when it
// sends the IPC. This member holds the handle value for the plugin module
// to read, but the plugin side of the proxy never takes ownership.
base::SyncSocket::Handle socket_handle_;
DISALLOW_COPY_AND_ASSIGN(Broker);
};
Broker::Broker(const HostResource& resource)
: Resource(OBJECT_IS_PROXY, resource),
called_connect_(false),
socket_handle_(base::SyncSocket::kInvalidHandle) {
}
Broker::~Broker() {
socket_handle_ = base::SyncSocket::kInvalidHandle;
}
PPB_Broker_API* Broker::AsPPB_Broker_API() {
return this;
}
int32_t Broker::Connect(scoped_refptr<TrackedCallback> connect_callback) {
if (TrackedCallback::IsPending(current_connect_callback_))
return PP_ERROR_INPROGRESS;
else if (called_connect_)
return PP_ERROR_FAILED;
current_connect_callback_ = connect_callback;
called_connect_ = true;
bool success = PluginDispatcher::GetForResource(this)->Send(
new PpapiHostMsg_PPBBroker_Connect(
API_ID_PPB_BROKER, host_resource()));
return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED;
}
int32_t Broker::GetHandle(int32_t* handle) {
if (socket_handle_ == base::SyncSocket::kInvalidHandle)
return PP_ERROR_FAILED;
*handle = PlatformFileToInt(socket_handle_);
return PP_OK;
}
void Broker::ConnectComplete(IPC::PlatformFileForTransit socket_handle,
int32_t result) {
if (result == PP_OK) {
DCHECK(socket_handle_ == base::SyncSocket::kInvalidHandle);
socket_handle_ = IPC::PlatformFileForTransitToPlatformFile(socket_handle);
} else {
// The caller may still have given us a handle in the failure case.
// The easiest way to clean it up is to just put it in an object
// and then close them. This failure case is not performance critical.
base::SyncSocket temp_socket(
IPC::PlatformFileForTransitToPlatformFile(socket_handle));
}
if (!TrackedCallback::IsPending(current_connect_callback_)) {
// The handle might leak if the plugin never calls GetHandle().
return;
}
current_connect_callback_->Run(result);
}
PPB_Broker_Proxy::PPB_Broker_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher),
callback_factory_(this){
}
PPB_Broker_Proxy::~PPB_Broker_Proxy() {
}
// static
PP_Resource PPB_Broker_Proxy::CreateProxyResource(PP_Instance instance) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return 0;
HostResource result;
dispatcher->Send(new PpapiHostMsg_PPBBroker_Create(
API_ID_PPB_BROKER, instance, &result));
if (result.is_null())
return 0;
return (new Broker(result))->GetReference();
}
bool PPB_Broker_Proxy::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPB_Broker_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBroker_Create, OnMsgCreate)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBroker_Connect, OnMsgConnect)
IPC_MESSAGE_HANDLER(PpapiMsg_PPBBroker_ConnectComplete,
OnMsgConnectComplete)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void PPB_Broker_Proxy::OnMsgCreate(PP_Instance instance,
HostResource* result_resource) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
thunk::EnterResourceCreation enter(instance);
if (enter.succeeded()) {
result_resource->SetHostResource(
instance,
enter.functions()->CreateBroker(instance));
}
}
void PPB_Broker_Proxy::OnMsgConnect(const HostResource& broker) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
EnterHostFromHostResourceForceCallback<PPB_Broker_API> enter(
broker, callback_factory_,
&PPB_Broker_Proxy::ConnectCompleteInHost, broker);
if (enter.succeeded())
enter.SetResult(enter.object()->Connect(enter.callback()));
}
// Called in the plugin to handle the connect callback.
// The proxy owns the handle and transfers it to the Broker. At that point,
// the plugin owns the handle and is responsible for closing it.
// The caller guarantees that socket_handle is not valid if result is not PP_OK.
void PPB_Broker_Proxy::OnMsgConnectComplete(
const HostResource& resource,
IPC::PlatformFileForTransit socket_handle,
int32_t result) {
DCHECK(result == PP_OK ||
socket_handle == IPC::InvalidPlatformFileForTransit());
EnterPluginFromHostResource<PPB_Broker_API> enter(resource);
if (enter.failed()) {
// As in Broker::ConnectComplete, we need to close the resource on error.
base::SyncSocket temp_socket(
IPC::PlatformFileForTransitToPlatformFile(socket_handle));
} else {
static_cast<Broker*>(enter.object())->ConnectComplete(socket_handle,
result);
}
}
// Callback on the host side.
// Transfers ownership of the handle to the plugin side. This function must
// either successfully call the callback or close the handle.
void PPB_Broker_Proxy::ConnectCompleteInHost(int32_t result,
const HostResource& broker) {
IPC::PlatformFileForTransit foreign_socket_handle =
IPC::InvalidPlatformFileForTransit();
if (result == PP_OK) {
int32_t socket_handle = PlatformFileToInt(base::SyncSocket::kInvalidHandle);
EnterHostFromHostResource<PPB_Broker_API> enter(broker);
if (enter.succeeded())
result = enter.object()->GetHandle(&socket_handle);
DCHECK(result == PP_OK ||
socket_handle ==
PlatformFileToInt(base::SyncSocket::kInvalidHandle));
if (result == PP_OK) {
foreign_socket_handle =
dispatcher()->ShareHandleWithRemote(IntToPlatformFile(socket_handle),
true);
if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) {
result = PP_ERROR_FAILED;
// Assume the local handle was closed even if the foreign handle could
// not be created.
}
}
}
DCHECK(result == PP_OK ||
foreign_socket_handle == IPC::InvalidPlatformFileForTransit());
bool success = dispatcher()->Send(new PpapiMsg_PPBBroker_ConnectComplete(
API_ID_PPB_BROKER, broker, foreign_socket_handle, result));
if (!success || result != PP_OK) {
// The plugin did not receive the handle, so it must be closed.
// The easiest way to clean it up is to just put it in an object
// and then close it. This failure case is not performance critical.
// The handle could still leak if Send succeeded but the IPC later failed.
base::SyncSocket temp_socket(
IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle));
}
}
} // namespace proxy
} // namespace ppapi

@ -1,52 +0,0 @@
// Copyright (c) 2011 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.
#ifndef PPAPI_PROXY_PPB_BROKER_PROXY_H_
#define PPAPI_PROXY_PPB_BROKER_PROXY_H_
#include <stdint.h>
#include "base/sync_socket.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
class HostResource;
namespace proxy {
class PPB_Broker_Proxy : public InterfaceProxy {
public:
explicit PPB_Broker_Proxy(Dispatcher* dispatcher);
~PPB_Broker_Proxy() override;
static PP_Resource CreateProxyResource(PP_Instance instance);
// InterfaceProxy implementation.
bool OnMessageReceived(const IPC::Message& msg) override;
static const ApiID kApiID = API_ID_PPB_BROKER;
private:
// Message handlers.
void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource);
void OnMsgConnect(const ppapi::HostResource& broker);
void OnMsgConnectComplete(const ppapi::HostResource& broker,
IPC::PlatformFileForTransit foreign_socket_handle,
int32_t result);
void ConnectCompleteInHost(int32_t result,
const ppapi::HostResource& host_resource);
ProxyCompletionCallbackFactory<PPB_Broker_Proxy> callback_factory_;
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_PPB_BROKER_PROXY_H_

@ -18,7 +18,6 @@
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_mouse_lock.h"
#include "ppapi/proxy/broker_resource.h"
#include "ppapi/proxy/browser_font_singleton_resource.h"
#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/flash_fullscreen_resource.h"
@ -345,9 +344,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
static_cast<PluginDispatcher*>(dispatcher())->sender());
switch (id) {
case BROKER_SINGLETON_ID:
new_singleton = new BrokerResource(connection, instance);
break;
case GAMEPAD_SINGLETON_ID:
new_singleton = new GamepadResource(connection, instance);
break;

@ -27,7 +27,6 @@
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_audio_proxy.h"
#include "ppapi/proxy/ppb_broker_proxy.h"
#include "ppapi/proxy/ppb_buffer_proxy.h"
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
@ -391,10 +390,6 @@ PP_Resource ResourceCreationProxy::CreateAudioOutput(PP_Instance instance) {
return (new AudioOutputResource(GetConnection(), instance))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateBroker(PP_Instance instance) {
return PPB_Broker_Proxy::CreateProxyResource(instance);
}
PP_Resource ResourceCreationProxy::CreateBrowserFont(
PP_Instance instance,
const PP_BrowserFont_Trusted_Description* description) {

@ -156,7 +156,6 @@ class ResourceCreationProxy : public InterfaceProxy,
#if !defined(OS_NACL)
PP_Resource CreateAudioInput(PP_Instance instance) override;
PP_Resource CreateAudioOutput(PP_Instance instance) override;
PP_Resource CreateBroker(PP_Instance instance) override;
PP_Resource CreateBrowserFont(
PP_Instance instance,
const PP_BrowserFont_Trusted_Description* description) override;

@ -13,7 +13,6 @@ enum ApiID {
// Zero is reserved for control messages.
API_ID_NONE = 0,
API_ID_PPB_AUDIO = 1,
API_ID_PPB_BROKER,
API_ID_PPB_BUFFER,
API_ID_PPB_CORE,
API_ID_PPB_FLASH_MESSAGELOOP,

@ -117,9 +117,6 @@ class PPAPI_SHARED_EXPORT PpapiGlobals {
// in-process plugins.
virtual base::TaskRunner* GetFileTaskRunner() = 0;
// Returns the command line for the process.
virtual std::string GetCmdLine() = 0;
// Preloads the font on Windows, does nothing on other platforms.
// TODO(brettw) remove this by passing the instance into the API so we don't
// have to have it on the globals.

@ -25,8 +25,6 @@
F(PPB_AudioInput_API) \
F(PPB_AudioOutput_API) \
F(PPB_AudioTrusted_API) \
F(PPB_Broker_API) \
F(PPB_Broker_Instance_API) \
F(PPB_BrowserFont_Singleton_API) \
F(PPB_BrowserFont_Trusted_API) \
F(PPB_Buffer_API) \

@ -10,10 +10,6 @@ namespace ppapi {
// These IDs are used to access singleton resource objects using
// PPB_Instance_API.GetSingletonResource.
enum SingletonResourceID {
// TODO(raymes): The broker resource isn't really a singleton. This is only
// a hack until PPB_Broker trusted has been fully refactored to the new
// resource model.
BROKER_SINGLETON_ID,
BROWSER_FONT_SINGLETON_ID,
FLASH_FULLSCREEN_SINGLETON_ID,
GAMEPAD_SINGLETON_ID,

@ -40,8 +40,6 @@ thunk::ResourceCreationAPI* TestGlobals::GetResourceCreationAPI(
PP_Module TestGlobals::GetModuleForInstance(PP_Instance instance) { return 0; }
std::string TestGlobals::GetCmdLine() { return std::string(); }
void TestGlobals::PreCacheFontForFlash(const void* /* logfontw */) {}
void TestGlobals::LogWithSource(PP_Instance instance,

@ -69,7 +69,6 @@ class TestGlobals : public PpapiGlobals {
thunk::ResourceCreationAPI* GetResourceCreationAPI(
PP_Instance instance) override;
PP_Module GetModuleForInstance(PP_Instance instance) override;
std::string GetCmdLine() override;
void PreCacheFontForFlash(const void* logfontw) override;
void LogWithSource(PP_Instance instance,
PP_LogLevel level,

@ -1,355 +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 "ppapi/tests/test_broker.h"
#if defined(_MSC_VER)
#define OS_WIN 1
#include <windows.h>
#else
#define OS_POSIX 1
#include <errno.h>
#include <unistd.h>
#endif
#include <stddef.h>
#include <stdint.h>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <limits>
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppp_broker.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(Broker);
namespace {
const char kHelloMessage[] = "Hello Plugin! This is Broker!";
// Message sent from broker to plugin if the broker is unsandboxed.
const char kBrokerUnsandboxed[] = "Broker is Unsandboxed!";
// Message sent from broker to plugin if the broker is sandboxed. This message
// needs to be longer than |kBrokerUnsandboxed| because the plugin is expecting
// |kBrokerUnsandboxed|. If it's shorter and the broker doesn't close its handle
// properly the plugin will hang waiting for all data of |kBrokerUnsandboxed| to
// be read.
const char kBrokerSandboxed[] = "Broker is Sandboxed! Verification failed!";
#if defined(OS_WIN)
typedef HANDLE PlatformFile;
const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE;
const int32_t kInvalidHandle = static_cast<int32_t>(
reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE));
#elif defined(OS_POSIX)
typedef int PlatformFile;
const PlatformFile kInvalidPlatformFileValue = -1;
const int32_t kInvalidHandle = -1;
#endif
PlatformFile IntToPlatformFile(int32_t handle) {
#if defined(OS_WIN)
return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
#elif defined(OS_POSIX)
return handle;
#endif
}
#if defined(OS_POSIX)
#define HANDLE_EINTR(x) ({ \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
} while (eintr_wrapper_result == -1 && errno == EINTR); \
eintr_wrapper_result; \
})
#define IGNORE_EINTR(x) ({ \
decltype(x) eintr_wrapper_result; \
do { \
eintr_wrapper_result = (x); \
if (eintr_wrapper_result == -1 && errno == EINTR) { \
eintr_wrapper_result = 0; \
} \
} while (0); \
eintr_wrapper_result; \
})
#endif
bool ReadMessage(PlatformFile file, size_t message_len, char* message) {
#if defined(OS_WIN)
assert(message_len < std::numeric_limits<DWORD>::max());
DWORD read = 0;
const DWORD size = static_cast<DWORD>(message_len);
return ::ReadFile(file, message, size, &read, NULL) && read == size;
#elif defined(OS_POSIX)
assert(message_len <
static_cast<size_t>(std::numeric_limits<ssize_t>::max()));
size_t total_read = 0;
while (total_read < message_len) {
ssize_t read = HANDLE_EINTR(::read(file, message + total_read,
message_len - total_read));
if (read <= 0)
break;
total_read += read;
}
return total_read == message_len;
#endif
}
bool WriteMessage(PlatformFile file, size_t message_len, const char* message) {
#if defined(OS_WIN)
assert(message_len < std::numeric_limits<DWORD>::max());
DWORD written = 0;
const DWORD size = static_cast<DWORD>(message_len);
return ::WriteFile(file, message, size, &written, NULL) && written == size;
#elif defined(OS_POSIX)
assert(message_len <
static_cast<size_t>(std::numeric_limits<ssize_t>::max()));
size_t total_written = 0;
while (total_written < message_len) {
ssize_t written = HANDLE_EINTR(::write(file, message + total_written,
message_len - total_written));
if (written <= 0)
break;
total_written += written;
}
return total_written == message_len;
#endif
}
bool VerifyMessage(PlatformFile file, size_t message_len, const char* message) {
char* message_received = new char[message_len];
bool success = ReadMessage(file, message_len, message_received) &&
!::strcmp(message_received, message);
delete [] message_received;
return success;
}
bool ClosePlatformFile(PlatformFile file) {
#if defined(OS_WIN)
return !!::CloseHandle(file);
#elif defined(OS_POSIX)
return !IGNORE_EINTR(::close(file));
#endif
}
bool VerifyIsUnsandboxed() {
#if defined(OS_WIN)
FILE* file = NULL;
wchar_t temp_path[MAX_PATH] = {'\0'};
wchar_t file_name[MAX_PATH] = {'\0'};
if (!::GetTempPath(MAX_PATH, temp_path) ||
!::GetTempFileName(temp_path, L"test_pepper_broker", 0, file_name) ||
::_wfopen_s(&file, file_name, L"w"))
return false;
if (::fclose(file)) {
::DeleteFile(file_name);
return false;
}
return !!::DeleteFile(file_name);
#elif defined(OS_POSIX)
char file_name[] = "/tmp/test_pepper_broker_XXXXXX";
int fd = ::mkstemp(file_name);
if (-1 == fd)
return false;
if (IGNORE_EINTR(::close(fd))) {
::remove(file_name);
return false;
}
return !::remove(file_name);
#endif
}
// Callback in the broker when a new broker connection occurs.
int32_t OnInstanceConnected(PP_Instance instance, int32_t handle) {
PlatformFile file = IntToPlatformFile(handle);
if (file == kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
// Send hello message.
if (!WriteMessage(file, sizeof(kHelloMessage), kHelloMessage)) {
ClosePlatformFile(file);
return PP_ERROR_FAILED;
}
// Verify broker is not sandboxed and send result to plugin over the pipe.
if (VerifyIsUnsandboxed()) {
if (!WriteMessage(file, sizeof(kBrokerUnsandboxed), kBrokerUnsandboxed)) {
ClosePlatformFile(file);
return PP_ERROR_FAILED;
}
} else {
if (!WriteMessage(file, sizeof(kBrokerSandboxed), kBrokerSandboxed)) {
ClosePlatformFile(file);
return PP_ERROR_FAILED;
}
}
if (!ClosePlatformFile(file))
return PP_ERROR_FAILED;
return PP_OK;
}
} // namespace
PP_EXPORT int32_t PPP_InitializeBroker(
PP_ConnectInstance_Func* connect_instance_func) {
*connect_instance_func = &OnInstanceConnected;
return PP_OK;
}
PP_EXPORT void PPP_ShutdownBroker() {}
TestBroker::TestBroker(TestingInstance* instance)
: TestCase(instance),
broker_interface_(NULL) {
}
bool TestBroker::Init() {
broker_interface_ = static_cast<const PPB_BrokerTrusted*>(
pp::Module::Get()->GetBrowserInterface(PPB_BROKER_TRUSTED_INTERFACE));
return !!broker_interface_;
}
void TestBroker::RunTests(const std::string& filter) {
RUN_TEST(Create, filter);
RUN_TEST(Create, filter);
RUN_TEST(GetHandleFailure, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter);
// The following tests require special setup, so only run them if they're
// explicitly specified by the filter.
if (!ShouldRunAllTests(filter)) {
RUN_TEST(ConnectPermissionDenied, filter);
RUN_TEST(ConnectPermissionGranted, filter);
RUN_TEST(IsAllowedPermissionDenied, filter);
RUN_TEST(IsAllowedPermissionGranted, filter);
}
}
std::string TestBroker::TestCreate() {
// Very simplistic test to make sure we can create a broker interface.
// TODO(raymes): All of the resources created in this file are leaked. Write
// a C++ wrapper for PPB_Broker_Trusted to avoid these leaks.
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0));
ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker));
PASS();
}
// Test connection on invalid resource.
std::string TestBroker::TestConnectFailure() {
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
callback.WaitForResult(broker_interface_->Connect(0,
callback.GetCallback().pp_completion_callback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
PASS();
}
std::string TestBroker::TestGetHandleFailure() {
int32_t handle = kInvalidHandle;
// Test getting the handle for an invalid resource.
ASSERT_EQ(PP_ERROR_BADRESOURCE, broker_interface_->GetHandle(0, &handle));
// Connect hasn't been called so this should fail.
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
ASSERT_EQ(PP_ERROR_FAILED, broker_interface_->GetHandle(broker, &handle));
PASS();
}
std::string TestBroker::TestConnectAndPipe() {
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
callback.WaitForResult(broker_interface_->Connect(broker,
callback.GetCallback().pp_completion_callback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
int32_t handle = kInvalidHandle;
ASSERT_EQ(PP_OK, broker_interface_->GetHandle(broker, &handle));
ASSERT_NE(kInvalidHandle, handle);
PlatformFile file = IntToPlatformFile(handle);
ASSERT_TRUE(VerifyMessage(file, sizeof(kHelloMessage), kHelloMessage));
ASSERT_TRUE(VerifyMessage(file, sizeof(kBrokerUnsandboxed),
kBrokerUnsandboxed));
ASSERT_TRUE(ClosePlatformFile(file));
PASS();
}
std::string TestBroker::TestConnectPermissionDenied() {
// This assumes that the browser side is set up to deny access to the broker.
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
callback.WaitForResult(broker_interface_->Connect(broker,
callback.GetCallback().pp_completion_callback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_ERROR_NOACCESS, callback.result());
PASS();
}
std::string TestBroker::TestConnectPermissionGranted() {
// This assumes that the browser side is set up to allow access to the broker.
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
callback.WaitForResult(broker_interface_->Connect(broker,
callback.GetCallback().pp_completion_callback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
PASS();
}
std::string TestBroker::TestIsAllowedPermissionDenied() {
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
ASSERT_EQ(PP_FALSE, broker_interface_->IsAllowed(broker));
PASS();
}
std::string TestBroker::TestIsAllowedPermissionGranted() {
PP_Resource broker = broker_interface_->CreateTrusted(
instance_->pp_instance());
ASSERT_TRUE(broker);
ASSERT_EQ(PP_TRUE, broker_interface_->IsAllowed(broker));
PASS();
}

@ -1,35 +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.
#ifndef PPAPI_TESTS_TEST_BROKER_H_
#define PPAPI_TESTS_TEST_BROKER_H_
#include <string>
#include <vector>
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/tests/test_case.h"
class TestBroker : public TestCase {
public:
TestBroker(TestingInstance* instance);
// TestCase implementation.
virtual bool Init();
virtual void RunTests(const std::string& filter);
private:
std::string TestCreate();
std::string TestConnectFailure();
std::string TestGetHandleFailure();
std::string TestConnectAndPipe();
std::string TestConnectPermissionDenied();
std::string TestConnectPermissionGranted();
std::string TestIsAllowedPermissionDenied();
std::string TestIsAllowedPermissionGranted();
const PPB_BrokerTrusted* broker_interface_;
};
#endif // PPAPI_TESTS_TEST_BROKER_H_

@ -31,7 +31,6 @@ source_set("thunk") {
"ppb_audio_input_api.h",
"ppb_audio_output_api.h",
"ppb_audio_thunk.cc",
"ppb_broker_api.h",
"ppb_browser_font_singleton_api.h",
"ppb_browser_font_trusted_api.h",
"ppb_buffer_api.h",
@ -143,7 +142,6 @@ source_set("thunk") {
sources += [
"ppb_audio_input_dev_thunk.cc",
"ppb_audio_output_dev_thunk.cc",
"ppb_broker_thunk.cc",
"ppb_browser_font_trusted_thunk.cc",
"ppb_buffer_thunk.cc",
"ppb_char_set_thunk.cc",

@ -17,12 +17,6 @@ PROXIED_IFACE(PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1,
PPB_X509Certificate_Private_0_1)
#if !defined(OS_NACL)
PROXIED_API(PPB_Broker)
PROXIED_IFACE(PPB_BROKER_TRUSTED_INTERFACE_0_2,
PPB_BrokerTrusted_0_2)
PROXIED_IFACE(PPB_BROKER_TRUSTED_INTERFACE_0_3,
PPB_BrokerTrusted_0_3)
PROXIED_IFACE(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0,
PPB_BrowserFont_Trusted_1_0)
PROXIED_IFACE(PPB_CHARSET_TRUSTED_INTERFACE_1_0,

@ -1,44 +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.
#ifndef PPAPI_THUNK_PPB_BROKER_API_H_
#define PPAPI_THUNK_PPB_BROKER_API_H_
#include "base/memory/ref_counted.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/shared_impl/singleton_resource_id.h"
namespace ppapi {
class TrackedCallback;
namespace thunk {
class PPB_Broker_API {
public:
virtual ~PPB_Broker_API() {}
virtual int32_t Connect(scoped_refptr<TrackedCallback> connect_callback) = 0;
virtual int32_t GetHandle(int32_t* handle) = 0;
};
// TODO(raymes): Merge this into PPB_Broker_API when the PPB_Broker proxy is
// refactored to the new resource model. The IsAllowed function should be
// attached to the resource implementing the PPB_Broker_API. However in order to
// implement this quickly, the function is added in a new instance API.
class PPB_Broker_Instance_API {
public:
virtual ~PPB_Broker_Instance_API() {}
virtual PP_Bool IsAllowed() = 0;
static const SingletonResourceID kSingletonResourceID = BROKER_SINGLETON_ID;
};
} // namespace thunk
} // namespace ppapi
#endif // PPAPI_THUNK_PPB_BROKER_API_H_

@ -1,88 +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 <stdint.h>
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_broker_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Resource CreateTrusted(PP_Instance instance) {
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
return enter.functions()->CreateBroker(instance);
}
PP_Bool IsBrokerTrusted(PP_Resource resource) {
EnterResource<PPB_Broker_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
int32_t Connect(PP_Resource resource,
PP_CompletionCallback callback) {
EnterResource<PPB_Broker_API> enter(resource, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->Connect(enter.callback()));
}
int32_t GetHandle(PP_Resource resource, int32_t* handle) {
EnterResource<PPB_Broker_API> enter(resource, true);
if (enter.failed())
return enter.retval();
return enter.object()->GetHandle(handle);
}
PP_Bool IsAllowed(PP_Resource resource) {
// TODO(raymes): This is a hack. See the note in ppb_broker_api.h.
PP_Instance instance = 0;
{
EnterResource<PPB_Broker_API> enter_resource(resource, true);
if (enter_resource.failed())
return PP_FALSE;
instance = enter_resource.resource()->pp_instance();
}
EnterInstanceAPI<PPB_Broker_Instance_API> enter_instance(instance);
if (enter_instance.failed())
return PP_FALSE;
return enter_instance.functions()->IsAllowed();
}
const PPB_BrokerTrusted_0_2 g_ppb_broker_0_2_thunk = {
&CreateTrusted,
&IsBrokerTrusted,
&Connect,
&GetHandle,
};
const PPB_BrokerTrusted_0_3 g_ppb_broker_0_3_thunk = {
&CreateTrusted,
&IsBrokerTrusted,
&Connect,
&GetHandle,
&IsAllowed,
};
} // namespace
const PPB_BrokerTrusted_0_2* GetPPB_BrokerTrusted_0_2_Thunk() {
return &g_ppb_broker_0_2_thunk;
}
const PPB_BrokerTrusted_0_3* GetPPB_BrokerTrusted_0_3_Thunk() {
return &g_ppb_broker_0_3_thunk;
}
} // namespace thunk
} // namespace ppapi

@ -179,7 +179,6 @@ class ResourceCreationAPI {
#if !defined(OS_NACL)
virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0;
virtual PP_Resource CreateAudioOutput(PP_Instance instance) = 0;
virtual PP_Resource CreateBroker(PP_Instance instance) = 0;
virtual PP_Resource CreateBrowserFont(
PP_Instance instance,
const PP_BrowserFont_Trusted_Description* description) = 0;

@ -178,8 +178,6 @@ SandboxType SandboxTypeFromCommandLine(const base::CommandLine& command_line) {
return SandboxType::kNoSandbox;
return SandboxType::kGpu;
}
if (process_type == switches::kPpapiBrokerProcess)
return SandboxType::kNoSandbox;
if (process_type == switches::kPpapiPluginProcess)
return SandboxType::kPpapi;

@ -134,19 +134,6 @@ TEST(SandboxTypeTest, GPU) {
EXPECT_EQ(SandboxType::kNoSandbox, SandboxTypeFromCommandLine(command_line));
}
TEST(SandboxTypeTest, PPAPIBroker) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitchASCII(switches::kProcessType,
switches::kPpapiBrokerProcess);
EXPECT_EQ(SandboxType::kNoSandbox, SandboxTypeFromCommandLine(command_line));
command_line.AppendSwitchASCII(switches::kServiceSandboxType, "network");
EXPECT_EQ(SandboxType::kNoSandbox, SandboxTypeFromCommandLine(command_line));
command_line.AppendSwitch(switches::kNoSandbox);
EXPECT_EQ(SandboxType::kNoSandbox, SandboxTypeFromCommandLine(command_line));
}
TEST(SandboxTypeTest, PPAPIPlugin) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitchASCII(switches::kProcessType,

@ -114,7 +114,6 @@ const char kProcessType[] = "type";
const char kGpuProcess[] = "gpu-process";
const char kNaClBrokerProcess[] = "nacl-broker";
const char kNaClLoaderProcess[] = "nacl-loader";
const char kPpapiBrokerProcess[] = "ppapi-broker";
const char kPpapiPluginProcess[] = "ppapi";
const char kRendererProcess[] = "renderer";
const char kUtilityProcess[] = "utility";

@ -71,7 +71,6 @@ SANDBOX_POLICY_EXPORT extern const char kProcessType[];
SANDBOX_POLICY_EXPORT extern const char kGpuProcess[];
SANDBOX_POLICY_EXPORT extern const char kNaClBrokerProcess[];
SANDBOX_POLICY_EXPORT extern const char kNaClLoaderProcess[];
SANDBOX_POLICY_EXPORT extern const char kPpapiBrokerProcess[];
SANDBOX_POLICY_EXPORT extern const char kPpapiPluginProcess[];
SANDBOX_POLICY_EXPORT extern const char kRendererProcess[];
SANDBOX_POLICY_EXPORT extern const char kUtilityProcess[];