Allow setting referrer
This commit is contained in:
parent
e07f5cd53f
commit
543c4d5597
6 changed files with 20 additions and 8 deletions
|
@ -125,13 +125,14 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
|
|||
return;
|
||||
} else if (name == "RequestHttpJob") {
|
||||
GURL url;
|
||||
std::string method;
|
||||
std::string method, referrer;
|
||||
dict.Get("url", &url);
|
||||
dict.Get("method", &method);
|
||||
dict.Get("referrer", &referrer);
|
||||
|
||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&AdapterRequestJob::CreateHttpJobAndStart,
|
||||
GetWeakPtr(), url, method));
|
||||
GetWeakPtr(), url, method, referrer));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,6 @@ class RequestErrorJob
|
|||
|
||||
protocol.RequestHttpJob =
|
||||
class RequestHttpJob
|
||||
constructor: ({@url, @method}) ->
|
||||
constructor: ({@url, @method, @referrer}) ->
|
||||
|
||||
module.exports = protocol
|
||||
|
|
|
@ -115,14 +115,15 @@ void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
|
|||
}
|
||||
|
||||
void AdapterRequestJob::CreateHttpJobAndStart(const GURL& url,
|
||||
const std::string& method) {
|
||||
const std::string& method,
|
||||
const std::string& referrer) {
|
||||
if (!url.is_valid()) {
|
||||
CreateErrorJobAndStart(net::ERR_INVALID_URL);
|
||||
return;
|
||||
}
|
||||
|
||||
real_job_ = new URLRequestFetchJob(request(), network_delegate(), url,
|
||||
method);
|
||||
method, referrer);
|
||||
real_job_->Start();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,9 @@ class AdapterRequestJob : public net::URLRequestJob {
|
|||
const std::string& charset,
|
||||
scoped_refptr<base::RefCountedBytes> data);
|
||||
void CreateFileJobAndStart(const base::FilePath& path);
|
||||
void CreateHttpJobAndStart(const GURL& url, const std::string& method);
|
||||
void CreateHttpJobAndStart(const GURL& url,
|
||||
const std::string& method,
|
||||
const std::string& referrer);
|
||||
void CreateJobFromProtocolHandlerAndStart();
|
||||
|
||||
private:
|
||||
|
|
|
@ -76,7 +76,8 @@ URLRequestFetchJob::URLRequestFetchJob(
|
|||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate,
|
||||
const GURL& url,
|
||||
const std::string& method)
|
||||
const std::string& method,
|
||||
const std::string& referrer)
|
||||
: net::URLRequestJob(request, network_delegate),
|
||||
pending_buffer_size_(0) {
|
||||
// Use |request|'s method if |method| is not specified.
|
||||
|
@ -90,6 +91,12 @@ URLRequestFetchJob::URLRequestFetchJob(
|
|||
auto context = AtomBrowserContext::Get()->url_request_context_getter();
|
||||
fetcher_->SetRequestContext(context);
|
||||
fetcher_->SaveResponseWithWriter(make_scoped_ptr(new ResponsePiper(this)));
|
||||
|
||||
// Use |request|'s referrer if |referrer| is not specified.
|
||||
if (referrer.empty())
|
||||
fetcher_->SetReferrer(request->referrer());
|
||||
else
|
||||
fetcher_->SetReferrer(referrer);
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::HeadersCompleted() {
|
||||
|
|
|
@ -16,7 +16,8 @@ class URLRequestFetchJob : public net::URLRequestJob,
|
|||
URLRequestFetchJob(net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate,
|
||||
const GURL& url,
|
||||
const std::string& method);
|
||||
const std::string& method,
|
||||
const std::string& referrer);
|
||||
|
||||
void HeadersCompleted();
|
||||
int DataAvailable(net::IOBuffer* buffer, int num_bytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue