summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 19:40:29 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 19:40:29 +0000
commit3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be (patch)
treea4e06819ca0c59659ff8d4538c51bdbfd18e0873 /webkit/glue/plugins
parent096d5cdd6c7b6930ca4a59bb965b5e4f6647f8e0 (diff)
downloadchromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.zip
chromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.tar.gz
chromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.tar.bz2
Expose whether we're in private browsing mode to plugins.I chose to implement this for multi-process mode only and not --single-process or --in-process-plugins, since I wanted to send this data from the browser process, not the renderer (in case it's exploited).
BUG=158 Review URL: http://codereview.chromium.org/52037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/plugin_host.cc8
-rw-r--r--webkit/glue/plugins/test/npapi_test_plugin.vcproj8
-rw-r--r--webkit/glue/plugins/test/plugin_client.cc6
-rw-r--r--webkit/glue/plugins/test/plugin_private_test.cc57
-rw-r--r--webkit/glue/plugins/test/plugin_private_test.h25
5 files changed, 103 insertions, 1 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 2ecb48f..b0c199a 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -781,6 +781,14 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
rv = NPERR_NO_ERROR;
break;
}
+ case NPNVprivateModeBool:
+ {
+ NPBool* private_mode = reinterpret_cast<NPBool*>(value);
+ scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
+ *private_mode = plugin->webplugin()->IsOffTheRecord();
+ rv = NPERR_NO_ERROR;
+ break;
+ }
case default_plugin::kMissingPluginStatusStart +
default_plugin::MISSING_PLUGIN_AVAILABLE:
// fall through
diff --git a/webkit/glue/plugins/test/npapi_test_plugin.vcproj b/webkit/glue/plugins/test/npapi_test_plugin.vcproj
index d52bba8..426885d 100644
--- a/webkit/glue/plugins/test/npapi_test_plugin.vcproj
+++ b/webkit/glue/plugins/test/npapi_test_plugin.vcproj
@@ -239,6 +239,14 @@
>
</File>
<File
+ RelativePath=".\plugin_private_test.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\plugin_private_test.h"
+ >
+ </File>
+ <File
RelativePath=".\plugin_test.cc"
>
</File>
diff --git a/webkit/glue/plugins/test/plugin_client.cc b/webkit/glue/plugins/test/plugin_client.cc
index e9cad4e..7b00e7c 100644
--- a/webkit/glue/plugins/test/plugin_client.cc
+++ b/webkit/glue/plugins/test/plugin_client.cc
@@ -9,11 +9,12 @@
#include "webkit/glue/plugins/test/plugin_execute_script_delete_test.h"
#include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h"
#include "webkit/glue/plugins/test/plugin_geturl_test.h"
+#include "webkit/glue/plugins/test/plugin_javascript_open_popup.h"
#include "webkit/glue/plugins/test/plugin_new_fails_test.h"
+#include "webkit/glue/plugins/test/plugin_private_test.h"
#include "webkit/glue/plugins/test/plugin_npobject_lifetime_test.h"
#include "webkit/glue/plugins/test/plugin_npobject_proxy_test.h"
#include "webkit/glue/plugins/test/plugin_window_size_test.h"
-#include "webkit/glue/plugins/test/plugin_javascript_open_popup.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npruntime.h"
@@ -142,6 +143,9 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
new_test = new NPAPIClient::ExecuteScriptDeleteTest(instance,
NPAPIClient::PluginClient::HostFunctions(), argv[name_index]);
windowless_plugin = true;
+ } else if (base::strcasecmp(argv[name_index], "private") == 0) {
+ new_test = new NPAPIClient::PrivateTest(instance,
+ NPAPIClient::PluginClient::HostFunctions());
} else {
// If we don't have a test case for this, create a
// generic one which basically never fails.
diff --git a/webkit/glue/plugins/test/plugin_private_test.cc b/webkit/glue/plugins/test/plugin_private_test.cc
new file mode 100644
index 0000000..65bbd89
--- /dev/null
+++ b/webkit/glue/plugins/test/plugin_private_test.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 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 "webkit/glue/plugins/test/plugin_private_test.h"
+
+#include "base/basictypes.h"
+#include "base/string_util.h"
+#include "webkit/glue/plugins/test/plugin_client.h"
+
+namespace NPAPIClient {
+
+PrivateTest::PrivateTest(NPP id, NPNetscapeFuncs *host_functions)
+ : PluginTest(id, host_functions) {
+}
+
+NPError PrivateTest::New(uint16 mode, int16 argc,
+ const char* argn[], const char* argv[],
+ NPSavedData* saved) {
+ PluginTest::New(mode, argc, argn, argv, saved);
+
+ NPBool private_mode = 0;
+ NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions();
+ NPError result = browser->getvalue(
+ id(), NPNVprivateModeBool, &private_mode);
+ if (result != NPERR_NO_ERROR) {
+ SetError("Failed to read NPNVprivateModeBool value.");
+ } else {
+ NPIdentifier location = HostFunctions()->getstringidentifier("location");
+ NPIdentifier href = HostFunctions()->getstringidentifier("href");
+
+ NPObject *window_obj = NULL;
+ HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj);
+
+ NPVariant location_var;
+ HostFunctions()->getproperty(id(), window_obj, location, &location_var);
+
+ NPVariant href_var;
+ HostFunctions()->getproperty(id(), NPVARIANT_TO_OBJECT(location_var), href,
+ &href_var);
+ std::string href_str(href_var.value.stringValue.UTF8Characters,
+ href_var.value.stringValue.UTF8Length);
+ bool private_expected = href_str.find("?private") != href_str.npos;
+ if (private_expected != private_expected)
+ SetError("NPNVprivateModeBool returned incorrect value.");
+
+ HostFunctions()->releasevariantvalue(&href_var);
+ HostFunctions()->releasevariantvalue(&location_var);
+ HostFunctions()->releaseobject(window_obj);
+ }
+
+ SignalTestCompleted();
+
+ return NPERR_NO_ERROR;
+}
+
+} // namespace NPAPIClient
diff --git a/webkit/glue/plugins/test/plugin_private_test.h b/webkit/glue/plugins/test/plugin_private_test.h
new file mode 100644
index 0000000..db6b5d1
--- /dev/null
+++ b/webkit/glue/plugins/test/plugin_private_test.h
@@ -0,0 +1,25 @@
+// Copyright (c) 2009 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 WEBKIT_PORT_PLUGINS_TEST_PLUGIN_PRIVATE_TEST_H_
+#define WEBKIT_PORT_PLUGINS_TEST_PLUGIN_PRIVATE_TEST_H_
+
+#include "webkit/glue/plugins/test/plugin_test.h"
+
+namespace NPAPIClient {
+
+// The PluginPrivateTest tests that a plugin can query if the browser is in
+// private browsing mode.
+class PrivateTest : public PluginTest {
+ public:
+ PrivateTest(NPP id, NPNetscapeFuncs *host_functions);
+
+ // Initialize this PluginTest based on the arguments from NPP_New.
+ virtual NPError New(uint16 mode, int16 argc, const char* argn[],
+ const char* argv[], NPSavedData* saved);
+};
+
+} // namespace NPAPIClient
+
+#endif // WEBKIT_PORT_PLUGINS_TEST_PLUGIN_PRIVATE_TEST_H_