Update to Chromium revision c78c0ad7 (#363565)

This commit is contained in:
Marshall Greenblatt
2015-12-09 11:10:16 -05:00
parent 535c4fbc30
commit 5dec0c5f57
62 changed files with 534 additions and 478 deletions

View File

@@ -14,6 +14,10 @@
#include "libcef/common/request_impl.h"
#include "libcef/common/response_impl.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "content/public/common/content_switches.h"
#include "net/base/net_errors.h"
#include "net/filter/filter.h"
#include "net/http/http_util.h"
@@ -225,6 +229,27 @@ CefNetworkDelegate::CefNetworkDelegate() {
CefNetworkDelegate::~CefNetworkDelegate() {
}
// static
bool CefNetworkDelegate::AreExperimentalCookieFeaturesEnabled() {
static bool initialized = false;
static bool enabled = false;
if (!initialized) {
enabled = base::CommandLine::ForCurrentProcess()->
HasSwitch(switches::kEnableExperimentalWebPlatformFeatures);
initialized = true;
}
return enabled;
}
// static
bool CefNetworkDelegate::AreStrictSecureCookiesEnabled() {
const std::string enforce_strict_secure_group =
base::FieldTrialList::FindFullName("StrictSecureCookies");
return AreExperimentalCookieFeaturesEnabled() ||
base::StartsWith(enforce_strict_secure_group, "Enabled",
base::CompareCase::INSENSITIVE_ASCII);
}
int CefNetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
const net::CompletionCallback& callback,
@@ -387,6 +412,14 @@ bool CefNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
return true;
}
bool CefNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
return AreExperimentalCookieFeaturesEnabled();
}
bool CefNetworkDelegate::OnAreStrictSecureCookiesEnabled() const {
return AreStrictSecureCookiesEnabled();
}
net::Filter* CefNetworkDelegate::SetupFilter(net::URLRequest* request,
net::Filter* filter_list) {
CefRefPtr<CefResponseFilter> cef_filter;

View File

@@ -15,6 +15,11 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
CefNetworkDelegate();
~CefNetworkDelegate() override;
// Match the logic from ChromeNetworkDelegate and
// RenderFrameMessageFilter::OnSetCookie.
static bool AreExperimentalCookieFeaturesEnabled();
static bool AreStrictSecureCookiesEnabled();
private:
// net::NetworkDelegate methods.
int OnBeforeURLRequest(net::URLRequest* request,
@@ -28,6 +33,8 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
void OnCompleted(net::URLRequest* request, bool started) override;
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const override;
bool OnAreExperimentalCookieFeaturesEnabled() const override;
bool OnAreStrictSecureCookiesEnabled() const override;
net::Filter* SetupFilter(net::URLRequest* request,
net::Filter* filter_list) override;

View File

@@ -106,25 +106,23 @@ class CefResourceRequestJobCallback : public CefCallback {
if (job_->has_response_started() &&
job_->GetStatus().is_io_pending()) {
// Read the bytes. They should be available but, if not, wait again.
int bytes_read = 0;
if (job_->ReadRawData(dest_, dest_size_, &bytes_read)) {
int bytes_read = job_->ReadRawData(dest_, dest_size_);
if (bytes_read == net::ERR_IO_PENDING) {
// Still pending, nothing to do...
} else if (bytes_read >= 0) {
// Must clear the members here because they may be reset as a result
// of calling NotifyReadComplete.
// of calling ReadRawDataComplete.
dest_size_ = 0;
dest_ = NULL;
// Clear the IO_PENDING status.
job_->SetStatus(URLRequestStatus());
// Notify about the available bytes. If bytes_read > 0 then
// ReadRawData may be called from URLRequest::Read. If bytes_read == 0
// then Kill will be called from the URLRequest destructor.
job_->NotifyReadComplete(bytes_read);
} else if (!job_->GetStatus().is_io_pending()) {
job_->ReadRawDataComplete(bytes_read);
} else {
// Failed due to an error.
NOTREACHED() <<
"ReadRawData returned false without setting IO as pending";
job_->NotifyDone(URLRequestStatus());
NOTREACHED() << "ReadRawData returned error " << bytes_read;
job_->ReadRawDataComplete(bytes_read);
Detach();
}
}
@@ -220,28 +218,19 @@ void CefResourceRequestJob::Kill() {
// This method will be called by URLRequestJob::Read and our callback.
// It can indicate the following states:
// 1. If the request is complete set |bytes_read| == 0 and return true. The
// caller is then responsible for calling NotifyReadComplete. ReadRawData
// should not be called again.
// 2. If data is available synchronously set |bytes_read| > 0 and return true.
// The caller is then responsible for calling NotifyReadComplete. ReadRawData
// may be called again by URLRequestJob::Read.
// 3. If data is not available now but may be available asynchronously set
// status to IO_PENDING and return false. When executed asynchronously the
// callback will again call ReadRawData. If data is returned at that time the
// callback will clear the status and call NotifyReadComplete.
bool CefResourceRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size,
int* bytes_read) {
// 1. Return ERR_IO_PENDING, and call ReadRawDataComplete when the read
// completes in any way, or
// 2. Return a count of bytes read >= 0, indicating synchronous success, or
// 3. Return another error code < 0, indicating synchronous failure.
int CefResourceRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
CEF_REQUIRE_IOT();
DCHECK_NE(dest_size, 0);
DCHECK(bytes_read);
if (remaining_bytes_ == 0) {
// No more data to read.
*bytes_read = 0;
DoneWithRequest();
return true;
return 0;
} else if (remaining_bytes_ > 0 && remaining_bytes_ < dest_size) {
// The handler knows the content size beforehand.
dest_size = static_cast<int>(remaining_bytes_);
@@ -255,33 +244,31 @@ bool CefResourceRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size,
}
// Read response data from the handler.
bool rv = handler_->ReadResponse(dest->data(), dest_size, *bytes_read,
int bytes_read = 0;
bool rv = handler_->ReadResponse(dest->data(), dest_size, bytes_read,
callback_.get());
if (!rv) {
// The handler has indicated completion of the request.
*bytes_read = 0;
DoneWithRequest();
return true;
} else if (*bytes_read == 0) {
return 0;
} else if (bytes_read == 0) {
// Continue reading asynchronously. May happen multiple times in a row so
// only set IO pending the first time.
if (!GetStatus().is_io_pending()) {
SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
// only set destination members the first time.
if (!GetStatus().is_io_pending())
callback_->SetDestination(dest, dest_size);
}
return false;
} else if (*bytes_read > dest_size) {
return net::ERR_IO_PENDING;
} else if (bytes_read > dest_size) {
// Normalize the return value.
*bytes_read = dest_size;
bytes_read = dest_size;
}
sent_bytes_ += *bytes_read;
sent_bytes_ += bytes_read;
if (remaining_bytes_ > 0)
remaining_bytes_ -= *bytes_read;
remaining_bytes_ -= bytes_read;
// Continue calling this method.
return true;
return bytes_read;
}
void CefResourceRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {

View File

@@ -33,7 +33,7 @@ class CefResourceRequestJob : public net::URLRequestJob {
// net::URLRequestJob methods.
void Start() override;
void Kill() override;
bool ReadRawData(net::IOBuffer* dest, int dest_size, int* bytes_read) override;
int ReadRawData(net::IOBuffer* dest, int dest_size) override;
void GetResponseInfo(net::HttpResponseInfo* info) override;
void GetLoadTimingInfo(
net::LoadTimingInfo* load_timing_info) const override;

View File

@@ -21,11 +21,13 @@
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/worker_pool.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
@@ -36,6 +38,7 @@
#include "net/dns/host_resolver.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h"
#include "net/http/http_cache.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/http_util.h"
@@ -97,6 +100,7 @@ class CefHttpUserAgentSettings : public net::HttpUserAgentSettings {
CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
const CefRequestContextSettings& settings,
PrefService* pref_service,
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
content::ProtocolHandlerMap* protocol_handlers,
@@ -111,6 +115,10 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
CEF_REQUIRE_UIT();
std::swap(protocol_handlers_, *protocol_handlers);
#if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName);
#endif
}
CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
@@ -172,24 +180,23 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
// Add support for single sign-on.
url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL));
std::vector<std::string> supported_schemes;
supported_schemes.push_back("basic");
supported_schemes.push_back("digest");
supported_schemes.push_back("ntlm");
supported_schemes.push_back("negotiate");
storage_->set_http_auth_handler_factory(make_scoped_ptr(
http_auth_preferences_.reset(
new net::HttpAuthPreferences(supported_schemes
#if defined(OS_POSIX) && !defined(OS_ANDROID)
, gsapi_library_name_
#endif
));
storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerRegistryFactory::Create(
supported_schemes,
url_security_manager_.get(),
url_request_context_->host_resolver(),
std::string(),
std::string(),
false,
false)));
http_auth_preferences_.get(),
url_request_context_->host_resolver()));
storage_->set_http_server_properties(
make_scoped_ptr<net::HttpServerProperties>(
new net::HttpServerPropertiesImpl));

View File

@@ -21,6 +21,8 @@
#include "content/public/browser/content_browser_client.h"
#include "net/url_request/url_request_job_factory.h"
class PrefService;
namespace base {
class MessageLoop;
}
@@ -28,11 +30,11 @@ class MessageLoop;
namespace net {
class CookieMonster;
class FtpTransactionFactory;
class HttpAuthPreferences;
class ProxyConfigService;
class URLRequestContextStorage;
class URLRequestJobFactory;
class URLRequestJobFactoryImpl;
class URLSecurityManager;
}
// Isolated URLRequestContextGetter implementation. Life span is primarily
@@ -43,6 +45,7 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
public:
CefURLRequestContextGetterImpl(
const CefRequestContextSettings& settings,
PrefService* pref_service,
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
content::ProtocolHandlerMap* protocol_handlers,
@@ -80,11 +83,15 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
base::MessageLoop* io_loop_;
base::MessageLoop* file_loop_;
#if defined(OS_POSIX) && !defined(OS_ANDROID)
std::string gsapi_library_name_;
#endif
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::URLRequestContextStorage> storage_;
scoped_ptr<net::HttpAuthPreferences> http_auth_preferences_;
scoped_ptr<CefURLRequestContextImpl> url_request_context_;
scoped_ptr<CefURLRequestManager> url_request_manager_;
scoped_ptr<net::URLSecurityManager> url_security_manager_;
scoped_ptr<net::FtpTransactionFactory> ftp_transaction_factory_;
content::ProtocolHandlerMap protocol_handlers_;
content::URLRequestInterceptorScopedVector request_interceptors_;