session: allow user to isolate pac script and proxy bypass rules
authorRobo <hop2deep@gmail.com>
Sun, 10 Jan 2016 22:25:56 +0000 (03:55 +0530)
committerRobo <hop2deep@gmail.com>
Sun, 10 Jan 2016 22:25:56 +0000 (03:55 +0530)
atom/browser/api/atom_api_session.cc
docs/api/session.md

index 8b73d61..0b2f4f9 100644 (file)
@@ -114,15 +114,15 @@ struct Converter<net::ProxyConfig> {
   static bool FromV8(v8::Isolate* isolate,
                      v8::Local<v8::Value> 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;
   }
 };
index 09fa61e..67dd537 100644 (file)
@@ -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[";"<scheme-proxies>]
+proxyRules = scheme-proxies[";"<scheme-proxies>]
 scheme-proxies = [<url-scheme>"="]<proxy-uri-list>
 url-scheme = "http" | "https" | "ftp" | "socks"
 proxy-uri-list = <proxy-uri>[","<proxy-uri-list>]