summaryrefslogtreecommitdiffstats
path: root/chrome_frame/utils.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 01:10:47 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 01:10:47 +0000
commit6ee88534895ff56a131400acfd2a837824ef1ead (patch)
treedda29859ab5e7ee86fc80afdc1f3dca3ac86438d /chrome_frame/utils.cc
parent6044824e6c218ea5c801934ac52b88d3b10f89eb (diff)
downloadchromium_src-6ee88534895ff56a131400acfd2a837824ef1ead.zip
chromium_src-6ee88534895ff56a131400acfd2a837824ef1ead.tar.gz
chromium_src-6ee88534895ff56a131400acfd2a837824ef1ead.tar.bz2
With the ChromeFrame IMoniker patch in the referrer would not propagate correctly to Chrome when we switch from IE to CF. In ChromeFrame
the referrer is set in the navigation manager which receives this in the IHttpNegotiate::BeginningTransaction patch. When we switch from IE to cF via the moniker patch we receive two calls to BeginningTransaction, the first one with the referrer and the other one without the referrer for the same URL causing the referrer to be overwritten. Fix is to handle this case. The referrer is cleared in our BeforeNavigate notification. I also moved some functions to chrome frame utils as part of this CL. Fixes bug http://code.google.com/p/chromium/issues/detail?id=41680 Bug=41680 Review URL: http://codereview.chromium.org/1653006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/utils.cc')
-rw-r--r--chrome_frame/utils.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index eb0c802..1bc13ac 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -29,6 +29,7 @@
#include "googleurl/src/url_canon.h"
#include "grit/chromium_strings.h"
+#include "net/http/http_util.h"
// Note that these values are all lower case and are compared to
// lower-case-transformed values.
@@ -992,3 +993,67 @@ bool CompareUrlsWithoutFragment(const wchar_t* url1, const wchar_t* url2) {
return parsed_url1 == parsed_url2;
}
+std::string FindReferrerFromHeaders(const wchar_t* headers,
+ const wchar_t* additional_headers) {
+ std::string referrer;
+
+ const wchar_t* both_headers[] = { headers, additional_headers };
+ for (int i = 0; referrer.empty() && i < arraysize(both_headers); ++i) {
+ if (!both_headers[i])
+ continue;
+ std::string raw_headers_utf8 = WideToUTF8(both_headers[i]);
+ net::HttpUtil::HeadersIterator it(raw_headers_utf8.begin(),
+ raw_headers_utf8.end(), "\r\n");
+ while (it.GetNext()) {
+ if (LowerCaseEqualsASCII(it.name(), "referer")) {
+ referrer = it.values();
+ break;
+ }
+ }
+ }
+
+ return referrer;
+}
+
+std::string GetHttpHeadersFromBinding(IBinding* binding) {
+ if (binding == NULL) {
+ DLOG(WARNING) << "GetHttpResponseStatus - no binding_";
+ return std::string();
+ }
+
+ ScopedComPtr<IWinInetHttpInfo> info;
+ if (FAILED(info.QueryFrom(binding))) {
+ DLOG(WARNING) << "Failed to QI for IWinInetHttpInfo";
+ return std::string();
+ }
+
+ return GetRawHttpHeaders(info);
+}
+
+int GetHttpResponseStatusFromBinding(IBinding* binding) {
+ DLOG(INFO) << __FUNCTION__;
+ if (binding == NULL) {
+ DLOG(WARNING) << "GetHttpResponseStatus - no binding_";
+ return 0;
+ }
+
+ int http_status = 0;
+
+ ScopedComPtr<IWinInetHttpInfo> info;
+ if (SUCCEEDED(info.QueryFrom(binding))) {
+ char status[10] = {0};
+ DWORD buf_size = sizeof(status);
+ DWORD flags = 0;
+ DWORD reserved = 0;
+ if (SUCCEEDED(info->QueryInfo(HTTP_QUERY_STATUS_CODE, status, &buf_size,
+ &flags, &reserved))) {
+ http_status = StringToInt(status);
+ } else {
+ NOTREACHED() << "Failed to get HTTP status";
+ }
+ } else {
+ NOTREACHED() << "failed to get IWinInetHttpInfo from binding_";
+ }
+
+ return http_status;
+}