mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Introduce chrome proxy implementation based on command-line flags (issue #600).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1080 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -76,32 +76,6 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<ClientApp> app) {
|
||||
|
||||
CefString(&settings.cache_path) =
|
||||
g_command_line->GetSwitchValue(cefclient::kCachePath);
|
||||
|
||||
// Retrieve command-line proxy configuration, if any.
|
||||
bool has_proxy = false;
|
||||
cef_proxy_type_t proxy_type = CEF_PROXY_TYPE_DIRECT;
|
||||
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 = CEF_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?
|
||||
CEF_PROXY_TYPE_NAMED:CEF_PROXY_TYPE_PAC_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (has_proxy) {
|
||||
// Provide a ClientApp instance to handle proxy resolution.
|
||||
app->SetProxyConfig(proxy_type, proxy_config);
|
||||
}
|
||||
}
|
||||
|
||||
bool AppIsOffScreenRenderingEnabled() {
|
||||
|
@@ -174,8 +174,7 @@ class ClientAppExtensionHandler : public CefV8Handler {
|
||||
} // namespace
|
||||
|
||||
|
||||
ClientApp::ClientApp()
|
||||
: proxy_type_(CEF_PROXY_TYPE_DIRECT) {
|
||||
ClientApp::ClientApp() {
|
||||
CreateBrowserDelegates(browser_delegates_);
|
||||
CreateRenderDelegates(render_delegates_);
|
||||
|
||||
@@ -234,13 +233,6 @@ void ClientApp::OnRenderProcessThreadCreated(
|
||||
(*it)->OnRenderProcessThreadCreated(this, extra_info);
|
||||
}
|
||||
|
||||
void ClientApp::GetProxyForUrl(const CefString& url,
|
||||
CefProxyInfo& proxy_info) {
|
||||
proxy_info.proxyType = proxy_type_;
|
||||
if (!proxy_config_.empty())
|
||||
CefString(&proxy_info.proxyList) = proxy_config_;
|
||||
}
|
||||
|
||||
void ClientApp::OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) {
|
||||
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||
for (; it != render_delegates_.end(); ++it)
|
||||
|
@@ -15,7 +15,6 @@
|
||||
|
||||
class ClientApp : public CefApp,
|
||||
public CefBrowserProcessHandler,
|
||||
public CefProxyHandler,
|
||||
public CefRenderProcessHandler {
|
||||
public:
|
||||
// Interface for browser delegates. All BrowserDelegates must be returned via
|
||||
@@ -118,13 +117,6 @@ class ClientApp : public CefApp,
|
||||
|
||||
ClientApp();
|
||||
|
||||
// Set the proxy configuration. Should only be called during initialization.
|
||||
void SetProxyConfig(cef_proxy_type_t proxy_type,
|
||||
const CefString& proxy_config) {
|
||||
proxy_type_ = proxy_type;
|
||||
proxy_config_ = proxy_config;
|
||||
}
|
||||
|
||||
// Set a JavaScript callback for the specified |message_name| and |browser_id|
|
||||
// combination. Will automatically be removed when the associated context is
|
||||
// released. Callbacks can also be set in JavaScript using the
|
||||
@@ -165,17 +157,12 @@ class ClientApp : public CefApp,
|
||||
OVERRIDE { return this; }
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||
virtual void OnContextInitialized() OVERRIDE;
|
||||
virtual void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||
virtual void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info)
|
||||
OVERRIDE;
|
||||
|
||||
// CefProxyHandler methods.
|
||||
virtual void GetProxyForUrl(const CefString& url,
|
||||
CefProxyInfo& proxy_info) OVERRIDE;
|
||||
|
||||
// CefRenderProcessHandler methods.
|
||||
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info)
|
||||
OVERRIDE;
|
||||
@@ -222,10 +209,6 @@ class ClientApp : public CefApp,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||
|
||||
// Proxy configuration.
|
||||
cef_proxy_type_t proxy_type_;
|
||||
CefString proxy_config_;
|
||||
|
||||
// Map of message callbacks.
|
||||
typedef std::map<std::pair<std::string, int>,
|
||||
std::pair<CefRefPtr<CefV8Context>, CefRefPtr<CefV8Value> > >
|
||||
|
@@ -60,11 +60,4 @@ const char kDeveloperToolsDisabled[] = "developer-tools-disabled";
|
||||
const char kOffScreenRenderingEnabled[] = "off-screen-rendering-enabled";
|
||||
const char kTransparentPaintingEnabled[] = "transparent-painting-enabled";
|
||||
|
||||
// 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
|
||||
|
@@ -56,13 +56,6 @@ extern const char kDeveloperToolsDisabled[];
|
||||
extern const char kOffScreenRenderingEnabled[];
|
||||
extern const char kTransparentPaintingEnabled[];
|
||||
|
||||
// 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
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_
|
||||
|
Reference in New Issue
Block a user