2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2011 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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
|
|
|
#pragma once
|
|
|
|
|
2012-06-28 19:21:18 +02:00
|
|
|
#include <set>
|
2012-06-19 18:29:49 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/compiler_specific.h"
|
2013-02-27 18:56:03 +01:00
|
|
|
#include "base/files/file_path.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
2013-03-12 21:23:24 +01:00
|
|
|
#include "content/public/browser/content_browser_client.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "net/url_request/url_request_context_getter.h"
|
2013-02-23 01:43:28 +01:00
|
|
|
#include "net/url_request/url_request_job_factory.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-04-16 00:16:01 +02:00
|
|
|
namespace base {
|
2012-04-03 03:34:16 +02:00
|
|
|
class MessageLoop;
|
2013-04-16 00:16:01 +02:00
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace net {
|
2013-06-24 20:57:05 +02:00
|
|
|
class FtpTransactionFactory;
|
2012-04-03 03:34:16 +02:00
|
|
|
class HostResolver;
|
|
|
|
class ProxyConfigService;
|
|
|
|
class URLRequestContextStorage;
|
|
|
|
class URLRequestJobFactory;
|
2013-02-27 18:56:03 +01:00
|
|
|
class URLRequestJobFactoryImpl;
|
2012-04-03 03:34:16 +02:00
|
|
|
class URLSecurityManager;
|
|
|
|
}
|
|
|
|
|
2013-04-16 00:16:01 +02:00
|
|
|
class CefRequestInterceptor;
|
|
|
|
class CefURLRequestContextProxy;
|
|
|
|
|
2012-12-06 21:50:39 +01:00
|
|
|
/*
|
2012-12-04 02:12:11 +01:00
|
|
|
// Classes used in network request processing:
|
|
|
|
//
|
|
|
|
// RC = net::URLRequestContext
|
|
|
|
// Owns various network-related objects including the global cookie manager.
|
|
|
|
//
|
|
|
|
// RCP = CefURLRequestContextProxy
|
|
|
|
// Creates the CSP and forwards requests to the objects owned by RC.
|
|
|
|
//
|
|
|
|
// CSP = CefCookieStoreProxy
|
|
|
|
// Gives the CefCookieManager associated with CefBrowserHostImpl an
|
|
|
|
// opportunity to handle cookie requests. Otherwise forwards requests via RC
|
|
|
|
// to the global cookie manager.
|
|
|
|
//
|
|
|
|
// RCG = CefURLRequestContextGetter
|
|
|
|
// Creates the RC and manages RCP lifespan.
|
|
|
|
//
|
|
|
|
// RCGP = CefURLRequestContextGetterProxy
|
|
|
|
// Causes the RCG to create and destroy browser-specific RCPs.
|
|
|
|
//
|
|
|
|
// Relationship diagram:
|
|
|
|
// ref = reference (scoped_refptr)
|
|
|
|
// own = ownership (scoped_ptr)
|
|
|
|
// ptr = raw pointer
|
|
|
|
//
|
|
|
|
// global cookie manager, etc...
|
|
|
|
// ^
|
|
|
|
// |
|
|
|
|
// /-own-> RC <-ptr-\
|
|
|
|
// / \
|
|
|
|
// / /<-ptr-\ \
|
|
|
|
// / / \ \
|
|
|
|
// CefBrowserContext -ref-> RCG --own-> RCP --ref-> CSP
|
|
|
|
// ^ ^ /
|
|
|
|
// ref ptr /
|
|
|
|
// | / /
|
|
|
|
// CefBrowserHostImpl -ref-> RCGP----/ /
|
|
|
|
// ^ /
|
|
|
|
// \-ref--------------------------/
|
2012-12-06 21:50:39 +01:00
|
|
|
*/
|
2012-12-04 02:12:11 +01:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
|
|
|
public:
|
|
|
|
CefURLRequestContextGetter(
|
2013-04-16 00:16:01 +02:00
|
|
|
base::MessageLoop* io_loop,
|
|
|
|
base::MessageLoop* file_loop,
|
2014-04-04 18:50:38 +02:00
|
|
|
content::ProtocolHandlerMap* protocol_handlers,
|
|
|
|
content::ProtocolHandlerScopedVector protocol_interceptors);
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual ~CefURLRequestContextGetter();
|
|
|
|
|
|
|
|
// net::URLRequestContextGetter implementation.
|
|
|
|
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
2012-06-22 00:50:34 +02:00
|
|
|
virtual scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
GetNetworkTaskRunner() const OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
net::HostResolver* host_resolver();
|
2013-02-27 18:56:03 +01:00
|
|
|
net::URLRequestJobFactoryImpl* job_factory_impl() const {
|
|
|
|
return job_factory_impl_;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
void SetCookieStoragePath(const base::FilePath& path,
|
2013-02-13 20:53:41 +01:00
|
|
|
bool persist_session_cookies);
|
2012-06-19 18:29:49 +02:00
|
|
|
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-06-28 19:21:18 +02:00
|
|
|
// Manage URLRequestContext proxy objects. It's important that proxy objects
|
|
|
|
// not be destroyed while any in-flight URLRequests exist. These methods
|
|
|
|
// manage that requirement.
|
|
|
|
CefURLRequestContextProxy* CreateURLRequestContextProxy();
|
|
|
|
void ReleaseURLRequestContextProxy(CefURLRequestContextProxy* proxy);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
void CreateProxyConfigService();
|
|
|
|
|
2013-04-16 00:16:01 +02:00
|
|
|
base::MessageLoop* io_loop_;
|
|
|
|
base::MessageLoop* file_loop_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
|
|
|
|
scoped_ptr<CefRequestInterceptor> request_interceptor_;
|
2012-05-18 17:04:56 +02:00
|
|
|
scoped_ptr<net::URLRequestContextStorage> storage_;
|
|
|
|
scoped_ptr<net::URLRequestContext> url_request_context_;
|
|
|
|
scoped_ptr<net::URLSecurityManager> url_security_manager_;
|
2013-06-24 20:57:05 +02:00
|
|
|
scoped_ptr<net::FtpTransactionFactory> ftp_transaction_factory_;
|
2013-03-12 21:23:24 +01:00
|
|
|
content::ProtocolHandlerMap protocol_handlers_;
|
2014-04-04 18:50:38 +02:00
|
|
|
content::ProtocolHandlerScopedVector protocol_interceptors_;
|
2013-02-27 18:56:03 +01:00
|
|
|
net::URLRequestJobFactoryImpl* job_factory_impl_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-06-28 19:21:18 +02:00
|
|
|
typedef std::set<CefURLRequestContextProxy*> RequestContextProxySet;
|
|
|
|
RequestContextProxySet url_request_context_proxies_;
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath cookie_store_path_;
|
2012-06-19 18:29:49 +02:00
|
|
|
std::vector<std::string> cookie_supported_schemes_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetter);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|