summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 00:37:22 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 00:37:22 +0000
commit96171cb12c21ded18210e72b2a240f641cfeafff (patch)
tree093f31cb7403676e364518b2849e3172e7395ad8 /chrome_frame
parent1c53a1f1fa5074d24e7324e76e55ce57bb1c33b4 (diff)
downloadchromium_src-96171cb12c21ded18210e72b2a240f641cfeafff.zip
chromium_src-96171cb12c21ded18210e72b2a240f641cfeafff.tar.gz
chromium_src-96171cb12c21ded18210e72b2a240f641cfeafff.tar.bz2
Add support in the ChromeFrame NPAPI plugin for receiving URL redirect notifications. This
is basically implementing the NPP_URLRedirectNotify plugin function and invoking the browser end function NPN_URLRedirectResponse indicating whether the redirect is to be followed or not. The ChromeFrame NPAPI implementation always disallows url redirects from the plugin and instead expects Chrome to follow the redirect. Tested this with a Firefox 4 nightly build. Currently this does not work as expected because of a bug in Firefox where it invokes the NPP_URLRedirectNotify function with the original URL instead of the redirected URL. This is tracked by mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=625164 BUG=69419 TEST=none. Will add a test for this once we have a builder with a working version of Firefox 4. Review URL: http://codereview.chromium.org/6223003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71271 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc12
-rw-r--r--chrome_frame/chrome_frame_npapi.h1
-rw-r--r--chrome_frame/chrome_frame_npapi_entrypoints.cc16
-rw-r--r--chrome_frame/chrome_frame_npapi_entrypoints.h3
-rw-r--r--chrome_frame/np_browser_functions.cc11
-rw-r--r--chrome_frame/np_browser_functions.h1
-rw-r--r--chrome_frame/npapi_url_request.cc12
-rw-r--r--chrome_frame/npapi_url_request.h1
8 files changed, 54 insertions, 3 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index 5716801..b503e35 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -1509,3 +1509,15 @@ int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len,
NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) {
return url_fetcher_.DestroyStream(stream, reason);
}
+
+void ChromeFrameNPAPI::URLRedirectNotify(const char* url, int status,
+ void* notify_data) {
+ DVLOG(1) << __FUNCTION__
+ << "Received redirect notification for url:"
+ << url;
+ // Inform chrome about the redirect and disallow the current redirect
+ // attempt.
+ url_fetcher_.UrlRedirectNotify(url, status, notify_data);
+ npapi::URLRedirectResponse(instance_, notify_data, false);
+}
+
diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h
index 1d3ac300..ba36b99 100644
--- a/chrome_frame/chrome_frame_npapi.h
+++ b/chrome_frame/chrome_frame_npapi.h
@@ -74,6 +74,7 @@ class ChromeFrameNPAPI
NPError DestroyStream(NPStream* stream, NPReason reason);
void Print(NPPrint* print_info);
+ void URLRedirectNotify(const char* url, int status, void* notify_data);
// NPObject functions, which ensure that the plugin object is scriptable.
static bool HasMethod(NPObject* obj, NPIdentifier name);
diff --git a/chrome_frame/chrome_frame_npapi_entrypoints.cc b/chrome_frame/chrome_frame_npapi_entrypoints.cc
index 267aba5..17eba60 100644
--- a/chrome_frame/chrome_frame_npapi_entrypoints.cc
+++ b/chrome_frame/chrome_frame_npapi_entrypoints.cc
@@ -37,6 +37,7 @@ NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
plugin_funcs->urlnotify = chrome_frame::NPP_URLNotify;
plugin_funcs->getvalue = chrome_frame::NPP_GetValue;
plugin_funcs->setvalue = chrome_frame::NPP_SetValue;
+ plugin_funcs->urlredirectnotify = chrome_frame::NPP_URLRedirectNotify;
return NPERR_NO_ERROR;
}
@@ -194,11 +195,24 @@ void NPP_Print(NPP instance, NPPrint* print_info) {
ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
if (plugin_instance == NULL) {
- NOTREACHED();
+ NOTREACHED() << "Failed to find plugin instance";
return;
}
plugin_instance->Print(print_info);
}
+void NPP_URLRedirectNotify(NPP instance, const char* url, int status,
+ void* notify_data) {
+ ChromeFrameNPAPI* plugin_instance =
+ ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
+
+ if (plugin_instance == NULL) {
+ NOTREACHED() << "Failed to find plugin instance";
+ npapi::URLRedirectResponse(instance, notify_data, false);
+ return;
+ }
+ plugin_instance->URLRedirectNotify(url, status, notify_data);
+}
+
} // namespace chrome_frame
diff --git a/chrome_frame/chrome_frame_npapi_entrypoints.h b/chrome_frame/chrome_frame_npapi_entrypoints.h
index 00b34fd..e3925a8 100644
--- a/chrome_frame/chrome_frame_npapi_entrypoints.h
+++ b/chrome_frame/chrome_frame_npapi_entrypoints.h
@@ -33,7 +33,8 @@ void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
void* notifyData);
void NPP_Print(NPP instance, NPPrint* print_info);
-
+void NPP_URLRedirectNotify(NPP instance, const char* url, int status,
+ void* notify_data);
} // namespace chrome_frame
#endif // CHROME_FRAME_CHROME_FRAME_NPAPI_ENTRYPOINTS_H_
diff --git a/chrome_frame/np_browser_functions.cc b/chrome_frame/np_browser_functions.cc
index 2646d24..02b89ac 100644
--- a/chrome_frame/np_browser_functions.cc
+++ b/chrome_frame/np_browser_functions.cc
@@ -75,6 +75,7 @@ NPN_ConstructProcPtr g_construct = NULL;
NPN_GetValueForURLPtr g_getvalueforurl = NULL;
NPN_SetValueForURLPtr g_setvalueforurl = NULL;
NPN_GetAuthenticationInfoPtr g_getauthenticationinfo = NULL;
+NPN_URLRedirectResponsePtr g_urlredirectresponse = NULL;
// Must be called prior to calling any of the browser functions below.
void InitializeBrowserFunctions(NPNetscapeFuncs* functions) {
@@ -128,6 +129,7 @@ void InitializeBrowserFunctions(NPNetscapeFuncs* functions) {
g_enumerate = functions->enumerate;
g_pluginthreadasynccall = functions->pluginthreadasynccall;
g_construct = functions->construct;
+ g_urlredirectresponse = functions->urlredirectresponse;
if (g_version.v.minor >= NPVERS_HAS_URL_AND_AUTH_INFO) {
g_getvalueforurl = functions->getvalueforurl;
@@ -492,6 +494,14 @@ NPError GetAuthenticationInfo(NPP instance, const char* protocol,
realm, username, ulen, password, plen);
}
+void URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) {
+ if (!g_urlredirectresponse) {
+ NOTREACHED() << "Unexpected call to NPN_URLRedirectResponse";
+ return;
+ }
+ return g_urlredirectresponse(instance, notify_data, allow);
+}
+
std::string StringFromIdentifier(NPIdentifier identifier) {
std::string ret;
NPUTF8* utf8 = UTF8FromIdentifier(identifier);
@@ -517,4 +527,3 @@ void AllocateStringVariant(const std::string& str, NPVariant* var) {
NULL_TO_NPVARIANT(*var);
}
}
-
diff --git a/chrome_frame/np_browser_functions.h b/chrome_frame/np_browser_functions.h
index b2dbd74..64344aa 100644
--- a/chrome_frame/np_browser_functions.h
+++ b/chrome_frame/np_browser_functions.h
@@ -140,6 +140,7 @@ NPError PopUpContextMenu(NPP instance, NPMenu* menu);
NPBool ConvertPoint(NPP instance, double sourceX, double sourceY,
NPCoordinateSpace sourceSpace, double *destX,
double *destY, NPCoordinateSpace destSpace);
+void URLRedirectResponse(NPP instance, void* notify_data, NPBool allow);
// Helper routine that wraps UTF8FromIdentifier to convert a string identifier
// to an STL string. It's not super efficient since it could possibly do two
diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc
index 0a28cdd..0596f84 100644
--- a/chrome_frame/npapi_url_request.cc
+++ b/chrome_frame/npapi_url_request.cc
@@ -418,6 +418,18 @@ void NPAPIUrlRequestManager::UrlNotify(const char* url, NPReason reason,
}
}
+void NPAPIUrlRequestManager::UrlRedirectNotify(const char* url, int status,
+ void* notify_data) {
+ NPAPIUrlRequest* request = RequestFromNotifyData(notify_data);
+ if (request) {
+ delegate_->OnResponseStarted(request->id(), "", "", 0, base::Time(),
+ url, status);
+ } else {
+ NOTREACHED() << "Received unexpected redirect notification for url:"
+ << url;
+ }
+}
+
scoped_refptr<NPAPIUrlRequest> NPAPIUrlRequestManager::LookupRequest(
int request_id) {
RequestMap::iterator index = request_map_.find(request_id);
diff --git a/chrome_frame/npapi_url_request.h b/chrome_frame/npapi_url_request.h
index eace09d..dfafbe9 100644
--- a/chrome_frame/npapi_url_request.h
+++ b/chrome_frame/npapi_url_request.h
@@ -30,6 +30,7 @@ class NPAPIUrlRequestManager : public PluginUrlRequestManager,
int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer);
NPError DestroyStream(NPStream* stream, NPReason reason);
void UrlNotify(const char* url, NPReason reason, void* notify_data);
+ void UrlRedirectNotify(const char* url, int status, void* notify_data);
private:
// PluginUrlRequestManager implementation. Called from AutomationClient.