diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-23 19:43:12 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-23 19:43:12 +0000 |
commit | 921a31d77870b86b4640f25a9c51fbeba07ab4b5 (patch) | |
tree | 9b5efa4e9e5bdf150c837298dc963cb311ba5699 /chrome_frame | |
parent | 20fbc692a57fdc985471a31e99c26e3f1a66fb62 (diff) | |
download | chromium_src-921a31d77870b86b4640f25a9c51fbeba07ab4b5.zip chromium_src-921a31d77870b86b4640f25a9c51fbeba07ab4b5.tar.gz chromium_src-921a31d77870b86b4640f25a9c51fbeba07ab4b5.tar.bz2 |
ChromeFrame in IE full tab mode would not render pages if Adblock Pro was installed on the machine.
Based on my debugging it looks like AdBlock gets confused because we report the mime type initally as
text/html and then swich to application/chromepage.
Fix is to attempt to determine the mime type in our IInternetProtocolSink::ReportProgress implementation.
If we fail we continue to determine the mime type in IInternetProtocolSink::ReportData.
Added a helper function CheckAndReportChromeMimeTypeForRequest which is invoked from both places.
Fixes http://code.google.com/p/chromium/issues/detail?id=31031
Bug=31031
Review URL: http://codereview.chromium.org/501181
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/protocol_sink_wrap.cc | 78 | ||||
-rw-r--r-- | chrome_frame/protocol_sink_wrap.h | 9 |
2 files changed, 58 insertions, 29 deletions
diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc index d4498299..cbafc8f 100644 --- a/chrome_frame/protocol_sink_wrap.cc +++ b/chrome_frame/protocol_sink_wrap.cc @@ -248,6 +248,9 @@ STDMETHODIMP ProtocolSinkWrap::ReportProgress(ULONG status_code, LPCWSTR status_text) { DLOG(INFO) << "ProtocolSinkWrap::ReportProgress: Code:" << status_code << " Text: " << (status_text ? status_text : L""); + if (!delegate_) { + return E_FAIL; + } if ((BINDSTATUS_MIMETYPEAVAILABLE == status_code) || (BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE == status_code)) { // If we have a MIMETYPE and that MIMETYPE is not "text/html". we don't @@ -259,13 +262,16 @@ STDMETHODIMP ProtocolSinkWrap::ReportProgress(ULONG status_code, if (!LowerCaseEqualsASCII(status_text, status_text_end, kTextHtmlMimeType)) { renderer_type_ = OTHER; + } else { + CheckAndReportChromeMimeTypeForRequest(); } } } - HRESULT hr = E_FAIL; - if (delegate_) + HRESULT hr = S_OK; + if (delegate_ && renderer_type_ != CHROME) { hr = delegate_->ReportProgress(status_code, status_text); + } return hr; } @@ -304,33 +310,7 @@ STDMETHODIMP ProtocolSinkWrap::ReportData(DWORD flags, ULONG progress, HRESULT hr = S_OK; if (is_undetermined()) { - HRESULT hr_read = S_OK; - while (hr_read == S_OK) { - ULONG size_read = 0; - hr_read = protocol_->Read(buffer_ + buffer_size_, - kMaxContentSniffLength - buffer_size_, &size_read); - buffer_size_ += size_read; - - // Attempt to determine the renderer type if we have received - // sufficient data. Do not attempt this when we are called recursively. - if (report_data_recursiveness_ < 2 && (S_FALSE == hr_read) || - (buffer_size_ >= kMaxContentSniffLength)) { - DetermineRendererType(); - if (renderer_type() == CHROME) { - // Workaround for IE 8 and "nosniff". See: - // http://blogs.msdn.com/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx - delegate_->ReportProgress( - BINDSTATUS_SERVER_MIMETYPEAVAILABLE, kChromeMimeType); - // For IE < 8. - delegate_->ReportProgress( - BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, kChromeMimeType); - - delegate_->ReportData( - BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE, 0, 0); - } - break; - } - } + CheckAndReportChromeMimeTypeForRequest(); } // we call original only if the renderer type is other @@ -582,6 +562,46 @@ void ProtocolSinkWrap::DetermineRendererType() { } } +HRESULT ProtocolSinkWrap::CheckAndReportChromeMimeTypeForRequest() { + if (!is_undetermined()) + return S_OK; + + HRESULT hr_read = S_OK; + while (hr_read == S_OK) { + ULONG size_read = 0; + hr_read = protocol_->Read(buffer_ + buffer_size_, + kMaxContentSniffLength - buffer_size_, &size_read); + buffer_size_ += size_read; + + // Attempt to determine the renderer type if we have received + // sufficient data. Do not attempt this when we are called recursively. + if (report_data_recursiveness_ < 2 && (S_FALSE == hr_read) || + (buffer_size_ >= kMaxContentSniffLength)) { + DetermineRendererType(); + if (renderer_type() == CHROME) { + // Workaround for IE 8 and "nosniff". See: + // http://blogs.msdn.com/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx + delegate_->ReportProgress( + BINDSTATUS_SERVER_MIMETYPEAVAILABLE, kChromeMimeType); + // For IE < 8. + delegate_->ReportProgress( + BINDSTATUS_MIMETYPEAVAILABLE, kChromeMimeType); + + delegate_->ReportProgress( + BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, kChromeMimeType); + + delegate_->ReportData( + BSCF_FIRSTDATANOTIFICATION, 0, 0); + + delegate_->ReportData( + BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE, 0, 0); + } + break; + } + } + return hr_read; +} + HRESULT ProtocolSinkWrap::OnReadImpl(void* buffer, ULONG size, ULONG* size_read, InternetProtocol_Read_Fn orig_read) { // We want to switch the renderer to chrome, we cannot return any diff --git a/chrome_frame/protocol_sink_wrap.h b/chrome_frame/protocol_sink_wrap.h index e8a7665..4596b58 100644 --- a/chrome_frame/protocol_sink_wrap.h +++ b/chrome_frame/protocol_sink_wrap.h @@ -17,6 +17,7 @@ #include "base/ref_counted.h" #include "base/scoped_comptr_win.h" #include "googleurl/src/gurl.h" +#include "chrome_frame/chrome_frame_delegate.h" #include "chrome_frame/ie8_types.h" #include "chrome_frame/utils.h" #include "chrome_frame/vtable_patch_manager.h" @@ -173,9 +174,17 @@ END_COM_MAP() const wchar_t* url); void DetermineRendererType(); + HRESULT OnReadImpl(void* buffer, ULONG size, ULONG* size_read, InternetProtocol_Read_Fn orig_read); + // This function determines whether the current request should be handled + // by Chrome. If yes it reports the mime type as application/chromepage, + // which ensures that the ChromeFrame is instantiated for handling this + // request. + // Returns S_OK on success. + HRESULT CheckAndReportChromeMimeTypeForRequest(); + bool is_undetermined() const { return (UNDETERMINED == renderer_type_); } |