summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/activex_shim/activex_shared.cc13
-rw-r--r--webkit/activex_shim/activex_shared.h4
-rw-r--r--webkit/default_plugin/plugin_main.cc32
-rw-r--r--webkit/glue/plugins/plugin_list_win.cc14
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc25
-rw-r--r--webkit/tools/test_shell/plugin_tests.cc28
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc12
7 files changed, 103 insertions, 25 deletions
diff --git a/webkit/activex_shim/activex_shared.cc b/webkit/activex_shim/activex_shared.cc
index c5b06a5..649ce01 100644
--- a/webkit/activex_shim/activex_shared.cc
+++ b/webkit/activex_shim/activex_shared.cc
@@ -225,4 +225,17 @@ bool IsMimeTypeActiveX(const std::string& mimetype) {
LowerCaseEqualsASCII(mimetype, "application/oleobject");
}
+bool GetMimeTypeForClsid(const std::string& clsid, std::string* mime_type) {
+ DCHECK(mime_type != NULL);
+
+ if (!base::strcasecmp(clsid.c_str(),
+ "6BF52A52-394A-11D3-B153-00C04F79FAA6") ||
+ !base::strcasecmp(clsid.c_str(),
+ "22D6F312-B0F6-11D0-94AB-0080C74C7E95")) {
+ *mime_type = "application/x-mplayer2";
+ return true;
+ }
+ return false;
+}
+
} // namespace activex_shim
diff --git a/webkit/activex_shim/activex_shared.h b/webkit/activex_shim/activex_shared.h
index 9b34dc9..062dd8d 100644
--- a/webkit/activex_shim/activex_shared.h
+++ b/webkit/activex_shim/activex_shared.h
@@ -61,6 +61,10 @@ bool IsCodebaseAllowed(const std::string& clsid, const std::string& codebase);
// "application/oleobject"
bool IsMimeTypeActiveX(const std::string& mimetype);
+// Returns the NPAPI mime type for the CLSID passed in. On failure
+// return false
+bool GetMimeTypeForClsid(const std::string& clsid, std::string* mime_type);
+
} // namespace activex_shim
#endif // #ifndef WEBKIT_ACTIVEX_SHIM_ACTIVEX_SHARED_H__
diff --git a/webkit/default_plugin/plugin_main.cc b/webkit/default_plugin/plugin_main.cc
index f23a6f8..b0a24f8 100644
--- a/webkit/default_plugin/plugin_main.cc
+++ b/webkit/default_plugin/plugin_main.cc
@@ -5,6 +5,7 @@
#include "webkit/default_plugin/plugin_main.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "webkit/activex_shim/npp_impl.h"
#include "webkit/default_plugin/plugin_impl.h"
#include "webkit/glue/webkit_glue.h"
@@ -54,6 +55,31 @@ NPError API_CALL NP_Shutdown(void) {
return 0;
}
+namespace {
+// This function is only invoked when the default plugin is invoked
+// with a special mime type application/chromium-test-default-plugin
+void SignalTestResult(NPP instance) {
+ NPObject *window_obj = NULL;
+ g_browser->getvalue(instance, NPNVWindowNPObject, &window_obj);
+ if (!window_obj) {
+ NOTREACHED();
+ return;
+ }
+
+ std::string script = "javascript:onSuccess()";
+ NPString script_string;
+ script_string.UTF8Characters = script.c_str();
+ script_string.UTF8Length =
+ static_cast<unsigned int>(script.length());
+
+ NPVariant result_var;
+ NPError result = g_browser->evaluate(instance, window_obj,
+ &script_string, &result_var);
+ g_browser->releaseobject(window_obj);
+}
+
+} // namespace CHROMIUM_DefaultPluginTest
+
NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
char* argn[], char* argv[], NPSavedData* saved) {
if (instance == NULL)
@@ -63,9 +89,15 @@ NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
// 1. Test-shell
// 2. The plugin is running in the renderer process.
if (webkit_glue::IsPluginRunningInRendererProcess()) {
+ if (!base::strcasecmp(plugin_type,
+ "application/chromium-test-default-plugin")) {
+ SignalTestResult(instance);
+ return NPERR_NO_ERROR;
+ }
return NPERR_GENERIC_ERROR;
}
+
PluginInstallerImpl* plugin_impl = new PluginInstallerImpl(mode);
plugin_impl->Initialize(GetCurrentModuleHandle(), instance, plugin_type, argc,
argn, argv);
diff --git a/webkit/glue/plugins/plugin_list_win.cc b/webkit/glue/plugins/plugin_list_win.cc
index 02b1b94..b91c54d 100644
--- a/webkit/glue/plugins/plugin_list_win.cc
+++ b/webkit/glue/plugins/plugin_list_win.cc
@@ -211,20 +211,6 @@ void PluginList::PlatformInit() {
const PluginVersionInfo builtin_plugins[] = {
{
- FilePath(kActiveXShimFileName),
- L"ActiveX Plug-in",
- L"ActiveX Plug-in provides a shim to support ActiveX controls",
- L"1, 0, 0, 1",
- L"application/x-oleobject|application/oleobject",
- L"*|*",
- L"",
- {
- activex_shim::ActiveX_Shim_NP_GetEntryPoints,
- activex_shim::ActiveX_Shim_NP_Initialize,
- activex_shim::ActiveX_Shim_NP_Shutdown
- }
- },
- {
FilePath(kActiveXShimFileNameForMediaPlayer),
kActiveXShimFileNameForMediaPlayer,
L"Windows Media Player",
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 29407d9..fb44f4d 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -1447,16 +1447,21 @@ Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, // TODO(erikkay)
webkit_glue::CStringToStdString(param_values[i].latin1()));
}
}
- // We only allowed specific ActiveX controls to run from certain websites.
- if (!activex_shim::IsActiveXAllowed(clsid, url))
- return NULL;
- // We need to pass the combined clsid + version to PluginsList, so that it
- // would detect if the requested version is installed. If not, it needs
- // to use the default plugin to update the control.
- if (!version.empty())
- combined_clsid = clsid + "#" + version;
- else
- combined_clsid = clsid;
+
+ // Attempt to map this clsid to a known NPAPI mime type if possible, failing
+ // which we attempt to load the activex shim for the clsid.
+ if (!activex_shim::GetMimeTypeForClsid(clsid, &my_mime_type)) {
+ // We only allowed specific ActiveX controls to run from certain websites.
+ if (!activex_shim::IsActiveXAllowed(clsid, url))
+ return NULL;
+ // We need to pass the combined clsid + version to PluginsList, so that it
+ // would detect if the requested version is installed. If not, it needs
+ // to use the default plugin to update the control.
+ if (!version.empty())
+ combined_clsid = clsid + "#" + version;
+ else
+ combined_clsid = clsid;
+ }
}
#endif
diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc
index d5ac5ca..f2ad349 100644
--- a/webkit/tools/test_shell/plugin_tests.cc
+++ b/webkit/tools/test_shell/plugin_tests.cc
@@ -95,3 +95,31 @@ TEST_F(PluginTest, Refresh) {
DeleteTestPlugin();
}
+
+TEST_F(PluginTest, DefaultPluginLoadTest) {
+ std::string html = "\
+ <div id='result'>Test running....</div>\
+ <script>\
+ function onSuccess() {\
+ var result = document.getElementById('result');\
+ result.innerHTML = 'DONE';\
+ }\
+ </script>\
+ <DIV ID=PluginDiv>\
+ <object classid=\"clsid:9E8BC6CE-AF35-400c-ABF6-A3F746A1871D\">\
+ <embed type=\"application/chromium-test-default-plugin\"\
+ mode=\"np_embed\"\
+ ></embed>\
+ </object>\
+ </DIV>\
+ ";
+
+ test_shell_->webView()->GetMainFrame()->LoadHTMLString(
+ html, GURL("about:blank"));
+ test_shell_->WaitTestFinished();
+
+ std::wstring text;
+ test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text);
+
+ ASSERT_EQ(true, StartsWith(text, L"DONE", true));
+}
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 6ce2509..b072d21 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -7,7 +7,7 @@
#include "webkit/tools/test_shell/test_shell.h"
-
+#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/debug_on_start.h"
#include "base/file_path.h"
@@ -614,6 +614,16 @@ bool GetPluginFinderURL(std::string* plugin_finder_url) {
#if !defined(LINUX2)
bool IsDefaultPluginEnabled() {
+#if defined(OS_WIN)
+ FilePath exe_path;
+
+ if (PathService::Get(base::FILE_EXE, &exe_path)) {
+ std::wstring exe_name = file_util::GetFilenameFromPath(
+ exe_path.ToWStringHack());
+ if (StartsWith(exe_name, L"test_shell_tests", false))
+ return true;
+ }
+#endif // OS_WIN
return false;
}