mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-20 14:10:40 +01:00
- Add a new CefApp interface that provides global handlers and gets passed to CefInitialize() (issue #399).
- Add a new CefProxyHandler interface to allow applications to resolve proxy information (issue #389). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@394 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
8c5b56cbf5
commit
7361732f92
4
cef.gyp
4
cef.gyp
@ -430,6 +430,8 @@
|
|||||||
'libcef_dll/cpptoc/xml_reader_cpptoc.h',
|
'libcef_dll/cpptoc/xml_reader_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
|
'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/zip_reader_cpptoc.h',
|
'libcef_dll/cpptoc/zip_reader_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/app_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/app_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/client_ctocpp.cc',
|
'libcef_dll/ctocpp/client_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/client_ctocpp.h',
|
'libcef_dll/ctocpp/client_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/content_filter_ctocpp.cc',
|
'libcef_dll/ctocpp/content_filter_ctocpp.cc',
|
||||||
@ -463,6 +465,8 @@
|
|||||||
'libcef_dll/ctocpp/menu_handler_ctocpp.h',
|
'libcef_dll/ctocpp/menu_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/print_handler_ctocpp.h',
|
'libcef_dll/ctocpp/print_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/proxy_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/proxy_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
||||||
|
@ -125,6 +125,8 @@
|
|||||||
],
|
],
|
||||||
'libcef_dll_wrapper_sources_common': [
|
'libcef_dll_wrapper_sources_common': [
|
||||||
'libcef_dll/cef_logging.h',
|
'libcef_dll/cef_logging.h',
|
||||||
|
'libcef_dll/cpptoc/app_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/app_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/base_cpptoc.h',
|
'libcef_dll/cpptoc/base_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/client_cpptoc.cc',
|
'libcef_dll/cpptoc/client_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/client_cpptoc.h',
|
'libcef_dll/cpptoc/client_cpptoc.h',
|
||||||
@ -159,6 +161,8 @@
|
|||||||
'libcef_dll/cpptoc/menu_handler_cpptoc.h',
|
'libcef_dll/cpptoc/menu_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/print_handler_cpptoc.h',
|
'libcef_dll/cpptoc/print_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/proxy_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/proxy_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "internal/cef_linux.h"
|
#include "internal/cef_linux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class CefApp;
|
||||||
class CefBrowser;
|
class CefBrowser;
|
||||||
class CefClient;
|
class CefClient;
|
||||||
class CefContentFilter;
|
class CefContentFilter;
|
||||||
@ -85,11 +86,12 @@ class CefWebURLRequestClient;
|
|||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to initialize
|
// This function should be called on the main application thread to initialize
|
||||||
// CEF when the application is started. A return value of true indicates that
|
// CEF when the application is started. The |application| parameter may be
|
||||||
// it succeeded and false indicates that it failed.
|
// empty. A return value of true indicates that it succeeded and false indicates
|
||||||
|
// that it failed.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
bool CefInitialize(const CefSettings& settings);
|
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application);
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to shut down
|
// This function should be called on the main application thread to shut down
|
||||||
@ -645,9 +647,9 @@ public:
|
|||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
|
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
const CefString& url,
|
const CefString& url,
|
||||||
const CefBrowserSettings& settings);
|
const CefBrowserSettings& settings);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Call this method before destroying a contained browser window. This method
|
// Call this method before destroying a contained browser window. This method
|
||||||
@ -1063,6 +1065,38 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this interface to handle proxy resolution events.
|
||||||
|
///
|
||||||
|
/*--cef(source=client)--*/
|
||||||
|
class CefProxyHandler : public virtual CefBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Called to retrieve proxy information for the specified |url|.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void GetProxyForUrl(const CefString& url,
|
||||||
|
CefProxyInfo& proxy_info) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this interface to provide handler implementations.
|
||||||
|
///
|
||||||
|
/*--cef(source=client)--*/
|
||||||
|
class CefApp : public virtual CefBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Return the handler for proxy events. If not handler is returned the default
|
||||||
|
// system handler will be used.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() { return NULL; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this interface to handle events related to browser life span. The
|
// Implement this interface to handle events related to browser life span. The
|
||||||
// methods of this class will be called on the UI thread.
|
// methods of this class will be called on the UI thread.
|
||||||
|
@ -51,10 +51,12 @@ extern "C" {
|
|||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to initialize
|
// This function should be called on the main application thread to initialize
|
||||||
// CEF when the application is started. A return value of true (1) indicates
|
// CEF when the application is started. The |application| parameter may be NULL.
|
||||||
// that it succeeded and false (0) indicates that it failed.
|
// A return value of true (1) indicates that it succeeded and false (0)
|
||||||
|
// indicates that it failed.
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings);
|
CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings,
|
||||||
|
struct _cef_app_t* application);
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to shut down
|
// This function should be called on the main application thread to shut down
|
||||||
@ -896,6 +898,41 @@ typedef struct _cef_frame_t
|
|||||||
} cef_frame_t;
|
} cef_frame_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this structure to handle proxy resolution events.
|
||||||
|
///
|
||||||
|
typedef struct _cef_proxy_handler_t
|
||||||
|
{
|
||||||
|
// Base structure.
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called to retrieve proxy information for the specified |url|.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *get_proxy_for_url)(struct _cef_proxy_handler_t* self,
|
||||||
|
const cef_string_t* url, struct _cef_proxy_info_t* proxy_info);
|
||||||
|
|
||||||
|
} cef_proxy_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this structure to provide handler implementations.
|
||||||
|
///
|
||||||
|
typedef struct _cef_app_t
|
||||||
|
{
|
||||||
|
// Base structure.
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for proxy events. If not handler is returned the default
|
||||||
|
// system handler will be used.
|
||||||
|
///
|
||||||
|
struct _cef_proxy_handler_t* (CEF_CALLBACK *get_proxy_handler)(
|
||||||
|
struct _cef_app_t* self);
|
||||||
|
|
||||||
|
} cef_app_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to browser life span. The
|
// Implement this structure to handle events related to browser life span. The
|
||||||
// functions of this structure will be called on the UI thread.
|
// functions of this structure will be called on the UI thread.
|
||||||
|
@ -1069,6 +1069,25 @@ enum cef_dom_node_type_t
|
|||||||
DOM_NODE_TYPE_XPATH_NAMESPACE,
|
DOM_NODE_TYPE_XPATH_NAMESPACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Proxy types.
|
||||||
|
///
|
||||||
|
enum cef_proxy_type_t
|
||||||
|
{
|
||||||
|
PROXY_TYPE_DIRECT = 0,
|
||||||
|
PROXY_TYPE_NAMED,
|
||||||
|
PROXY_TYPE_PAC_STRING,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Proxy information.
|
||||||
|
///
|
||||||
|
typedef struct _cef_proxy_info_t
|
||||||
|
{
|
||||||
|
enum cef_proxy_type_t proxyType;
|
||||||
|
cef_string_t proxyList;
|
||||||
|
} cef_proxy_info_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -527,4 +527,69 @@ struct CefCookieTraits {
|
|||||||
///
|
///
|
||||||
typedef CefStructBase<CefCookieTraits> CefCookie;
|
typedef CefStructBase<CefCookieTraits> CefCookie;
|
||||||
|
|
||||||
|
|
||||||
|
struct CefProxyInfoTraits {
|
||||||
|
typedef cef_proxy_info_t struct_type;
|
||||||
|
|
||||||
|
static inline void init(struct_type* s) {}
|
||||||
|
|
||||||
|
static inline void clear(struct_type* s)
|
||||||
|
{
|
||||||
|
cef_string_clear(&s->proxyList);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set(const struct_type* src, struct_type* target, bool copy)
|
||||||
|
{
|
||||||
|
target->proxyType = src->proxyType;
|
||||||
|
cef_string_set(src->proxyList.str, src->proxyList.length,
|
||||||
|
&target->proxyList, copy);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// Class representing the results of proxy resolution.
|
||||||
|
///
|
||||||
|
class CefProxyInfo : public CefStructBase<CefProxyInfoTraits>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Use a direction connection instead of a proxy.
|
||||||
|
///
|
||||||
|
void UseDirect()
|
||||||
|
{
|
||||||
|
proxyType = PROXY_TYPE_DIRECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Use one or more named proxy servers specified in WinHTTP format. Each proxy
|
||||||
|
// server is of the form:
|
||||||
|
//
|
||||||
|
// [<scheme>"://"]<server>[":"<port>]
|
||||||
|
//
|
||||||
|
// Multiple values may be separated by semicolons or whitespace. For example,
|
||||||
|
// "foo1:80;foo2:80".
|
||||||
|
///
|
||||||
|
void UseNamedProxy(const CefString& proxy_uri_list)
|
||||||
|
{
|
||||||
|
proxyType = PROXY_TYPE_NAMED;
|
||||||
|
(CefString(&proxyList)) = proxy_uri_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Use one or more named proxy servers specified in PAC script format. For
|
||||||
|
// example, "PROXY foobar:99; SOCKS fml:2; DIRECT".
|
||||||
|
///
|
||||||
|
void UsePacString(const CefString& pac_string)
|
||||||
|
{
|
||||||
|
proxyType = PROXY_TYPE_PAC_STRING;
|
||||||
|
(CefString(&proxyList)) = pac_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDirect() const { return proxyType == PROXY_TYPE_DIRECT; }
|
||||||
|
bool IsNamedProxy() const { return proxyType == PROXY_TYPE_NAMED; }
|
||||||
|
bool IsPacString() const { return proxyType == PROXY_TYPE_PAC_STRING; }
|
||||||
|
|
||||||
|
CefString ProxyList() const { return CefString(&proxyList); }
|
||||||
|
};
|
||||||
|
|
||||||
#endif // _CEF_TYPES_WRAPPERS_H
|
#endif // _CEF_TYPES_WRAPPERS_H
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "net/http/http_server_properties_impl.h"
|
#include "net/http/http_server_properties_impl.h"
|
||||||
#include "net/proxy/proxy_config_service.h"
|
#include "net/proxy/proxy_config_service.h"
|
||||||
#include "net/proxy/proxy_config_service_fixed.h"
|
#include "net/proxy/proxy_config_service_fixed.h"
|
||||||
|
#include "net/proxy/proxy_resolver.h"
|
||||||
#include "net/proxy/proxy_service.h"
|
#include "net/proxy/proxy_service.h"
|
||||||
#include "net/url_request/url_request_job_factory.h"
|
#include "net/url_request/url_request_job_factory.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
|
||||||
@ -46,14 +47,75 @@ namespace {
|
|||||||
class ProxyConfigServiceNull : public net::ProxyConfigService {
|
class ProxyConfigServiceNull : public net::ProxyConfigService {
|
||||||
public:
|
public:
|
||||||
ProxyConfigServiceNull() {}
|
ProxyConfigServiceNull() {}
|
||||||
virtual void AddObserver(Observer* observer) {}
|
virtual void AddObserver(Observer* observer) OVERRIDE {}
|
||||||
virtual void RemoveObserver(Observer* observer) {}
|
virtual void RemoveObserver(Observer* observer) OVERRIDE {}
|
||||||
virtual ProxyConfigService::ConfigAvailability
|
virtual ProxyConfigService::ConfigAvailability
|
||||||
GetLatestProxyConfig(net::ProxyConfig* config)
|
GetLatestProxyConfig(net::ProxyConfig* config) OVERRIDE
|
||||||
{ return ProxyConfigService::CONFIG_VALID; }
|
{ return ProxyConfigService::CONFIG_VALID; }
|
||||||
virtual void OnLazyPoll() {}
|
virtual void OnLazyPoll() OVERRIDE {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ProxyResolver implementation that forewards resolution to a CefProxyHandler.
|
||||||
|
class CefProxyResolver : public net::ProxyResolver {
|
||||||
|
public:
|
||||||
|
CefProxyResolver(CefRefPtr<CefProxyHandler> handler)
|
||||||
|
: ProxyResolver(false),
|
||||||
|
handler_(handler) {}
|
||||||
|
virtual ~CefProxyResolver() {}
|
||||||
|
|
||||||
|
virtual int GetProxyForURL(const GURL& url,
|
||||||
|
net::ProxyInfo* results,
|
||||||
|
net::OldCompletionCallback* callback,
|
||||||
|
ProxyResolver::RequestHandle* request,
|
||||||
|
const net::BoundNetLog& net_log) OVERRIDE
|
||||||
|
{
|
||||||
|
CefProxyInfo proxy_info;
|
||||||
|
handler_->GetProxyForUrl(url.spec(), proxy_info);
|
||||||
|
if (proxy_info.IsDirect())
|
||||||
|
results->UseDirect();
|
||||||
|
else if (proxy_info.IsNamedProxy())
|
||||||
|
results->UseNamedProxy(proxy_info.ProxyList());
|
||||||
|
else if (proxy_info.IsPacString())
|
||||||
|
results->UsePacString(proxy_info.ProxyList());
|
||||||
|
|
||||||
|
return net::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int SetPacScript(
|
||||||
|
const scoped_refptr<net::ProxyResolverScriptData>& script_data,
|
||||||
|
net::OldCompletionCallback* callback) OVERRIDE
|
||||||
|
{
|
||||||
|
return net::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void CancelRequest(RequestHandle request) OVERRIDE {}
|
||||||
|
virtual net::LoadState GetLoadState(RequestHandle request) const OVERRIDE
|
||||||
|
{ return net::LOAD_STATE_IDLE; }
|
||||||
|
virtual net::LoadState GetLoadStateThreadSafe(RequestHandle request) const
|
||||||
|
OVERRIDE { return net::LOAD_STATE_IDLE; }
|
||||||
|
virtual void CancelSetPacScript() OVERRIDE {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CefRefPtr<CefProxyHandler> handler_;
|
||||||
|
};
|
||||||
|
|
||||||
|
net::ProxyConfigService* CreateProxyConfigService() {
|
||||||
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||||
|
// Use no proxy to avoid ProxyConfigServiceLinux.
|
||||||
|
// Enabling use of the ProxyConfigServiceLinux requires:
|
||||||
|
// -Calling from a thread with a TYPE_UI MessageLoop,
|
||||||
|
// -If at all possible, passing in a pointer to the IO thread's MessageLoop,
|
||||||
|
// -Keep in mind that proxy auto configuration is also non-functional on linux
|
||||||
|
// in this context because of v8 threading issues.
|
||||||
|
// TODO(port): rename "linux" to some nonspecific unix.
|
||||||
|
return new net::ProxyConfigServiceFixed(net::ProxyConfig());
|
||||||
|
#else
|
||||||
|
// Use the system proxy settings.
|
||||||
|
return net::ProxyService::CreateSystemProxyConfigService(
|
||||||
|
MessageLoop::current(), NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
@ -95,54 +157,51 @@ void BrowserRequestContext::Init(
|
|||||||
set_accept_language("en-us,en");
|
set_accept_language("en-us,en");
|
||||||
set_accept_charset("iso-8859-1,*,utf-8");
|
set_accept_charset("iso-8859-1,*,utf-8");
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
CefRefPtr<CefApp> app = _Context->application();
|
||||||
const CefSettings& settings = _Context->settings();
|
if (app.get()) {
|
||||||
if (!settings.auto_detect_proxy_settings_enabled) {
|
CefRefPtr<CefProxyHandler> handler = app->GetProxyHandler();
|
||||||
// Using the system proxy resolver on Windows when "Automatically detect
|
if (handler) {
|
||||||
// settings" (auto-detection) is checked under LAN Settings can hurt
|
// The client will provide proxy resolution.
|
||||||
// resource loading performance because the call to WinHttpGetProxyForUrl in
|
storage_.set_proxy_service(
|
||||||
// proxy_resolver_winhttp.cc will block the IO thread. This is especially
|
new net::ProxyService(CreateProxyConfigService(),
|
||||||
// true for Windows 7 where auto-detection is checked by default. To avoid
|
new CefProxyResolver(handler), NULL));
|
||||||
// slow resource loading on Windows we only use the system proxy resolver if
|
}
|
||||||
// auto-detection is unchecked.
|
}
|
||||||
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config = {0};
|
|
||||||
if (WinHttpGetIEProxyConfigForCurrentUser(&ie_config)) {
|
|
||||||
if (ie_config.fAutoDetect == TRUE) {
|
|
||||||
storage_.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver(
|
|
||||||
new ProxyConfigServiceNull(), NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ie_config.lpszAutoConfigUrl)
|
#if defined(OS_WIN)
|
||||||
GlobalFree(ie_config.lpszAutoConfigUrl);
|
if (!proxy_service()) {
|
||||||
if (ie_config.lpszProxy)
|
const CefSettings& settings = _Context->settings();
|
||||||
GlobalFree(ie_config.lpszProxy);
|
if (!settings.auto_detect_proxy_settings_enabled) {
|
||||||
if (ie_config.lpszProxyBypass)
|
// Using the system proxy resolver on Windows when "Automatically detect
|
||||||
GlobalFree(ie_config.lpszProxyBypass);
|
// settings" (auto-detection) is checked under LAN Settings can hurt
|
||||||
|
// resource loading performance because the call to WinHttpGetProxyForUrl
|
||||||
|
// in proxy_resolver_winhttp.cc will block the IO thread. This is
|
||||||
|
// especially true for Windows 7 where auto-detection is checked by
|
||||||
|
// default. To avoid slow resource loading on Windows we only use the
|
||||||
|
// system proxy resolver if auto-detection is unchecked.
|
||||||
|
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config = {0};
|
||||||
|
if (WinHttpGetIEProxyConfigForCurrentUser(&ie_config)) {
|
||||||
|
if (ie_config.fAutoDetect == TRUE) {
|
||||||
|
storage_.set_proxy_service(
|
||||||
|
net::ProxyService::CreateWithoutProxyResolver(
|
||||||
|
new ProxyConfigServiceNull(), NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ie_config.lpszAutoConfigUrl)
|
||||||
|
GlobalFree(ie_config.lpszAutoConfigUrl);
|
||||||
|
if (ie_config.lpszProxy)
|
||||||
|
GlobalFree(ie_config.lpszProxy);
|
||||||
|
if (ie_config.lpszProxyBypass)
|
||||||
|
GlobalFree(ie_config.lpszProxyBypass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
if (!proxy_service()) {
|
if (!proxy_service()) {
|
||||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
storage_.set_proxy_service(
|
||||||
// Use no proxy to avoid ProxyConfigServiceLinux.
|
net::ProxyService::CreateUsingSystemProxyResolver(
|
||||||
// Enabling use of the ProxyConfigServiceLinux requires:
|
CreateProxyConfigService(), 0, NULL));
|
||||||
// -Calling from a thread with a TYPE_UI MessageLoop,
|
|
||||||
// -If at all possible, passing in a pointer to the IO thread's MessageLoop,
|
|
||||||
// -Keep in mind that proxy auto configuration is also
|
|
||||||
// non-functional on linux in this context because of v8 threading
|
|
||||||
// issues.
|
|
||||||
// TODO(port): rename "linux" to some nonspecific unix.
|
|
||||||
scoped_ptr<net::ProxyConfigService> proxy_config_service(
|
|
||||||
new net::ProxyConfigServiceFixed(net::ProxyConfig()));
|
|
||||||
#else
|
|
||||||
// Use the system proxy settings.
|
|
||||||
scoped_ptr<net::ProxyConfigService> proxy_config_service(
|
|
||||||
net::ProxyService::CreateSystemProxyConfigService(
|
|
||||||
MessageLoop::current(), NULL));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver(
|
|
||||||
proxy_config_service.release(), 0, NULL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storage_.set_host_resolver(
|
storage_.set_host_resolver(
|
||||||
|
@ -348,7 +348,7 @@ void UIT_SetStoragePath(int64 namespace_id, const CefString& path)
|
|||||||
|
|
||||||
} // anonymous
|
} // anonymous
|
||||||
|
|
||||||
bool CefInitialize(const CefSettings& settings)
|
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application)
|
||||||
{
|
{
|
||||||
// Return true if the global context already exists.
|
// Return true if the global context already exists.
|
||||||
if(_Context.get())
|
if(_Context.get())
|
||||||
@ -363,7 +363,7 @@ bool CefInitialize(const CefSettings& settings)
|
|||||||
_Context = new CefContext();
|
_Context = new CefContext();
|
||||||
|
|
||||||
// Initialize the global context.
|
// Initialize the global context.
|
||||||
return _Context->Initialize(settings);
|
return _Context->Initialize(settings, application);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefShutdown()
|
void CefShutdown()
|
||||||
@ -842,9 +842,11 @@ CefContext::~CefContext()
|
|||||||
Shutdown();
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefContext::Initialize(const CefSettings& settings)
|
bool CefContext::Initialize(const CefSettings& settings,
|
||||||
|
CefRefPtr<CefApp> application)
|
||||||
{
|
{
|
||||||
settings_ = settings;
|
settings_ = settings;
|
||||||
|
application_ = application;
|
||||||
|
|
||||||
cache_path_ = FilePath(CefString(&settings.cache_path));
|
cache_path_ = FilePath(CefString(&settings.cache_path));
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
~CefContext();
|
~CefContext();
|
||||||
|
|
||||||
// These methods will be called on the main application thread.
|
// These methods will be called on the main application thread.
|
||||||
bool Initialize(const CefSettings& settings);
|
bool Initialize(const CefSettings& settings, CefRefPtr<CefApp> application);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
// Returns true if the context is initialized.
|
// Returns true if the context is initialized.
|
||||||
@ -52,6 +52,7 @@ public:
|
|||||||
const FilePath& cache_path() const { return cache_path_; }
|
const FilePath& cache_path() const { return cache_path_; }
|
||||||
|
|
||||||
const CefSettings& settings() const { return settings_; }
|
const CefSettings& settings() const { return settings_; }
|
||||||
|
CefRefPtr<CefApp> application() const { return application_; }
|
||||||
|
|
||||||
// Return the locale specified in CefSettings or the default value of "en-US".
|
// Return the locale specified in CefSettings or the default value of "en-US".
|
||||||
std::string locale() const;
|
std::string locale() const;
|
||||||
@ -94,6 +95,7 @@ private:
|
|||||||
base::AtExitManager at_exit_manager_;
|
base::AtExitManager at_exit_manager_;
|
||||||
|
|
||||||
CefSettings settings_;
|
CefSettings settings_;
|
||||||
|
CefRefPtr<CefApp> application_;
|
||||||
FilePath cache_path_;
|
FilePath cache_path_;
|
||||||
scoped_refptr<BrowserRequestContext> request_context_;
|
scoped_refptr<BrowserRequestContext> request_context_;
|
||||||
scoped_ptr<DOMStorageContext> storage_context_;
|
scoped_ptr<DOMStorageContext> storage_context_;
|
||||||
|
45
libcef_dll/cpptoc/app_cpptoc.cc
Normal file
45
libcef_dll/cpptoc/app_cpptoc.cc
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// A portion of this file was generated by the CEF translator tool. When
|
||||||
|
// making changes by hand only do so within the body of existing function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(struct _cef_app_t* self)
|
||||||
|
{
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
CefRefPtr<CefProxyHandler> handlerPtr =
|
||||||
|
CefAppCppToC::Get(self)->GetProxyHandler();
|
||||||
|
if(handlerPtr.get())
|
||||||
|
return CefProxyHandlerCppToC::Wrap(handlerPtr);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefAppCppToC::CefAppCppToC(CefApp* cls)
|
||||||
|
: CefCppToC<CefAppCppToC, CefApp, cef_app_t>(cls)
|
||||||
|
{
|
||||||
|
struct_.struct_.get_proxy_handler = app_get_proxy_handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefAppCppToC, CefApp, cef_app_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
34
libcef_dll/cpptoc/app_cpptoc.h
Normal file
34
libcef_dll/cpptoc/app_cpptoc.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
#ifndef _APP_CPPTOC_H
|
||||||
|
#define _APP_CPPTOC_H
|
||||||
|
|
||||||
|
#ifndef USING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef.h"
|
||||||
|
#include "include/cef_capi.h"
|
||||||
|
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||||
|
|
||||||
|
// Wrap a C++ class with a C structure.
|
||||||
|
// This class may be instantiated and accessed wrapper-side only.
|
||||||
|
class CefAppCppToC
|
||||||
|
: public CefCppToC<CefAppCppToC, CefApp, cef_app_t>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefAppCppToC(CefApp* cls);
|
||||||
|
virtual ~CefAppCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // _APP_CPPTOC_H
|
||||||
|
|
53
libcef_dll/cpptoc/proxy_handler_cpptoc.cc
Normal file
53
libcef_dll/cpptoc/proxy_handler_cpptoc.cc
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// A portion of this file was generated by the CEF translator tool. When
|
||||||
|
// making changes by hand only do so within the body of existing function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK proxy_handler_get_proxy_for_url(
|
||||||
|
struct _cef_proxy_handler_t* self, const cef_string_t* url,
|
||||||
|
struct _cef_proxy_info_t* proxy_info)
|
||||||
|
{
|
||||||
|
DCHECK(self);
|
||||||
|
DCHECK(url);
|
||||||
|
DCHECK(proxy_info);
|
||||||
|
if (!self || !url || !proxy_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CefProxyInfo info;
|
||||||
|
|
||||||
|
// Take ownership of the values.
|
||||||
|
info.AttachTo(*proxy_info);
|
||||||
|
|
||||||
|
CefProxyHandlerCppToC::Get(self)->GetProxyForUrl(CefString(url), info);
|
||||||
|
|
||||||
|
// Return the values to the structure.
|
||||||
|
info.DetachTo(*proxy_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefProxyHandlerCppToC::CefProxyHandlerCppToC(CefProxyHandler* cls)
|
||||||
|
: CefCppToC<CefProxyHandlerCppToC, CefProxyHandler, cef_proxy_handler_t>(
|
||||||
|
cls)
|
||||||
|
{
|
||||||
|
struct_.struct_.get_proxy_for_url = proxy_handler_get_proxy_for_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefProxyHandlerCppToC, CefProxyHandler,
|
||||||
|
cef_proxy_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
35
libcef_dll/cpptoc/proxy_handler_cpptoc.h
Normal file
35
libcef_dll/cpptoc/proxy_handler_cpptoc.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
#ifndef _PROXYHANDLER_CPPTOC_H
|
||||||
|
#define _PROXYHANDLER_CPPTOC_H
|
||||||
|
|
||||||
|
#ifndef USING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef.h"
|
||||||
|
#include "include/cef_capi.h"
|
||||||
|
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||||
|
|
||||||
|
// Wrap a C++ class with a C structure.
|
||||||
|
// This class may be instantiated and accessed wrapper-side only.
|
||||||
|
class CefProxyHandlerCppToC
|
||||||
|
: public CefCppToC<CefProxyHandlerCppToC, CefProxyHandler,
|
||||||
|
cef_proxy_handler_t>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefProxyHandlerCppToC(CefProxyHandler* cls);
|
||||||
|
virtual ~CefProxyHandlerCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // _PROXYHANDLER_CPPTOC_H
|
||||||
|
|
35
libcef_dll/ctocpp/app_ctocpp.cc
Normal file
35
libcef_dll/ctocpp/app_ctocpp.cc
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// A portion of this file was generated by the CEF translator tool. When
|
||||||
|
// making changes by hand only do so within the body of existing static and
|
||||||
|
// virtual method implementations. See the translator.README.txt file in the
|
||||||
|
// tools directory for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/ctocpp/app_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
CefRefPtr<CefProxyHandler> CefAppCToCpp::GetProxyHandler()
|
||||||
|
{
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_proxy_handler))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cef_proxy_handler_t* handlerStruct = struct_->get_proxy_handler(struct_);
|
||||||
|
if(handlerStruct)
|
||||||
|
return CefProxyHandlerCToCpp::Wrap(handlerStruct);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefAppCToCpp, CefApp, cef_app_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
39
libcef_dll/ctocpp/app_ctocpp.h
Normal file
39
libcef_dll/ctocpp/app_ctocpp.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _APP_CTOCPP_H
|
||||||
|
#define _APP_CTOCPP_H
|
||||||
|
|
||||||
|
#ifndef BUILDING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||||
|
#else // BUILDING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef.h"
|
||||||
|
#include "include/cef_capi.h"
|
||||||
|
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||||
|
|
||||||
|
// Wrap a C structure with a C++ class.
|
||||||
|
// This class may be instantiated and accessed DLL-side only.
|
||||||
|
class CefAppCToCpp
|
||||||
|
: public CefCToCpp<CefAppCToCpp, CefApp, cef_app_t>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefAppCToCpp(cef_app_t* str)
|
||||||
|
: CefCToCpp<CefAppCToCpp, CefApp, cef_app_t>(str) {}
|
||||||
|
virtual ~CefAppCToCpp() {}
|
||||||
|
|
||||||
|
// CefApp methods
|
||||||
|
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // _APP_CTOCPP_H
|
||||||
|
|
32
libcef_dll/ctocpp/proxy_handler_ctocpp.cc
Normal file
32
libcef_dll/ctocpp/proxy_handler_ctocpp.cc
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// A portion of this file was generated by the CEF translator tool. When
|
||||||
|
// making changes by hand only do so within the body of existing static and
|
||||||
|
// virtual method implementations. See the translator.README.txt file in the
|
||||||
|
// tools directory for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefProxyHandlerCToCpp::GetProxyForUrl(const CefString& url,
|
||||||
|
CefProxyInfo& proxy_info)
|
||||||
|
{
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_proxy_for_url))
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct_->get_proxy_for_url(struct_, url.GetStruct(), &proxy_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefProxyHandlerCToCpp, CefProxyHandler,
|
||||||
|
cef_proxy_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
42
libcef_dll/ctocpp/proxy_handler_ctocpp.h
Normal file
42
libcef_dll/ctocpp/proxy_handler_ctocpp.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _PROXYHANDLER_CTOCPP_H
|
||||||
|
#define _PROXYHANDLER_CTOCPP_H
|
||||||
|
|
||||||
|
#ifndef BUILDING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||||
|
#else // BUILDING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef.h"
|
||||||
|
#include "include/cef_capi.h"
|
||||||
|
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||||
|
|
||||||
|
// Wrap a C structure with a C++ class.
|
||||||
|
// This class may be instantiated and accessed DLL-side only.
|
||||||
|
class CefProxyHandlerCToCpp
|
||||||
|
: public CefCToCpp<CefProxyHandlerCToCpp, CefProxyHandler,
|
||||||
|
cef_proxy_handler_t>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefProxyHandlerCToCpp(cef_proxy_handler_t* str)
|
||||||
|
: CefCToCpp<CefProxyHandlerCToCpp, CefProxyHandler, cef_proxy_handler_t>(
|
||||||
|
str) {}
|
||||||
|
virtual ~CefProxyHandlerCToCpp() {}
|
||||||
|
|
||||||
|
// CefProxyHandler methods
|
||||||
|
virtual void GetProxyForUrl(const CefString& url,
|
||||||
|
CefProxyInfo& proxy_info) OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // _PROXYHANDLER_CTOCPP_H
|
||||||
|
|
@ -22,6 +22,7 @@
|
|||||||
#include "cpptoc/web_urlrequest_cpptoc.h"
|
#include "cpptoc/web_urlrequest_cpptoc.h"
|
||||||
#include "cpptoc/xml_reader_cpptoc.h"
|
#include "cpptoc/xml_reader_cpptoc.h"
|
||||||
#include "cpptoc/zip_reader_cpptoc.h"
|
#include "cpptoc/zip_reader_cpptoc.h"
|
||||||
|
#include "ctocpp/app_ctocpp.h"
|
||||||
#include "ctocpp/content_filter_ctocpp.h"
|
#include "ctocpp/content_filter_ctocpp.h"
|
||||||
#include "ctocpp/cookie_visitor_ctocpp.h"
|
#include "ctocpp/cookie_visitor_ctocpp.h"
|
||||||
#include "ctocpp/domevent_listener_ctocpp.h"
|
#include "ctocpp/domevent_listener_ctocpp.h"
|
||||||
@ -44,7 +45,8 @@ CEF_EXPORT int cef_build_revision()
|
|||||||
return CEF_REVISION;
|
return CEF_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings)
|
CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings,
|
||||||
|
struct _cef_app_t* application)
|
||||||
{
|
{
|
||||||
CefSettings settingsObj;
|
CefSettings settingsObj;
|
||||||
|
|
||||||
@ -52,9 +54,7 @@ CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings)
|
|||||||
if (settings)
|
if (settings)
|
||||||
settingsObj.Set(*settings, false);
|
settingsObj.Set(*settings, false);
|
||||||
|
|
||||||
int ret = CefInitialize(settingsObj);
|
return CefInitialize(settingsObj, CefAppCToCpp::Wrap(application));
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CEF_EXPORT void cef_shutdown()
|
CEF_EXPORT void cef_shutdown()
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "include/cef_nplugin.h"
|
#include "include/cef_nplugin.h"
|
||||||
#include "include/cef_nplugin_capi.h"
|
#include "include/cef_nplugin_capi.h"
|
||||||
#include "include/cef_version.h"
|
#include "include/cef_version.h"
|
||||||
|
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
|
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
||||||
@ -37,7 +38,7 @@
|
|||||||
#include "libcef_dll/ctocpp/zip_reader_ctocpp.h"
|
#include "libcef_dll/ctocpp/zip_reader_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
bool CefInitialize(const CefSettings& settings)
|
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application)
|
||||||
{
|
{
|
||||||
int build_revision = cef_build_revision();
|
int build_revision = cef_build_revision();
|
||||||
if (build_revision != CEF_REVISION) {
|
if (build_revision != CEF_REVISION) {
|
||||||
@ -45,8 +46,8 @@ bool CefInitialize(const CefSettings& settings)
|
|||||||
DCHECK(false);
|
DCHECK(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cef_initialize(&settings)?true:false;
|
return cef_initialize(&settings, CefAppCppToC::Wrap(application))?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefShutdown()
|
void CefShutdown()
|
||||||
|
@ -73,6 +73,37 @@ int GetIntValue(const CefString& str)
|
|||||||
return atoi(stdStr.c_str());
|
return atoi(stdStr.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ClientApp implementation.
|
||||||
|
class ClientApp : public CefApp,
|
||||||
|
public CefProxyHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClientApp(cef_proxy_type_t proxy_type, const CefString& proxy_config)
|
||||||
|
: proxy_type_(proxy_type),
|
||||||
|
proxy_config_(proxy_config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// CefApp methods
|
||||||
|
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||||
|
|
||||||
|
// CefProxyHandler methods
|
||||||
|
virtual void GetProxyForUrl(const CefString& url,
|
||||||
|
CefProxyInfo& proxy_info) OVERRIDE
|
||||||
|
{
|
||||||
|
proxy_info.proxyType = proxy_type_;
|
||||||
|
if (!proxy_config_.empty())
|
||||||
|
CefString(&proxy_info.proxyList) = proxy_config_;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cef_proxy_type_t proxy_type_;
|
||||||
|
CefString proxy_config_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefRefPtr<ClientHandler> g_handler;
|
CefRefPtr<ClientHandler> g_handler;
|
||||||
@ -109,7 +140,7 @@ CefRefPtr<CefCommandLine> AppGetCommandLine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns the application settings based on command line arguments.
|
// Returns the application settings based on command line arguments.
|
||||||
void AppGetSettings(CefSettings& settings)
|
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app)
|
||||||
{
|
{
|
||||||
ASSERT(g_command_line.get());
|
ASSERT(g_command_line.get());
|
||||||
if (!g_command_line.get())
|
if (!g_command_line.get())
|
||||||
@ -184,6 +215,32 @@ void AppGetSettings(CefSettings& settings)
|
|||||||
|
|
||||||
CefString(&settings.javascript_flags) =
|
CefString(&settings.javascript_flags) =
|
||||||
g_command_line->GetSwitchValue(cefclient::kJavascriptFlags);
|
g_command_line->GetSwitchValue(cefclient::kJavascriptFlags);
|
||||||
|
|
||||||
|
// Retrieve command-line proxy configuration, if any.
|
||||||
|
bool has_proxy = false;
|
||||||
|
cef_proxy_type_t proxy_type;
|
||||||
|
CefString proxy_config;
|
||||||
|
|
||||||
|
if (g_command_line->HasSwitch(cefclient::kProxyType)) {
|
||||||
|
std::string str = g_command_line->GetSwitchValue(cefclient::kProxyType);
|
||||||
|
if (str == cefclient::kProxyType_Direct) {
|
||||||
|
has_proxy = true;
|
||||||
|
proxy_type = PROXY_TYPE_DIRECT;
|
||||||
|
} else if (str == cefclient::kProxyType_Named ||
|
||||||
|
str == cefclient::kProxyType_Pac) {
|
||||||
|
proxy_config = g_command_line->GetSwitchValue(cefclient::kProxyConfig);
|
||||||
|
if (!proxy_config.empty()) {
|
||||||
|
has_proxy = true;
|
||||||
|
proxy_type = (str == cefclient::kProxyType_Named?
|
||||||
|
PROXY_TYPE_NAMED:PROXY_TYPE_PAC_STRING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_proxy) {
|
||||||
|
// Provide a ClientApp instance to handle proxy resolution.
|
||||||
|
app = new ClientApp(proxy_type, proxy_config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the application browser settings based on command line arguments.
|
// Returns the application browser settings based on command line arguments.
|
||||||
|
@ -23,7 +23,7 @@ void AppInitCommandLine(int argc, const char* const* argv);
|
|||||||
CefRefPtr<CefCommandLine> AppGetCommandLine();
|
CefRefPtr<CefCommandLine> AppGetCommandLine();
|
||||||
|
|
||||||
// Returns the application settings based on command line arguments.
|
// Returns the application settings based on command line arguments.
|
||||||
void AppGetSettings(CefSettings& settings);
|
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app);
|
||||||
|
|
||||||
// Returns the application browser settings based on command line arguments.
|
// Returns the application browser settings based on command line arguments.
|
||||||
void AppGetBrowserSettings(CefBrowserSettings& settings);
|
void AppGetBrowserSettings(CefBrowserSettings& settings);
|
||||||
|
@ -327,11 +327,13 @@ int main(int argc, char *argv[]) {
|
|||||||
AppInitCommandLine(argc, argv);
|
AppInitCommandLine(argc, argv);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
|
CefRefPtr<CefApp> app;
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
CefInitialize(settings);
|
// Initialize CEF.
|
||||||
|
CefInitialize(settings, app);
|
||||||
|
|
||||||
// Register the V8 extension handler.
|
// Register the V8 extension handler.
|
||||||
InitExtensionTest();
|
InitExtensionTest();
|
||||||
|
@ -549,13 +549,14 @@ int main(int argc, char* argv[])
|
|||||||
// Parse command line arguments.
|
// Parse command line arguments.
|
||||||
AppInitCommandLine(argc, argv);
|
AppInitCommandLine(argc, argv);
|
||||||
|
|
||||||
// Initialize CEF.
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
|
CefRefPtr<CefApp> app;
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
CefInitialize(settings);
|
// Initialize CEF.
|
||||||
|
CefInitialize(settings, app);
|
||||||
|
|
||||||
// Initialize tests.
|
// Initialize tests.
|
||||||
InitExtensionTest();
|
InitExtensionTest();
|
||||||
|
@ -76,4 +76,11 @@ const char kAcceleratedDrawingDisabled[] = "accelerated-drawing-disabled";
|
|||||||
const char kAcceleratedPluginsDisabled[] = "accelerated-plugins-disabled";
|
const char kAcceleratedPluginsDisabled[] = "accelerated-plugins-disabled";
|
||||||
const char kDeveloperToolsDisabled[] = "developer-tools-disabled";
|
const char kDeveloperToolsDisabled[] = "developer-tools-disabled";
|
||||||
|
|
||||||
|
// Other attributes.
|
||||||
|
const char kProxyType[] = "proxy-type";
|
||||||
|
const char kProxyType_Direct[] = "direct";
|
||||||
|
const char kProxyType_Named[] = "named";
|
||||||
|
const char kProxyType_Pac[] = "pac";
|
||||||
|
const char kProxyConfig[] = "proxy-config";
|
||||||
|
|
||||||
} // namespace cefclient
|
} // namespace cefclient
|
||||||
|
@ -74,6 +74,13 @@ extern const char kAcceleratedDrawingDisabled[];
|
|||||||
extern const char kAcceleratedPluginsDisabled[];
|
extern const char kAcceleratedPluginsDisabled[];
|
||||||
extern const char kDeveloperToolsDisabled[];
|
extern const char kDeveloperToolsDisabled[];
|
||||||
|
|
||||||
|
// Other attributes.
|
||||||
|
extern const char kProxyType[];
|
||||||
|
extern const char kProxyType_Direct[];
|
||||||
|
extern const char kProxyType_Named[];
|
||||||
|
extern const char kProxyType_Pac[];
|
||||||
|
extern const char kProxyConfig[];
|
||||||
|
|
||||||
} // namespace cefclient
|
} // namespace cefclient
|
||||||
|
|
||||||
#endif // _CEFCLIENT_SWITCHES_H
|
#endif // _CEFCLIENT_SWITCHES_H
|
||||||
|
@ -65,12 +65,13 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
|||||||
AppInitCommandLine(0, NULL);
|
AppInitCommandLine(0, NULL);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
|
CefRefPtr<CefApp> app;
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
// Initialize CEF.
|
// Initialize CEF.
|
||||||
CefInitialize(settings);
|
CefInitialize(settings, app);
|
||||||
|
|
||||||
// Register the internal client plugin.
|
// Register the internal client plugin.
|
||||||
InitPluginTest();
|
InitPluginTest();
|
||||||
|
@ -26,7 +26,7 @@ void CefTestSuite::Initialize() {
|
|||||||
CefString(&settings.cache_path).FromASCII(cache_path.c_str());
|
CefString(&settings.cache_path).FromASCII(cache_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CefInitialize(settings);
|
CefInitialize(settings, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefTestSuite::Shutdown() {
|
void CefTestSuite::Shutdown() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user