summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_npapi.cc
diff options
context:
space:
mode:
authortyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 03:38:29 +0000
committertyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 03:38:29 +0000
commit3ffe71e020ea8e3597c2835f1ba0ebb8fb85ab9e (patch)
treefe9ac76dc74f86b0b9fbe803488ac1a9276e26f5 /chrome_frame/chrome_frame_npapi.cc
parentd5a49e5ad3e6eb962cc026c9fd5c945f89ea9b0c (diff)
downloadchromium_src-3ffe71e020ea8e3597c2835f1ba0ebb8fb85ab9e.zip
chromium_src-3ffe71e020ea8e3597c2835f1ba0ebb8fb85ab9e.tar.gz
chromium_src-3ffe71e020ea8e3597c2835f1ba0ebb8fb85ab9e.tar.bz2
Reason:
Linux Builder (ChromiumOS) failed. http://chrome-buildbot.corp.google.com:8010/builders/Linux%20Builder%20(ChromiumOS)/builds/2050/steps/compile/logs/stdio Please add changes to external_cookie_handler_unittest.cc no to break compilation and reland? ---- Revert 35769 - Deleting cookies by setting the expires attribute on them with an empty value would not work in ChromeFrame with the host network stack enabled. When we receive a response in the host browser (IE) we send over the response headers which include the SetCookie header and a list of cookies retreived via the InternetGetCookie API. We call this API to retrieve the persistent cookies and send them over to Chrome. However this API returns session cookies as well as persistent cookies. There is no documented way to return only persistent cookies from IE. As a result we would end up setting duplicate cookies in Chrome, which caused this issu.e. To workaround this issue when we receive the response in the url request automation job which handles ChromeFrame network requests, we strip out duplicate cookies sent via InternetGetCookie. When a script deletes a cookie we now handle it correctly in IE and set the data to an empty string. However this does not delete the cookie. When such cookies show up in Chrome, we strip them out as well. Fixes bug http://code.google.com/p/chromium/issues/detail?id=30786 The changes to chrome_frame_npapi.cc/.h are to move the NPAPI functions to the chrome_frame namespace as they conflict with similar functions in NACL. Added the DeleteCookie function to the CookieStore interface, which I think missed out by oversight. Bug=30786 Test=Covered by ChromeFrame unit tests. I also added a unit test to test the newly added URLRequestAutomationJob::IsCookiePresentInCookieHeader function Review URL: http://codereview.chromium.org/518054 TBR=ananta@chromium.org Review URL: http://codereview.chromium.org/517070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_npapi.cc')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc150
1 files changed, 150 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index 2dd3145..d3e1f91 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -85,6 +85,8 @@ void ChromeFrameNPAPI::CompileAsserts() {
you_must_add_both_plugin_property_and_name);
}
+static const int kMaxBytesForPluginConsumption = 0x7FFFFFFF;
+
static const char kPluginSrcAttribute[] = "src";
static const char kPluginForceFullPageAttribute[] = "force_full_page";
static const char kPluginOnloadAttribute[] = "onload";
@@ -109,6 +111,154 @@ static const char kPluginChromeFunctionsAutomatedAttribute[] =
// If chrome network stack is to be used
static const char kPluginUseChromeNetwork[] = "usechromenetwork";
+
+NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData* saved) {
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj =
+ reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
+ npapi::CreateObject(instance, ChromeFrameNPAPI::PluginClass()));
+ DCHECK(chrome_frame_npapi_obj != NULL);
+
+ ChromeFrameNPAPI* plugin_instance =
+ chrome_frame_npapi_obj->chrome_frame_plugin_instance;
+ DCHECK(plugin_instance != NULL);
+
+ // Note that we MUST set instance->pdata BEFORE calling Initialize. This is
+ // because Initialize can call back into the NPAPI host which will need the
+ // pdata field to be set.
+ chrome_frame_npapi_obj->chrome_frame_plugin_instance =
+ plugin_instance;
+ instance->pdata = chrome_frame_npapi_obj;
+
+ bool init = plugin_instance->Initialize(plugin_type, instance,
+ mode, argc, argn, argv);
+ DCHECK(init);
+
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_Destroy(NPP instance, NPSavedData** save) {
+ // Takes ownership and releases the object at the end of scope.
+ ScopedNpObject<ChromeFrameNPAPI::ChromeFrameNPObject> chrome_frame_npapi_obj(
+ reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
+ instance->pdata));
+
+ if (chrome_frame_npapi_obj.get()) {
+ ChromeFrameNPAPI* plugin_instance =
+ ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
+
+ plugin_instance->Uninitialize();
+ instance->pdata = NULL;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_SetWindow(NPP instance, NPWindow* window_info) {
+ if (window_info == NULL) {
+ NOTREACHED();
+ return NPERR_GENERIC_ERROR;
+ }
+
+ ChromeFrameNPAPI* plugin_instance =
+ ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
+
+ if (plugin_instance == NULL) {
+ return NPERR_INVALID_INSTANCE_ERROR;
+ }
+
+ plugin_instance->SetWindow(window_info);
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stream_type) {
+ NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest(
+ instance, stream->notifyData);
+ if (url_request) {
+ if (!url_request->OnStreamCreated(type, stream))
+ return NPERR_GENERIC_ERROR;
+ }
+
+ // We need to return the requested stream mode if we are returning a success
+ // code. If we don't do this it causes Opera to blow up.
+ *stream_type = NP_NORMAL;
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
+ NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest(
+ instance, stream->notifyData);
+ if (url_request) {
+ url_request->OnStreamDestroyed(reason);
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
+ if (variable == NPPVpluginScriptableNPObject) {
+ void** plugin = reinterpret_cast<void**>(value);
+ ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj =
+ reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
+ instance->pdata);
+ // Return value is expected to be retained
+ npapi::RetainObject(reinterpret_cast<NPObject*>(chrome_frame_npapi_obj));
+ *plugin = chrome_frame_npapi_obj;
+ return NPERR_NO_ERROR;
+ }
+ return NPERR_GENERIC_ERROR;
+}
+
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
+ return NPERR_GENERIC_ERROR;
+}
+
+int32 NPP_WriteReady(NPP instance, NPStream* stream) {
+ NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest(
+ instance, stream->notifyData);
+ if (url_request) {
+ return url_request->OnWriteReady();
+ }
+
+ return kMaxBytesForPluginConsumption;
+}
+
+int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
+ void* buffer) {
+ NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest(
+ instance, stream->notifyData);
+ if (url_request) {
+ return url_request->OnWrite(buffer, len);
+ }
+
+ return len;
+}
+
+void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
+ void* notifyData) {
+ ChromeFrameNPAPI* plugin_instance =
+ ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
+ if (plugin_instance) {
+ plugin_instance->UrlNotify(url, reason, notifyData);
+ }
+}
+
+void NPP_Print(NPP instance, NPPrint* print_info) {
+ ChromeFrameNPAPI* plugin_instance =
+ ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
+
+ if (plugin_instance == NULL) {
+ NOTREACHED();
+ return;
+ }
+
+ plugin_instance->Print(print_info);
+}
+
// ChromeFrameNPAPI member defines.
// TODO(tommi): remove ignore_setfocus_ since that's not how focus is