From 2045b41427fd10137d9c97dbc3d2ab536fd45480 Mon Sep 17 00:00:00 2001 From: "stoyan@chromium.org" Date: Tue, 17 Aug 2010 19:40:09 +0000 Subject: Support rendering in Chrome Frame if the content-type of the top level request is [application/xhtml+xml, image/svg, image/svg+xml, video/ogg, video/webm,video/mp4] or text/html BUG=51982 Review URL: http://codereview.chromium.org/3107019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56398 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/protocol_sink_wrap.cc | 46 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'chrome_frame/protocol_sink_wrap.cc') diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc index 5d28438..b7ef18f 100644 --- a/chrome_frame/protocol_sink_wrap.cc +++ b/chrome_frame/protocol_sink_wrap.cc @@ -248,18 +248,31 @@ void PutProtData(IBindCtx* pbc, ProtData* data) { } bool IsTextHtml(const wchar_t* status_text) { - if (!status_text) - return false; - size_t status_text_length = lstrlenW(status_text); - const wchar_t* status_text_end = status_text + - std::min(status_text_length, arraysize(kTextHtmlMimeType) - 1); - bool is_text_html = LowerCaseEqualsASCII(status_text, status_text_end, - kTextHtmlMimeType); + const std::wstring str = status_text; + bool is_text_html = LowerCaseEqualsASCII(str, kTextHtmlMimeType); return is_text_html; } +bool IsAdditionallySupportedContentType(const wchar_t* status_text) { + const std::wstring str = status_text; + if (LowerCaseEqualsASCII(str, "application/xhtml+xml")) + return true; + if (LowerCaseEqualsASCII(str, "image/svg")) + return true; + if (LowerCaseEqualsASCII(str, "image/svg+xml")) + return true; + if (LowerCaseEqualsASCII(str, "video/ogg")) + return true; + if (LowerCaseEqualsASCII(str, "video/webm")) + return true; + if (LowerCaseEqualsASCII(str, "video/mp4")) + return true; + + return false; +} + // Returns: -// CHROME: if suggested mime type is "text/html" and at least one of the +// CHROME: if suggested mime type is a supported one and at least one of the // following is true: 1) X-UA-Compatible tag is in HTTP headers. // 2) Url is listed in OptInURLs registry key. // OTHER: if suggested mime type is not text/html. @@ -268,9 +281,13 @@ RendererType DetermineRendererTypeFromMetaData( const wchar_t* suggested_mime_type, const std::wstring& url, IWinInetHttpInfo* info) { - if (!IsTextHtml(suggested_mime_type)) { + + bool is_text_html = IsTextHtml(suggested_mime_type); + bool is_supported_content_type = is_text_html || + IsAdditionallySupportedContentType(suggested_mime_type); + + if (!is_supported_content_type) return OTHER; - } if (!url.empty() && IsOptInUrl(url.c_str())) { return CHROME; @@ -287,7 +304,14 @@ RendererType DetermineRendererTypeFromMetaData( } } } - return UNDETERMINED; + + // We can (and want) to sniff the content. + if (is_text_html) { + return UNDETERMINED; + } + + // We cannot sniff the content. + return OTHER; } RendererType DetermineRendererType(void* buffer, DWORD size, bool last_chance) { -- cgit v1.1