Skip to content

Commit

Permalink
Pepper: Remove trusted plugin loadable module.
Browse files Browse the repository at this point in the history
This change links the trusted plugin into the renderer, making it easier for
the trusted plugin to use libraries in Chromium. This removes the
ppGoogleNaClPlugin loadable module file on various platforms.

This is part of a larger effort to remove the "trusted plugin" used to
bootstrap NaCl plugins.

It introduces an "internal_module" interface for setting the value returned by
pp::Module::Get(). This is so that both the trusted plugin and the remoting
plugin can be linked into the renderer. However, I believe this is safe because
the trusted plugin runs in-process and the remoting plugin runs out-of-process.

BUG=394497
R=dmichael@chromium.org, mseaborn@chromium.org, phajdan.jr@chromium.org, thestig@chromium.org, wez@chromium.org

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287071

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287580 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
teravest@chromium.org committed Aug 5, 2014
1 parent 324b3a1 commit 0116711
Show file tree
Hide file tree
Showing 37 changed files with 163 additions and 321 deletions.
1 change: 0 additions & 1 deletion chrome/browser_tests.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
'isolate_dependency_tracked': [
'<(PRODUCT_DIR)/keyboard_resources.pak',
'<(PRODUCT_DIR)/libexif.so',
'<(PRODUCT_DIR)/libppGoogleNaClPluginChrome.so',
'<(PRODUCT_DIR)/nacl_helper',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
'browser/chromeos/login/test/https_forwarder.py',
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
'isolate_dependency_tracked': [
'<(PRODUCT_DIR)/libffmpegsumo.so',
'<(PRODUCT_DIR)/libosmesa.so',
'<(PRODUCT_DIR)/libppGoogleNaClPluginChrome.so',
'<(PRODUCT_DIR)/nacl_helper<(EXECUTABLE_SUFFIX)',
'<(PRODUCT_DIR)/nacl_helper_bootstrap<(EXECUTABLE_SUFFIX)',
],
Expand Down Expand Up @@ -64,7 +63,6 @@
'<(PRODUCT_DIR)/libexif.dll',
'<(PRODUCT_DIR)/nacl64<(EXECUTABLE_SUFFIX)',
'<(PRODUCT_DIR)/osmesa.dll',
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
],
},
}],
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@
['disable_nacl==0', {
'dependencies': [
'<(DEPTH)/components/nacl.gyp:nacl_common',
'<(DEPTH)/ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin',
],
'sources': [
'common/extensions/manifest_handlers/nacl_modules_handler.cc',
Expand Down
3 changes: 0 additions & 3 deletions chrome/chrome_dll_bundle.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@
],
'conditions': [
['disable_nacl!=1', {
'files': [
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.plugin',
],
'conditions': [
['target_arch=="x64"', {
'files': [
Expand Down
1 change: 0 additions & 1 deletion chrome/chrome_installer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@
'<(PRODUCT_DIR)/chrome_sandbox',
'<(PRODUCT_DIR)/libffmpegsumo.so',
'<(PRODUCT_DIR)/libpdf.so',
'<(PRODUCT_DIR)/libppGoogleNaClPluginChrome.so',
'<(PRODUCT_DIR)/xdg-mime',
'<(PRODUCT_DIR)/xdg-settings',
'<(PRODUCT_DIR)/locales/en-US.pak',
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@
],
'dependencies': [
# Runtime dependency.
'../ppapi/native_client/src/trusted/plugin/plugin.gyp:ppGoogleNaClPluginChrome',
'../ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin',
],
'conditions': [
['disable_nacl_untrusted==0', {
Expand Down
1 change: 1 addition & 0 deletions chrome/common/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include_rules = [
"+google_apis/gaia", # For gaia_switches.h
"+grit", # For generated headers
"+media",
"+ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h",
"+ppapi/shared_impl",
"+remoting/client/plugin",
"+webkit/common/user_agent",
Expand Down
46 changes: 28 additions & 18 deletions chrome/common/chrome_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
#include "components/nacl/common/nacl_sandbox_type_mac.h"
#endif

#if !defined(DISABLE_NACL)
#include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
#endif

#if defined(ENABLE_REMOTING)
#include "remoting/client/plugin/pepper_entrypoints.h"
#endif
Expand All @@ -70,6 +74,7 @@ const char kPDFPluginOutOfProcessMimeType[] =
const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_DEV;

#if !defined(DISABLE_NACL)
const char kNaClPluginMimeType[] = "application/x-nacl";
const char kNaClPluginExtension[] = "";
const char kNaClPluginDescription[] = "Native Client Executable";
Expand All @@ -79,6 +84,7 @@ const uint32 kNaClPluginPermissions = ppapi::PERMISSION_PRIVATE |
const char kPnaclPluginMimeType[] = "application/x-pnacl";
const char kPnaclPluginExtension[] = "";
const char kPnaclPluginDescription[] = "Portable Native Client Executable";
#endif // !defined(DISABLE_NACL)

const char kO1DPluginName[] = "Google Talk Plugin Video Renderer";
const char kO1DPluginMimeType[] ="application/o1d";
Expand Down Expand Up @@ -166,30 +172,34 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
}
}

#if !defined(DISABLE_NACL)
// Handle Native Client just like the PDF plugin. This means that it is
// enabled by default for the non-portable case. This allows apps installed
// from the Chrome Web Store to use NaCl even if the command line switch
// isn't set. For other uses of NaCl we check for the command line switch.
static bool skip_nacl_file_check = false;
if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
if (skip_nacl_file_check || base::PathExists(path)) {
content::PepperPluginInfo nacl;
nacl.path = path;
nacl.name = ChromeContentClient::kNaClPluginName;
content::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType,
kNaClPluginExtension,
kNaClPluginDescription);
nacl.mime_types.push_back(nacl_mime_type);
content::WebPluginMimeType pnacl_mime_type(kPnaclPluginMimeType,
kPnaclPluginExtension,
kPnaclPluginDescription);
nacl.mime_types.push_back(pnacl_mime_type);
nacl.permissions = kNaClPluginPermissions;
plugins->push_back(nacl);

skip_nacl_file_check = true;
}
content::PepperPluginInfo nacl;
// The nacl plugin is now built into the Chromium binary.
nacl.is_internal = true;
nacl.path = path;
nacl.name = ChromeContentClient::kNaClPluginName;
content::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType,
kNaClPluginExtension,
kNaClPluginDescription);
nacl.mime_types.push_back(nacl_mime_type);
content::WebPluginMimeType pnacl_mime_type(kPnaclPluginMimeType,
kPnaclPluginExtension,
kPnaclPluginDescription);
nacl.mime_types.push_back(pnacl_mime_type);
nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface;
nacl.internal_entry_points.initialize_module =
nacl_plugin::PPP_InitializeModule;
nacl.internal_entry_points.shutdown_module =
nacl_plugin::PPP_ShutdownModule;
nacl.permissions = kNaClPluginPermissions;
plugins->push_back(nacl);
}
#endif // !defined(DISABLE_NACL)

static bool skip_o1d_file_check = false;
if (PathService::Get(chrome::FILE_O1D_PLUGIN, &path)) {
Expand Down
13 changes: 4 additions & 9 deletions chrome/common/chrome_paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,8 @@ const base::FilePath::CharType kInternalPDFPluginFileName[] =
FILE_PATH_LITERAL("libpdf.so");
#endif

// File name of the internal NaCl plugin on different platforms.
const base::FilePath::CharType kInternalNaClPluginFileName[] =
#if defined(OS_WIN)
FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.dll");
#elif defined(OS_MACOSX)
// TODO(noelallen) Please verify this extention name is correct.
FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.plugin");
#else // Linux and Chrome OS
FILE_PATH_LITERAL("libppGoogleNaClPluginChrome.so");
#endif
FILE_PATH_LITERAL("internal-nacl-plugin");

const base::FilePath::CharType kEffectsPluginFileName[] =
#if defined(OS_WIN)
Expand Down Expand Up @@ -312,6 +304,9 @@ bool PathProvider(int key, base::FilePath* result) {
return false;
cur = cur.Append(kEffectsPluginFileName);
break;
// TODO(teravest): Remove this case once the internal NaCl plugin is gone.
// We currently need a path here to look up whether the plugin is disabled
// and what its permissions are.
case chrome::FILE_NACL_PLUGIN:
if (!GetInternalPluginsDirectory(&cur))
return false;
Expand Down
5 changes: 0 additions & 5 deletions chrome/installer/linux/common/installer.include
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ stage_install_common() {
install -m 644 -s "${BUILDDIR}/lib/libpeerconnection.so" "${STAGEDIR}/${INSTALLDIR}/lib/"
fi

# nacl pepper plugin
if [ -f "${BUILDDIR}/libppGoogleNaClPluginChrome.so" ]; then
install -m 644 -s "${BUILDDIR}/libppGoogleNaClPluginChrome.so" "${STAGEDIR}/${INSTALLDIR}/"
fi

# nacl_helper and nacl_helper_bootstrap
# Don't use "-s" (strip) because this runs binutils "strip", which
# mangles the special ELF program headers of nacl_helper_bootstrap.
Expand Down
2 changes: 0 additions & 2 deletions chrome/installer/mini_installer.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
['disable_nacl==1', {
'inputs!': [
'<(PRODUCT_DIR)/nacl64.exe',
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
'<(PRODUCT_DIR)/nacl_irt_x86_32.nexe',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
],
Expand Down Expand Up @@ -231,7 +230,6 @@
'<(PRODUCT_DIR)/chrome.exe',
'<(PRODUCT_DIR)/chrome.dll',
'<(PRODUCT_DIR)/nacl64.exe',
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
'<(PRODUCT_DIR)/nacl_irt_x86_32.nexe',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
'<(PRODUCT_DIR)/locales/en-US.pak',
Expand Down
1 change: 0 additions & 1 deletion chrome/installer/mini_installer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
'<(PRODUCT_DIR)/chrome.exe',
'<@(chrome_dll_path)',
'<(PRODUCT_DIR)/nacl64.exe',
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
'<(PRODUCT_DIR)/nacl_irt_x86_32.nexe',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
'<(PRODUCT_DIR)/locales/en-US.pak',
Expand Down
1 change: 0 additions & 1 deletion chrome/installer/mini_installer/chrome.release
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ nacl64.exe: %(VersionDir)s\
nacl_irt_x86_32.nexe: %(VersionDir)s\
nacl_irt_x86_64.nexe: %(VersionDir)s\
pdf.dll: %(VersionDir)s\
ppGoogleNaClPluginChrome.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
syzyasan_rtl.dll: %(VersionDir)s\
xinput1_3.dll: %(VersionDir)s\
Expand Down
1 change: 0 additions & 1 deletion chrome/interactive_ui_tests.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
'<(PRODUCT_DIR)/ffmpegsumo.dll',
'<(PRODUCT_DIR)/libEGL.dll',
'<(PRODUCT_DIR)/libGLESv2.dll',
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
'<(PRODUCT_DIR)/osmesa.dll',
],
'isolate_dependency_untracked': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ln -f -s /opt/google/chrome/*.pak "$this_dir/"
ln -f -s /opt/google/chrome/nacl_helper "$this_dir/"
ln -f -s /opt/google/chrome/nacl_helper_bootstrap "$this_dir/"
ln -f -s /opt/google/chrome/nacl_irt_*.nexe "$this_dir/"
ln -f -s /opt/google/chrome/libppGoogleNaClPluginChrome.so "$this_dir/"

# Create links to resources from pyauto_dep.

Expand Down
5 changes: 0 additions & 5 deletions chrome/test/nacl/nacl_browsertest_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ void NaClBrowserTestBase::SetUpCommandLine(base::CommandLine* command_line) {
}

void NaClBrowserTestBase::SetUpOnMainThread() {
// Sanity check.
base::FilePath plugin_lib;
ASSERT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
ASSERT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value();

ASSERT_TRUE(StartTestServer()) << "Cannot start test server.";
}

Expand Down
7 changes: 0 additions & 7 deletions chrome/test/ppapi/ppapi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ void PPAPINaClTest::SetUpCommandLine(base::CommandLine* command_line) {
}

void PPAPINaClTest::SetUpOnMainThread() {
base::FilePath plugin_lib;
EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
EXPECT_TRUE(base::PathExists(plugin_lib));
}

void PPAPINaClTest::RunTest(const std::string& test_case) {
Expand Down Expand Up @@ -464,8 +461,4 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
// The default content setting for the PPAPI broker is ASK. We purposefully
// don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.

base::FilePath plugin_lib;
EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
EXPECT_TRUE(base::PathExists(plugin_lib));
}
4 changes: 0 additions & 4 deletions chrome/tools/build/chromeos/FILES.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ FILES = [
'buildtype': ['dev', 'official'],
},
# Native Client plugin files:
{
'filename': 'libppGoogleNaClPluginChrome.so',
'buildtype': ['dev', 'official'],
},
{
'filename': 'nacl_irt_x86_32.nexe',
'arch': ['32bit'],
Expand Down
4 changes: 0 additions & 4 deletions chrome/tools/build/linux/FILES.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ FILES = [
'buildtype': ['dev', 'official'],
},
# Native Client plugin files:
{
'filename': 'libppGoogleNaClPluginChrome.so',
'buildtype': ['dev', 'official'],
},
{
'filename': 'nacl_irt_x86_32.nexe',
'arch': ['32bit'],
Expand Down
1 change: 0 additions & 1 deletion chrome/tools/build/mac/dump_product_syms
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ SRC_NAMES=(
"crash_report_sender.app"
"exif.so"
"ffmpegsumo.so"
"ppGoogleNaClPluginChrome.plugin"
)

# PDF.plugin is optional. Only include it if present.
Expand Down
10 changes: 0 additions & 10 deletions chrome/tools/build/win/FILES.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,6 @@ FILES = [
'buildtype': ['dev', 'official'],
},
# Native Client plugin files:
{
'filename': 'ppGoogleNaClPluginChrome.dll',
'buildtype': ['dev', 'official'],
'filegroup': ['default', 'symsrc'],
},
{
'filename': 'nacl_irt_x86_32.nexe',
'arch': ['32bit'],
Expand Down Expand Up @@ -702,11 +697,6 @@ FILES = [
'buildtype': ['dev', 'official'],
'archive': 'chrome-win32-syms.zip',
},
{
'filename': 'ppGoogleNaClPluginChrome.dll.pdb',
'buildtype': ['dev', 'official'],
'archive': 'chrome-win32-syms.zip',
},
{
'filename': 'setup.exe.pdb',
'buildtype': ['dev', 'official'],
Expand Down
3 changes: 0 additions & 3 deletions chrome/unit_tests.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
'<(PRODUCT_DIR)/locales/fr.pak',
'<(PRODUCT_DIR)/xdisplaycheck<(EXECUTABLE_SUFFIX)',
],
'isolate_dependency_touched': [
'<(PRODUCT_DIR)/libppGoogleNaClPluginChrome.so',
],
},
}],
['OS=="linux" or OS=="mac" or OS=="win"', {
Expand Down
2 changes: 1 addition & 1 deletion components/nacl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
'../base/base.gyp:base',
'../base/base.gyp:base_static',
'../ipc/ipc.gyp:ipc',
'../ppapi/native_client/src/trusted/plugin/plugin.gyp:ppGoogleNaClPluginChrome',
'../ppapi/ppapi_internal.gyp:ppapi_shared',
'../ppapi/ppapi_internal.gyp:ppapi_ipc',
'../native_client/src/trusted/service_runtime/service_runtime.gyp:sel_main_chrome',
Expand Down Expand Up @@ -183,6 +182,7 @@
],
'dependencies': [
'../content/content.gyp:content_renderer',
'../ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin',
'../third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
'../third_party/WebKit/public/blink.gyp:blink',
],
Expand Down
7 changes: 7 additions & 0 deletions ppapi/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ source_set("ppapi_cpp") {
]
}

source_set("ppapi_internal_module") {
sources = [
"cpp/private/internal_module.cc",
"cpp/private/internal_module.h",
]
}

source_set("ppapi_gles2") {
sources = [
"lib/gl/gles2/gl2ext_ppapi.c",
Expand Down
21 changes: 21 additions & 0 deletions ppapi/cpp/private/internal_module.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2014 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/cpp/module.h"
#include "ppapi/cpp/private/internal_module.h"

namespace pp {
namespace {
static Module* g_module_singleton = NULL;
} // namespace

Module* Module::Get() {
return g_module_singleton;
}

void InternalSetModuleSingleton(Module* module) {
g_module_singleton = module;
}

} // namespace pp
16 changes: 16 additions & 0 deletions ppapi/cpp/private/internal_module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2014 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_CPP_PRIVATE_INTERNAL_MODULE_H_
#define PPAPI_CPP_PRIVATE_INTERNAL_MODULE_H_

namespace pp {
class Module;

// Forcibly sets the value returned by pp::Module::Get(). Do not call this
// function except to support the trusted plugin or the remoting plugin!
void InternalSetModuleSingleton(Module* module);
}

#endif // PPAPI_CPP_PRIVATE_INTERNAL_MODULE_H_
Loading

0 comments on commit 0116711

Please sign in to comment.