summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorgregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:46:27 +0000
committergregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:46:27 +0000
commitea5ac0e47d18753dbe971a35cce7f657ba64bae8 (patch)
tree54713ad26e136bbb9b0bf0062229092c537df533 /webkit/glue
parenteb4035b0048a7c9e3eeae7e189161f0cfbf3db22 (diff)
downloadchromium_src-ea5ac0e47d18753dbe971a35cce7f657ba64bae8.zip
chromium_src-ea5ac0e47d18753dbe971a35cce7f657ba64bae8.tar.gz
chromium_src-ea5ac0e47d18753dbe971a35cce7f657ba64bae8.tar.bz2
This is a copy of http://codereview.chromium.org/153002/show
First step towards NaCl-Chrome integration:1. NaCl plugin becomes a built-in plugin in Chrome and runs in the renderer process.2. Most of the changes are related to launching the NaCl process (that loads and runs the NaCl module) and establishing the initial communication between that process and the NaCl plugin.3. This CL relies on another CL that contains the changes on the Native Client side: http://codereview.chromium.org/1501904. Command line flag "--internal-nacl" is required to enable the built-in NaCl plugin.5. NaCl still cannot run in Chrome sandbox, so the "--no-sandbox" flag is also required TBR=bradnelson Review URL: http://codereview.chromium.org/207025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/plugin_lib.h2
-rw-r--r--webkit/glue/plugins/plugin_list.cc43
-rw-r--r--webkit/glue/plugins/plugin_list.h16
-rw-r--r--webkit/glue/plugins/plugin_list_linux.cc4
-rw-r--r--webkit/glue/plugins/plugin_list_mac.mm4
-rw-r--r--webkit/glue/plugins/plugin_list_win.cc4
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h3
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_win.cc54
8 files changed, 99 insertions, 31 deletions
diff --git a/webkit/glue/plugins/plugin_lib.h b/webkit/glue/plugins/plugin_lib.h
index ed523c12..a5de7fe 100644
--- a/webkit/glue/plugins/plugin_lib.h
+++ b/webkit/glue/plugins/plugin_lib.h
@@ -61,6 +61,8 @@ class PluginLib : public base::RefCounted<PluginLib> {
// supports.
const WebPluginInfo& plugin_info() { return web_plugin_info_; }
+ bool internal() { return internal_; }
+
//
// NPAPI functions
//
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index 69315b2..3adb0eb 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -15,6 +15,8 @@
#include "webkit/glue/webkit_glue.h"
#include "googleurl/src/gurl.h"
+#define kNpGoogleNaClPlugin (FILE_PATH_LITERAL("npgooglenaclplugin"))
+
namespace NPAPI {
base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED);
@@ -113,7 +115,8 @@ bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
return true;
}
-PluginList::PluginList() : plugins_loaded_(false) {
+PluginList::PluginList() : plugins_loaded_(false),
+ use_internal_nacl_(false) {
PlatformInit();
#if defined(OS_WIN)
@@ -168,6 +171,10 @@ void PluginList::LoadPlugins(bool refresh) {
LoadPluginsFromDir(directories_to_scan[i], &new_plugins);
}
+ if (use_internal_nacl_) {
+ LoadPlugin(FilePath(kNaClPluginLibraryName), &new_plugins);
+ }
+
if (webkit_glue::IsDefaultPluginEnabled())
LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins);
@@ -209,6 +216,20 @@ void PluginList::LoadPlugin(const FilePath &path,
plugins->push_back(plugin_info);
}
+bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
+ std::vector<WebPluginInfo>* plugins) {
+ FilePath::StringType filename =
+ StringToLowerASCII(info.path.BaseName().value());
+
+ // Don't load the external version of NaCl when we need to use
+ // the internal one.
+ if (use_internal_nacl_) {
+ if (std::wstring::npos != filename.find(kNpGoogleNaClPlugin))
+ return false;
+ }
+ return PlatformShouldLoadPlugin(info, plugins);
+}
+
bool PluginList::FindPlugin(const std::string& mime_type,
bool allow_wildcard,
WebPluginInfo* info) {
@@ -327,4 +348,24 @@ void PluginList::Shutdown() {
// TODO
}
+// static
+void PluginList::UseInternalNaCl(PluginEntryPoints* entry_points) {
+ // We access the singleton directly, and not through Singleton(), since
+ // we don't want LoadPlugins() to be called.
+ g_singleton.Pointer()->use_internal_nacl_ = true;
+
+ const NPAPI::PluginVersionInfo nacl_plugin_info = {
+ FilePath(kNaClPluginLibraryName),
+ L"Native Client",
+ L"Statically linked NaCl",
+ L"1, 0, 0, 1",
+ L"application/x-nacl-srpc",
+ L"",
+ L"",
+ *entry_points
+ };
+
+ Singleton()->RegisterInternalPlugin(nacl_plugin_info);
+}
+
} // namespace NPAPI
diff --git a/webkit/glue/plugins/plugin_list.h b/webkit/glue/plugins/plugin_list.h
index 7fc2b58..3840682 100644
--- a/webkit/glue/plugins/plugin_list.h
+++ b/webkit/glue/plugins/plugin_list.h
@@ -29,6 +29,7 @@ namespace NPAPI
#define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin")
#define kGearsPluginLibraryName FILE_PATH_LITERAL("gears")
+#define kNaClPluginLibraryName FILE_PATH_LITERAL("internal_nacl")
class PluginInstance;
@@ -105,6 +106,13 @@ class PluginList {
static bool CreateWebPluginInfo(const PluginVersionInfo& pvi,
WebPluginInfo* info);
+ // Set NativeClient plugin mode (avoid loading both the built-in and
+ // the external version of the plugin). The arguments provide pointers
+ // to NaCl plugin entry points - the functions are not referenced directly
+ // from this class to avoid introducing dependency between Webkit glue
+ // library and NaCl code.
+ static void UseInternalNaCl(PluginEntryPoints* entry_points);
+
// Shutdown all plugins. Should be called at process teardown.
void Shutdown();
@@ -148,6 +156,11 @@ class PluginList {
bool ShouldLoadPlugin(const WebPluginInfo& info,
std::vector<WebPluginInfo>* plugins);
+ // Returns true if we should load the given plugin, or false otherwise.
+ // This function is platform-specific and is called from ShouldLoadPlugin.
+ bool PlatformShouldLoadPlugin(const WebPluginInfo& info,
+ std::vector<WebPluginInfo>* plugins);
+
// Find a plugin by mime type.
// The allow_wildcard parameter controls whether this function returns
// plugins which support wildcard mime types (* as the mime type)
@@ -212,6 +225,9 @@ class PluginList {
// Holds information about internal plugins.
std::vector<PluginVersionInfo> internal_plugins_;
+ // true if we should use our internal Native Client plugin
+ bool use_internal_nacl_;
+
// Need synchronization for the above members since this object can be
// accessed on multiple threads.
Lock lock_;
diff --git a/webkit/glue/plugins/plugin_list_linux.cc b/webkit/glue/plugins/plugin_list_linux.cc
index 4f72ab1..cdfa628 100644
--- a/webkit/glue/plugins/plugin_list_linux.cc
+++ b/webkit/glue/plugins/plugin_list_linux.cc
@@ -165,8 +165,8 @@ void PluginList::LoadPluginsFromDir(const FilePath& path,
}
-bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
- std::vector<WebPluginInfo>* plugins) {
+bool PluginList::PlatformShouldLoadPlugin(const WebPluginInfo& info,
+ std::vector<WebPluginInfo>* plugins) {
if (DebugPluginLoading()) {
LOG(ERROR) << "Considering " << info.path.value()
<< " (" << info.name << ")";
diff --git a/webkit/glue/plugins/plugin_list_mac.mm b/webkit/glue/plugins/plugin_list_mac.mm
index c470c5a..ce4f2a1 100644
--- a/webkit/glue/plugins/plugin_list_mac.mm
+++ b/webkit/glue/plugins/plugin_list_mac.mm
@@ -67,8 +67,8 @@ void PluginList::LoadPluginsFromDir(const FilePath &path,
}
}
-bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
- std::vector<WebPluginInfo>* plugins) {
+bool PluginList::PlatformShouldLoadPlugin(const WebPluginInfo& info,
+ std::vector<WebPluginInfo>* plugins) {
// The Gears plugin is Safari-specific, and causes crashes, so don't load it.
for (std::vector<WebPluginMimeType>::const_iterator i =
info.mime_types.begin(); i != info.mime_types.end(); ++i) {
diff --git a/webkit/glue/plugins/plugin_list_win.cc b/webkit/glue/plugins/plugin_list_win.cc
index 9873691..4360ab6 100644
--- a/webkit/glue/plugins/plugin_list_win.cc
+++ b/webkit/glue/plugins/plugin_list_win.cc
@@ -262,8 +262,8 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) {
return false;
}
-bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
- std::vector<WebPluginInfo>* plugins) {
+bool PluginList::PlatformShouldLoadPlugin(const WebPluginInfo& info,
+ std::vector<WebPluginInfo>* plugins) {
// Version check
for (size_t i = 0; i < plugins->size(); ++i) {
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 6d53339..0641093 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -43,7 +43,8 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
PLUGIN_QUIRK_WINDOWLESS_OFFSET_WINDOW_TO_DRAW = 256, // Linux
PLUGIN_QUIRK_WINDOWLESS_INVALIDATE_AFTER_SET_WINDOW = 512, // Linux
PLUGIN_QUIRK_NO_WINDOWLESS = 1024, // Windows
- PLUGIN_QUIRK_PATCH_REGENUMKEYEXW = 2048, // Windows
+ PLUGIN_QUIRK_DONT_CREATE_DUMMY_WINDOW = 2048, // Native Client
+ PLUGIN_QUIRK_PATCH_REGENUMKEYEXW = 4096, // Windows
};
static WebPluginDelegateImpl* Create(const FilePath& filename,
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
index 1f13cf8..25f9fa0 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc
@@ -298,6 +298,9 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
// Explanation for this quirk can be found in
// WebPluginDelegateImpl::Initialize.
quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
+ } else if (instance_->mime_type() == "application/x-nacl-srpc") {
+ // NaCl plugin runs in the sandbox - it cannot use the hwnd
+ quirks_ |= PLUGIN_QUIRK_DONT_CREATE_DUMMY_WINDOW;
}
}
@@ -326,35 +329,40 @@ void WebPluginDelegateImpl::PluginDestroyed() {
void WebPluginDelegateImpl::PlatformInitialize() {
plugin_->SetWindow(windowed_handle_);
- if (windowless_) {
+
+ if (windowless_ && !(quirks_ & PLUGIN_QUIRK_DONT_CREATE_DUMMY_WINDOW)) {
CreateDummyWindowForActivation();
handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL);
plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_);
}
- // Windowless plugins call the WindowFromPoint API and passes the result of
- // that to the TrackPopupMenu API call as the owner window. This causes the
- // API to fail as the API expects the window handle to live on the same thread
- // as the caller. It works in the other browsers as the plugin lives on the
- // browser thread. Our workaround is to intercept the TrackPopupMenu API and
- // replace the window handle with the dummy activation window.
- if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) {
- g_iat_patch_track_popup_menu.Pointer()->Patch(
- GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu",
- WebPluginDelegateImpl::TrackPopupMenuPatch);
- }
+ // We cannot patch internal plugins as they are not shared libraries.
+ if (!instance_->plugin_lib()->internal()) {
+ // Windowless plugins call the WindowFromPoint API and passes the result of
+ // that to the TrackPopupMenu API call as the owner window. This causes the
+ // API to fail as the API expects the window handle to live on the same
+ // thread as the caller. It works in the other browsers as the plugin lives
+ // on the browser thread. Our workaround is to intercept the TrackPopupMenu
+ // API and replace the window handle with the dummy activation window.
+ if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) {
+ g_iat_patch_track_popup_menu.Pointer()->Patch(
+ GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu",
+ WebPluginDelegateImpl::TrackPopupMenuPatch);
+ }
- // Windowless plugins can set cursors by calling the SetCursor API. This
- // works because the thread inputs of the browser UI thread and the plugin
- // thread are attached. We intercept the SetCursor API for windowless plugins
- // and remember the cursor being set. This is shipped over to the browser
- // in the HandleEvent call, which ensures that the cursor does not change
- // when a windowless plugin instance changes the cursor in a background tab.
- if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() &&
- (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) {
- g_iat_patch_set_cursor.Pointer()->Patch(
- GetPluginPath().value().c_str(), "user32.dll", "SetCursor",
- WebPluginDelegateImpl::SetCursorPatch);
+ // Windowless plugins can set cursors by calling the SetCursor API. This
+ // works because the thread inputs of the browser UI thread and the plugin
+ // thread are attached. We intercept the SetCursor API for windowless
+ // plugins and remember the cursor being set. This is shipped over to the
+ // browser in the HandleEvent call, which ensures that the cursor does not
+ // change when a windowless plugin instance changes the cursor
+ // in a background tab.
+ if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() &&
+ (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) {
+ g_iat_patch_set_cursor.Pointer()->Patch(
+ GetPluginPath().value().c_str(), "user32.dll", "SetCursor",
+ WebPluginDelegateImpl::SetCursorPatch);
+ }
}
// On XP, WMP will use its old UI unless a registry key under HKLM has the