diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 22:52:42 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 22:52:42 +0000 |
commit | bff3df1ed12fd08156019b2f4f2df5b7e8b14f2d (patch) | |
tree | 0b111c3a42e140023d49d176eaa296cb031400fd /chrome_frame | |
parent | c5b8b37430110ec63885eafeed20914a74463ed3 (diff) | |
download | chromium_src-bff3df1ed12fd08156019b2f4f2df5b7e8b14f2d.zip chromium_src-bff3df1ed12fd08156019b2f4f2df5b7e8b14f2d.tar.gz chromium_src-bff3df1ed12fd08156019b2f4f2df5b7e8b14f2d.tar.bz2 |
Implement poor man's redirect handling in ChromeFrame for browsers which don't implement
the NPAPI redirect notification spec.
We compare the URL received in the NewStream notification with the requested URL and if they
differ we cancel the current request and inform Chrome that this was a redirect. The sideeffect
would be that there would be two GET requests sent out.
BUG=69419
TEST=none.
Review URL: http://codereview.chromium.org/6381005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/np_browser_functions.cc | 4 | ||||
-rw-r--r-- | chrome_frame/np_browser_functions.h | 4 | ||||
-rw-r--r-- | chrome_frame/npapi_url_request.cc | 19 |
3 files changed, 27 insertions, 0 deletions
diff --git a/chrome_frame/np_browser_functions.cc b/chrome_frame/np_browser_functions.cc index 02b89ac..804efdc 100644 --- a/chrome_frame/np_browser_functions.cc +++ b/chrome_frame/np_browser_functions.cc @@ -527,3 +527,7 @@ void AllocateStringVariant(const std::string& str, NPVariant* var) { NULL_TO_NPVARIANT(*var); } } + +bool BrowserSupportsRedirectNotification() { + return npapi::g_urlredirectresponse != NULL; +} diff --git a/chrome_frame/np_browser_functions.h b/chrome_frame/np_browser_functions.h index 64344aa..da2a1c8 100644 --- a/chrome_frame/np_browser_functions.h +++ b/chrome_frame/np_browser_functions.h @@ -276,4 +276,8 @@ class ScopedNpObject { // The memory allocation is done via the npapi browser functions. void AllocateStringVariant(const std::string& str, NPVariant* var); +// Returns true if the host browser supports the NPAPI redirect notification +// spec. https://wiki.mozilla.org/NPAPI:HTTPRedirectHandling +bool BrowserSupportsRedirectNotification(); + #endif // CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_ diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc index 306321d..49b3555 100644 --- a/chrome_frame/npapi_url_request.cc +++ b/chrome_frame/npapi_url_request.cc @@ -6,6 +6,7 @@ #include "base/string_number_conversions.h" #include "base/threading/platform_thread.h" +#include "chrome_frame/chrome_frame_npapi.h" #include "chrome_frame/np_browser_functions.h" #include "chrome_frame/np_utils.h" #include "net/base/net_errors.h" @@ -370,6 +371,24 @@ NPError NPAPIUrlRequestManager::NewStream(NPMIMEType type, } DCHECK(request_map_.find(request->id()) != request_map_.end()); + + // If the host browser does not support the NPAPI redirect notification + // spec, and if the request URL is implicitly redirected, we need to + // inform Chrome about the redirect and allow it to follow the redirect. + // We achieve this by comparing the URL requested with the URL received in + // the response and if they don't match we assume a redirect. This would have + // a sideffect that two GET requests would be sent out in this case. + if (!BrowserSupportsRedirectNotification()) { + if (GURL(request->url().c_str()) != GURL(stream->url)) { + DVLOG(1) << "Request URL:" + << request->url() + << " was redirected to:" + << stream->url; + delegate_->OnResponseStarted(request->id(), "", "", 0, base::Time(), + stream->url, 302); + 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; |