diff options
author | jam <jam@chromium.org> | 2015-04-22 10:44:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-22 17:44:54 +0000 |
commit | 1e40c6d971df52a57befe8c26895836231c2625d (patch) | |
tree | 9534aae68fe5560f7c697e9195b00c9a619f15d8 | |
parent | 5a586e5039cf30c3071b14a8e1df105f08c6b06a (diff) | |
download | chromium_src-1e40c6d971df52a57befe8c26895836231c2625d.zip chromium_src-1e40c6d971df52a57befe8c26895836231c2625d.tar.gz chromium_src-1e40c6d971df52a57befe8c26895836231c2625d.tar.bz2 |
Send the referrer in html_viewer.
Since NavigatorHost interface doesn't take extra parameters yet, don't use a new blink instance when a request has the referrer set.
Also, update the user agent version so that Gmail doesn't give a warning.
BUG=479407
Review URL: https://codereview.chromium.org/1051273012
Cr-Commit-Position: refs/heads/master@{#326333}
-rw-r--r-- | mojo/services/html_viewer/blink_platform_impl.cc | 2 | ||||
-rw-r--r-- | mojo/services/html_viewer/html_document.cc | 6 | ||||
-rw-r--r-- | mojo/services/html_viewer/web_url_loader_impl.cc | 12 | ||||
-rw-r--r-- | mojo/services/html_viewer/web_url_loader_impl.h | 2 | ||||
-rw-r--r-- | mojo/services/network/public/interfaces/url_loader.mojom | 4 | ||||
-rw-r--r-- | mojo/services/network/url_loader_impl.cc | 5 |
6 files changed, 29 insertions, 2 deletions
diff --git a/mojo/services/html_viewer/blink_platform_impl.cc b/mojo/services/html_viewer/blink_platform_impl.cc index 5da193c..3d20a10 100644 --- a/mojo/services/html_viewer/blink_platform_impl.cc +++ b/mojo/services/html_viewer/blink_platform_impl.cc @@ -36,7 +36,7 @@ const char kUserAgentSwitch[] = "user-agent"; // TODO(darin): Figure out what our UA should really be. const char kDefaultUserAgentString[] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/35.0.1916.153 Safari/537.36"; + "Chrome/42.0.2311.68 Safari/537.36"; class WebWaitableEventImpl : public blink::WebWaitableEvent { public: diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc index 2a47b9d..4cdda3e 100644 --- a/mojo/services/html_viewer/html_document.cc +++ b/mojo/services/html_viewer/html_document.cc @@ -98,6 +98,12 @@ bool CanNavigateLocally(blink::WebFrame* frame, if (EqualsASCII(request.httpMethod(), "POST")) return true; + // Logging into Gmail fails when the referrer isn't sent with a request. + // TODO(jam): pass referrer and other HTTP data to NavigatorHost so we can + // use a new process in this case. + if (!request.httpHeaderField(blink::WebString::fromUTF8("Referer")).isEmpty()) + return true; + // Otherwise we don't know if we're the right app to handle this request. Ask // host to do the navigation for us. return false; diff --git a/mojo/services/html_viewer/web_url_loader_impl.cc b/mojo/services/html_viewer/web_url_loader_impl.cc index ce4315a..09c795f 100644 --- a/mojo/services/html_viewer/web_url_loader_impl.cc +++ b/mojo/services/html_viewer/web_url_loader_impl.cc @@ -18,6 +18,7 @@ #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" #include "third_party/WebKit/public/platform/WebURLResponse.h" +using blink::WebString; using mojo::URLResponsePtr; namespace html_viewer { @@ -80,7 +81,9 @@ WebURLRequestExtraData::~WebURLRequestExtraData() { } WebURLLoaderImpl::WebURLLoaderImpl(mojo::NetworkService* network_service) - : client_(NULL), weak_factory_(this) { + : client_(NULL), + referrer_policy_(blink::WebReferrerPolicyDefault), + weak_factory_(this) { network_service->CreateURLLoader(GetProxy(&url_loader_)); } @@ -102,6 +105,10 @@ void WebURLLoaderImpl::loadAsynchronously(const blink::WebURLRequest& request, mojo::URLRequestPtr url_request = mojo::URLRequest::From(request); url_request->auto_follow_redirects = false; + referrer_policy_ = request.referrerPolicy(); + GURL referrer_url( + request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()); + url_request->referrer = referrer_url.spec(); if (request.extraData()) { WebURLRequestExtraData* extra_data = @@ -187,6 +194,9 @@ void WebURLLoaderImpl::OnReceivedRedirect(const blink::WebURLRequest& request, new_request.setSkipServiceWorker(request.skipServiceWorker()); new_request.setFetchRequestMode(request.fetchRequestMode()); new_request.setFetchCredentialsMode(request.fetchCredentialsMode()); + new_request.setHTTPReferrer( + WebString::fromUTF8(url_response->redirect_referrer), + referrer_policy_); std::string old_method = request.httpMethod().utf8(); new_request.setHTTPMethod( diff --git a/mojo/services/html_viewer/web_url_loader_impl.h b/mojo/services/html_viewer/web_url_loader_impl.h index 2892275..8c09185 100644 --- a/mojo/services/html_viewer/web_url_loader_impl.h +++ b/mojo/services/html_viewer/web_url_loader_impl.h @@ -9,6 +9,7 @@ #include "base/memory/weak_ptr.h" #include "mojo/common/handle_watcher.h" #include "mojo/services/network/public/interfaces/url_loader.mojom.h" +#include "third_party/WebKit/public/platform/WebReferrerPolicy.h" #include "third_party/WebKit/public/platform/WebURLLoader.h" #include "third_party/WebKit/public/platform/WebURLRequest.h" @@ -55,6 +56,7 @@ class WebURLLoaderImpl : public blink::WebURLLoader { blink::WebURLLoaderClient* client_; GURL url_; + blink::WebReferrerPolicy referrer_policy_; mojo::URLLoaderPtr url_loader_; mojo::ScopedDataPipeConsumerHandle response_body_stream_; mojo::common::HandleWatcher handle_watcher_; diff --git a/mojo/services/network/public/interfaces/url_loader.mojom b/mojo/services/network/public/interfaces/url_loader.mojom index 10f0af3..77db3ad 100644 --- a/mojo/services/network/public/interfaces/url_loader.mojom +++ b/mojo/services/network/public/interfaces/url_loader.mojom @@ -34,6 +34,9 @@ struct URLRequest { // servers to also not satisfy the request from their cache. This has the // effect of forcing a full end-to-end fetch. bool bypass_cache = false; + + // The referrer request header. + string? referrer; }; struct URLResponse { @@ -67,6 +70,7 @@ struct URLResponse { // follow this redirect. string? redirect_method; string? redirect_url; + string? redirect_referrer; }; struct URLLoaderStatus { diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc index 964f9c2..467cc3f 100644 --- a/mojo/services/network/url_loader_impl.cc +++ b/mojo/services/network/url_loader_impl.cc @@ -129,6 +129,10 @@ void URLLoaderImpl::Start(URLRequestPtr request, url_request_ = context_->url_request_context()->CreateRequest( GURL(request->url), net::DEFAULT_PRIORITY, this); url_request_->set_method(request->method); + url_request_->SetReferrer(request->referrer); + // TODO(jam): need to specify this policy. + url_request_->set_referrer_policy( + net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE); if (request->headers) { net::HttpRequestHeaders headers; for (size_t i = 0; i < request->headers.size(); ++i) @@ -207,6 +211,7 @@ void URLLoaderImpl::OnReceivedRedirect(net::URLRequest* url_request, URLResponsePtr response = MakeURLResponse(url_request); response->redirect_method = redirect_info.new_method; response->redirect_url = String::From(redirect_info.new_url); + response->redirect_referrer = redirect_info.new_referrer; SendResponse(response.Pass()); |