2012-04-05 00:32:24 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser_network_delegate.h"
|
|
|
|
|
|
|
|
#include "net/base/net_errors.h"
|
|
|
|
#include "net/base/static_cookie_policy.h"
|
2012-04-05 02:37:45 +02:00
|
|
|
#include "net/url_request/url_request.h"
|
2012-04-05 00:32:24 +02:00
|
|
|
|
|
|
|
BrowserNetworkDelegate::BrowserNetworkDelegate()
|
|
|
|
: accept_all_cookies_(true) {
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserNetworkDelegate::~BrowserNetworkDelegate() {
|
|
|
|
}
|
|
|
|
|
|
|
|
int BrowserNetworkDelegate::OnBeforeURLRequest(
|
|
|
|
net::URLRequest* request,
|
|
|
|
const net::CompletionCallback& callback,
|
|
|
|
GURL* new_url) {
|
|
|
|
return net::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BrowserNetworkDelegate::OnBeforeSendHeaders(
|
|
|
|
net::URLRequest* request,
|
|
|
|
const net::CompletionCallback& callback,
|
|
|
|
net::HttpRequestHeaders* headers) {
|
|
|
|
return net::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnSendHeaders(
|
|
|
|
net::URLRequest* request,
|
|
|
|
const net::HttpRequestHeaders& headers) {
|
|
|
|
}
|
|
|
|
|
|
|
|
int BrowserNetworkDelegate::OnHeadersReceived(
|
|
|
|
net::URLRequest* request,
|
|
|
|
const net::CompletionCallback& callback,
|
2012-11-06 18:13:58 +01:00
|
|
|
const net::HttpResponseHeaders* original_response_headers,
|
2012-04-05 00:32:24 +02:00
|
|
|
scoped_refptr<net::HttpResponseHeaders>*override_response_headers) {
|
|
|
|
return net::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
|
|
|
const GURL& new_location) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
|
|
|
|
int bytes_read) {
|
|
|
|
}
|
|
|
|
void BrowserNetworkDelegate::OnCompleted(net::URLRequest* request,
|
|
|
|
bool started) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserNetworkDelegate::OnPACScriptError(int line_number,
|
|
|
|
const string16& error) {
|
|
|
|
}
|
|
|
|
|
|
|
|
net::NetworkDelegate::AuthRequiredResponse
|
|
|
|
BrowserNetworkDelegate::OnAuthRequired(
|
|
|
|
net::URLRequest* request,
|
|
|
|
const net::AuthChallengeInfo& auth_info,
|
|
|
|
const AuthCallback& callback,
|
|
|
|
net::AuthCredentials* credentials) {
|
|
|
|
return AUTH_REQUIRED_RESPONSE_NO_ACTION;
|
|
|
|
}
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
bool BrowserNetworkDelegate::OnCanGetCookies(
|
|
|
|
const net::URLRequest& request,
|
2012-04-05 00:32:24 +02:00
|
|
|
const net::CookieList& cookie_list) {
|
|
|
|
net::StaticCookiePolicy::Type policy_type = accept_all_cookies_ ?
|
|
|
|
net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
|
|
|
|
net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES;
|
|
|
|
|
|
|
|
net::StaticCookiePolicy policy(policy_type);
|
|
|
|
int rv = policy.CanGetCookies(
|
2012-05-23 21:01:04 +02:00
|
|
|
request.url(), request.first_party_for_cookies());
|
2012-04-05 00:32:24 +02:00
|
|
|
return rv == net::OK;
|
|
|
|
}
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
bool BrowserNetworkDelegate::OnCanSetCookie(
|
|
|
|
const net::URLRequest& request,
|
|
|
|
const std::string& cookie_line,
|
|
|
|
net::CookieOptions* options) {
|
2012-04-05 00:32:24 +02:00
|
|
|
net::StaticCookiePolicy::Type policy_type = accept_all_cookies_ ?
|
|
|
|
net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
|
|
|
|
net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES;
|
|
|
|
|
|
|
|
net::StaticCookiePolicy policy(policy_type);
|
|
|
|
int rv = policy.CanSetCookie(
|
2012-05-23 21:01:04 +02:00
|
|
|
request.url(), request.first_party_for_cookies());
|
2012-04-05 00:32:24 +02:00
|
|
|
return rv == net::OK;
|
|
|
|
}
|
2012-05-23 21:01:04 +02:00
|
|
|
|
|
|
|
bool BrowserNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
|
|
|
|
const FilePath& path) const {
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-22 02:10:10 +02:00
|
|
|
|
|
|
|
bool BrowserNetworkDelegate::OnCanThrottleRequest(
|
|
|
|
const net::URLRequest& request) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BrowserNetworkDelegate::OnBeforeSocketStreamConnect(
|
|
|
|
net::SocketStream* stream,
|
|
|
|
const net::CompletionCallback& callback) {
|
|
|
|
return net::OK;
|
|
|
|
}
|
2012-08-07 15:58:35 +02:00
|
|
|
|
2012-08-29 22:11:26 +02:00
|
|
|
void BrowserNetworkDelegate::OnRequestWaitStateChange(
|
2012-08-07 15:58:35 +02:00
|
|
|
const net::URLRequest& request,
|
2012-08-29 22:11:26 +02:00
|
|
|
RequestWaitState state) {
|
2012-08-07 15:58:35 +02:00
|
|
|
}
|