From be50ca26539e0cbcc58671aa8f229616d4125282 Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 11 Jan 2016 03:55:56 +0530 Subject: [PATCH] session: allow user to isolate pac script and proxy bypass rules --- atom/browser/api/atom_api_session.cc | 14 +++++++------- docs/api/session.md | 10 ++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 8b73d61622e..0b2f4f9be97 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -114,15 +114,15 @@ struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, net::ProxyConfig* out) { - std::string proxy; - if (!ConvertFromV8(isolate, val, &proxy)) + mate::Dictionary options; + if (!ConvertFromV8(isolate, val, &options)) return false; - auto pac_url = GURL(proxy); - if (pac_url.is_valid()) { + GURL pac_url; + std::string rules; + if (options.Get("pacScript", &pac_url)) out->set_pac_url(pac_url); - } else { - out->proxy_rules().ParseFromString(proxy); - } + else if (options.Get("proxyRules", &rules)) + out->proxy_rules().ParseFromString(rules); return true; } }; diff --git a/docs/api/session.md b/docs/api/session.md index 09fa61e2112..67dd537d44e 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -181,15 +181,13 @@ Clears the data of web storages. #### `ses.setProxy(config, callback)` -* `config` String +* `config` Object + * `pacScript` String - The URL associated with the PAC file. + * `proxyRules` String - Rules indicating which proxies to use. * `callback` Function - Called when operation is done. -If `config` is a PAC url, it is used directly otherwise -`config` is parsed based on the following rules indicating which -proxies to use for the session. - ``` -config = scheme-proxies[";"] +proxyRules = scheme-proxies[";"] scheme-proxies = ["="] url-scheme = "http" | "https" | "ftp" | "socks" proxy-uri-list = [","]