summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 12:41:46 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 12:41:46 +0000
commitccfdfbdf29c2c0a2042d1d090f3f0f1172e65890 (patch)
tree93a4283fd5784a564845076505056f6e0d393b8d /chrome
parent613409bb31cfbee5cd0a0b8f2b372f6c41df1b86 (diff)
downloadchromium_src-ccfdfbdf29c2c0a2042d1d090f3f0f1172e65890.zip
chromium_src-ccfdfbdf29c2c0a2042d1d090f3f0f1172e65890.tar.gz
chromium_src-ccfdfbdf29c2c0a2042d1d090f3f0f1172e65890.tar.bz2
Migrated Proxy Settings API to mechanisms of Content Settings API
BUG=73295 TEST=execute ProxySettingsApiTest.* browser_tests Review URL: http://codereview.chromium.org/6531036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc4
-rw-r--r--chrome/browser/extensions/extension_preference_api.cc4
-rw-r--r--chrome/browser/extensions/extension_proxy_api.cc90
-rw-r--r--chrome/browser/extensions/extension_proxy_api.h29
-rw-r--r--chrome/common/extensions/api/extension_api.json50
-rw-r--r--chrome/common/extensions/docs/experimental.proxy.html467
-rw-r--r--chrome/common/extensions/docs/samples.json3
-rw-r--r--chrome/common/extensions/docs/static/experimental.proxy.html27
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js21
-rw-r--r--chrome/test/data/extensions/api_test/proxy/auto/test.js12
-rw-r--r--chrome/test/data/extensions/api_test/proxy/bypass/test.js12
-rw-r--r--chrome/test/data/extensions/api_test/proxy/direct/test.js12
-rw-r--r--chrome/test/data/extensions/api_test/proxy/events/test.js4
-rw-r--r--chrome/test/data/extensions/api_test/proxy/individual/test.js12
-rw-r--r--chrome/test/data/extensions/api_test/proxy/individual_incognito_also/test.js9
-rw-r--r--chrome/test/data/extensions/api_test/proxy/individual_incognito_only/test.js5
-rw-r--r--chrome/test/data/extensions/api_test/proxy/individual_remove/test.js5
-rw-r--r--chrome/test/data/extensions/api_test/proxy/pac/test.js5
-rw-r--r--chrome/test/data/extensions/api_test/proxy/pacdata/test.js8
-rw-r--r--chrome/test/data/extensions/api_test/proxy/single/test.js5
-rw-r--r--chrome/test/data/extensions/api_test/proxy/system/test.js5
21 files changed, 176 insertions, 613 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index c20dc0d..41b540d 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -259,9 +259,9 @@ void FactoryRegistry::ResetFunctions() {
RegisterFunction<OmniboxSetDefaultSuggestionFunction>();
// Proxies.
- RegisterFunction<UseCustomProxySettingsFunction>();
+ RegisterFunction<SetProxySettingsFunction>();
RegisterFunction<RemoveCustomProxySettingsFunction>();
- RegisterFunction<GetCurrentProxySettingsFunction>();
+ RegisterFunction<GetProxySettingsFunction>();
// Sidebar.
RegisterFunction<CollapseSidebarFunction>();
diff --git a/chrome/browser/extensions/extension_preference_api.cc b/chrome/browser/extensions/extension_preference_api.cc
index 5a0bc97..b7d9717 100644
--- a/chrome/browser/extensions/extension_preference_api.cc
+++ b/chrome/browser/extensions/extension_preference_api.cc
@@ -25,6 +25,10 @@ PrefMappingEntry pref_mapping[] = {
prefs::kBlockThirdPartyCookies,
Extension::kContentSettingsPermission
},
+ { "proxy",
+ prefs::kProxy,
+ Extension::kProxyPermission
+ },
};
class PrefMapping {
diff --git a/chrome/browser/extensions/extension_proxy_api.cc b/chrome/browser/extensions/extension_proxy_api.cc
index 5416af3..f5a82fc 100644
--- a/chrome/browser/extensions/extension_proxy_api.cc
+++ b/chrome/browser/extensions/extension_proxy_api.cc
@@ -137,7 +137,7 @@ void ExtensionProxyEventRouter::OnProxyError(
kProxyEventOnProxyError, json_args, GURL());
}
-bool UseCustomProxySettingsFunction::GetProxyServer(
+bool SetProxySettingsFunction::GetProxyServer(
const DictionaryValue* dict,
net::ProxyServer::Scheme default_scheme,
net::ProxyServer* proxy_server) {
@@ -175,8 +175,8 @@ bool UseCustomProxySettingsFunction::GetProxyServer(
return true;
}
-bool UseCustomProxySettingsFunction::GetProxyRules(DictionaryValue* proxy_rules,
- std::string* out) {
+bool SetProxySettingsFunction::GetProxyRules(DictionaryValue* proxy_rules,
+ std::string* out) {
if (!proxy_rules)
return false;
@@ -235,30 +235,7 @@ bool UseCustomProxySettingsFunction::GetProxyRules(DictionaryValue* proxy_rules,
return true;
}
-void ProxySettingsFunction::ApplyPreference(const char* pref_path,
- Value* pref_value,
- bool incognito) {
- Profile* use_profile = profile();
- if (use_profile->IsOffTheRecord())
- use_profile = use_profile->GetOriginalProfile();
-
- use_profile->GetExtensionService()->extension_prefs()->
- SetExtensionControlledPref(extension_id(), pref_path, incognito,
- pref_value);
-}
-
-void ProxySettingsFunction::RemovePreference(const char* pref_path,
- bool incognito) {
- Profile* use_profile = profile();
- if (use_profile->IsOffTheRecord())
- use_profile = use_profile->GetOriginalProfile();
-
- use_profile->GetExtensionService()->extension_prefs()->
- RemoveExtensionControlledPref(extension_id(), pref_path, incognito);
-}
-
-
-bool UseCustomProxySettingsFunction::JoinUrlList(
+bool SetProxySettingsFunction::JoinUrlList(
ListValue* list, const std::string& joiner, std::string* out) {
std::string result;
for (size_t i = 0; i < list->GetSize(); ++i) {
@@ -281,8 +258,8 @@ bool UseCustomProxySettingsFunction::JoinUrlList(
return true;
}
-bool UseCustomProxySettingsFunction::GetBypassList(DictionaryValue* proxy_rules,
- std::string* out) {
+bool SetProxySettingsFunction::GetBypassList(DictionaryValue* proxy_rules,
+ std::string* out) {
if (!proxy_rules)
return false;
@@ -299,14 +276,12 @@ bool UseCustomProxySettingsFunction::GetBypassList(DictionaryValue* proxy_rules,
return JoinUrlList(bypass_list, ",", out);
}
-bool UseCustomProxySettingsFunction::RunImpl() {
- DictionaryValue* proxy_config;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &proxy_config));
+bool SetProxySettingsFunction::RunImpl() {
+ DictionaryValue* details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details));
- bool incognito = false; // Optional argument, defaults to false.
- if (HasOptionalArgument(1)) {
- EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &incognito));
- }
+ DictionaryValue* proxy_config = NULL;
+ EXTENSION_FUNCTION_VALIDATE(details->GetDictionary("value", &proxy_config));
std::string proxy_mode;
// We can safely assume that this is ASCII due to the allowed enumeration
@@ -410,8 +385,18 @@ bool UseCustomProxySettingsFunction::RunImpl() {
if (!result_proxy_config)
return false;
- ApplyPreference(prefs::kProxy, result_proxy_config, incognito);
- return true;
+ details->Set("value", result_proxy_config);
+ return SetPreferenceFunction::RunImpl();
+}
+
+void RemoveCustomProxySettingsFunction::RemovePreference(const char* pref_path,
+ bool incognito) {
+ Profile* use_profile = profile();
+ if (use_profile->IsOffTheRecord())
+ use_profile = use_profile->GetOriginalProfile();
+
+ use_profile->GetExtensionService()->extension_prefs()->
+ RemoveExtensionControlledPref(extension_id(), pref_path, incognito);
}
bool RemoveCustomProxySettingsFunction::RunImpl() {
@@ -424,25 +409,20 @@ bool RemoveCustomProxySettingsFunction::RunImpl() {
return true;
}
-bool GetCurrentProxySettingsFunction::RunImpl() {
- bool incognito = false;
- EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &incognito));
-
- // This is how it is stored in the PrefStores:
- const DictionaryValue* proxy_prefs;
+bool GetProxySettingsFunction::RunImpl() {
+ if (!GetPreferenceFunction::RunImpl())
+ return false;
- Profile* use_profile = profile();
- if (use_profile->IsOffTheRecord())
- use_profile = use_profile->GetOriginalProfile();
+ DCHECK(result_->IsType(Value::TYPE_DICTIONARY));
- PrefService* prefs = incognito ? use_profile->GetOffTheRecordPrefs()
- : use_profile->GetPrefs();
- proxy_prefs = prefs->GetDictionary(prefs::kProxy);
+ // This is how it is stored in the PrefStores:
+ scoped_ptr<DictionaryValue> proxy_prefs(
+ static_cast<DictionaryValue*>(result_.release()));
// This is how it is presented to the API caller:
scoped_ptr<DictionaryValue> out(new DictionaryValue);
- if (!ConvertToApiFormat(proxy_prefs, out.get())) {
+ if (!ConvertToApiFormat(proxy_prefs.get(), out.get())) {
// Do not set error message as ConvertToApiFormat does that.
return false;
}
@@ -451,7 +431,7 @@ bool GetCurrentProxySettingsFunction::RunImpl() {
return true;
}
-bool GetCurrentProxySettingsFunction::ConvertToApiFormat(
+bool GetProxySettingsFunction::ConvertToApiFormat(
const DictionaryValue* proxy_prefs,
DictionaryValue* api_proxy_config) {
ProxyConfigDictionary dict(proxy_prefs);
@@ -527,8 +507,8 @@ bool GetCurrentProxySettingsFunction::ConvertToApiFormat(
return true;
}
-bool GetCurrentProxySettingsFunction::ParseRules(const std::string& rules,
- DictionaryValue* out) const {
+bool GetProxySettingsFunction::ParseRules(const std::string& rules,
+ DictionaryValue* out) const {
net::ProxyConfig::ProxyRules config;
config.ParseFromString(rules);
switch (config.type) {
@@ -563,7 +543,7 @@ bool GetCurrentProxySettingsFunction::ParseRules(const std::string& rules,
return true;
}
-DictionaryValue* GetCurrentProxySettingsFunction::ConvertToDictionary(
+DictionaryValue* GetProxySettingsFunction::ConvertToDictionary(
const net::ProxyServer& proxy) const {
DictionaryValue* out = new DictionaryValue;
switch (proxy.scheme()) {
diff --git a/chrome/browser/extensions/extension_proxy_api.h b/chrome/browser/extensions/extension_proxy_api.h
index dd5ae97..1dbb042 100644
--- a/chrome/browser/extensions/extension_proxy_api.h
+++ b/chrome/browser/extensions/extension_proxy_api.h
@@ -9,6 +9,7 @@
#include "base/singleton.h"
#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/extensions/extension_preference_api.h"
#include "net/proxy/proxy_config.h"
class DictionaryValue;
@@ -33,23 +34,12 @@ class ExtensionProxyEventRouter {
DISALLOW_COPY_AND_ASSIGN(ExtensionProxyEventRouter);
};
-class ProxySettingsFunction : public SyncExtensionFunction {
+class SetProxySettingsFunction : public SetPreferenceFunction {
public:
- virtual ~ProxySettingsFunction() {}
- virtual bool RunImpl() = 0;
- protected:
- // Takes ownership of |pref_value|.
- void ApplyPreference(
- const char* pref_path, Value* pref_value, bool incognito);
- void RemovePreference(const char* pref_path, bool incognito);
-};
-
-class UseCustomProxySettingsFunction : public ProxySettingsFunction {
- public:
- virtual ~UseCustomProxySettingsFunction() {}
+ virtual ~SetProxySettingsFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.useCustomProxySettings")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.set")
private:
// Converts a proxy "rules" element passed by the API caller into a proxy
// configuration string that can be used by the proxy subsystem (see
@@ -76,22 +66,23 @@ class UseCustomProxySettingsFunction : public ProxySettingsFunction {
bool GetBypassList(DictionaryValue* proxy_rules, std::string* out);
};
-class RemoveCustomProxySettingsFunction : public ProxySettingsFunction {
+class RemoveCustomProxySettingsFunction : public SyncExtensionFunction {
public:
virtual ~RemoveCustomProxySettingsFunction() {}
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.proxy.removeCustomProxySettings")
+ private:
+ void RemovePreference(const char* pref_path, bool incognito);
};
-class GetCurrentProxySettingsFunction : public ProxySettingsFunction {
+class GetProxySettingsFunction : public GetPreferenceFunction {
public:
- virtual ~GetCurrentProxySettingsFunction() {}
+ virtual ~GetProxySettingsFunction() {}
virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME(
- "experimental.proxy.getCurrentProxySettings")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.get")
private:
// Convert the representation of a proxy configuration from the format
// that is stored in the pref stores to the format that is used by the API.
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 12b1f0e..86662a6 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -3756,23 +3756,6 @@
],
"functions": [
{
- "name": "useCustomProxySettings",
- "type": "function",
- "description": "Apply the given proxy configuration.",
- "parameters": [
- {
- "name": "config",
- "$ref": "ProxyConfig"
- },
- {
- "name": "incognito",
- "type": "boolean",
- "description": "If true, the proxy settings apply only to incognito windows. Otherwise they apply to regular windows (and incognito windows if no specific settings are provided for incognito windows.)",
- "optional": true
- }
- ]
- },
- {
"name": "removeCustomProxySettings",
"type": "function",
"description": "Remove a custom proxy set by the current extension. This is the inverse of useCustomProxySettings().",
@@ -3784,31 +3767,22 @@
"optional": true
}
]
- },
- {
- "name": "getCurrentProxySettings",
- "type": "function",
- "description": "Returns the currently effective proxy settings. These can originate from default values, command-line options, the extension settings API, policies and possibly other sources in the future.",
- "parameters": [
- {
- "name": "incognito",
- "type": "boolean",
- "description": "See incognito parameter of useCustomProxySettings()."
- },
+ }
+ ],
+ "properties": {
+ "settings": {
+ "$ref": "Preference",
+ "description": "Proxy settings to be used. The value of this preference is a ProxyConfig object.",
+ "value": [
+ "proxy",
+ {"$ref": "ProxyConfig"},
{
- "name": "callback",
- "type": "function",
- "parameters": [
- {
- "name": "config",
- "$ref": "ProxyConfig",
- "description": "Configuration, not necessarily a literal copy of the configuration passed to useCustomProxySettings()."
- }
- ]
+ "get": "experimental.proxy.get",
+ "set": "experimental.proxy.set"
}
]
}
- ],
+ },
"events": [
{
"name": "onProxyError",
diff --git a/chrome/common/extensions/docs/experimental.proxy.html b/chrome/common/extensions/docs/experimental.proxy.html
index 9711b84..e0d3687 100644
--- a/chrome/common/extensions/docs/experimental.proxy.html
+++ b/chrome/common/extensions/docs/experimental.proxy.html
@@ -295,11 +295,11 @@
<li>
<a href="#apiReference">API reference: chrome.experimental.proxy</a>
<ol>
- <li style="display: none; ">
+ <li>
<a href="#properties">Properties</a>
<ol>
<li>
- <a href="#property-anchor">propertyName</a>
+ <a href="#property-settings">settings</a>
</li>
</ol>
</li>
@@ -307,11 +307,7 @@
<a href="#global-methods">Methods</a>
<ol>
<li>
- <a href="#method-getCurrentProxySettings">getCurrentProxySettings</a>
- </li><li>
<a href="#method-removeCustomProxySettings">removeCustomProxySettings</a>
- </li><li>
- <a href="#method-useCustomProxySettings">useCustomProxySettings</a>
</li>
</ol>
</li>
@@ -566,8 +562,9 @@ apply to regular and incognito windows.
bypassList: ["foobar.com"]
}
};
-var incognito = false;
-chrome.experimental.proxy.useCustomProxySettings(config, incognito);
+chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ function() {});
</pre>
<p>
@@ -584,30 +581,28 @@ The following code sets a custom pac script.
"}"
}
};
-var incognito = false;
-chrome.experimental.proxy.useCustomProxySettings(config, incognito);
+chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ function() {});
</pre>
<p>
The next snippet queries the current proxy settings.
</p>
-<pre>var incognito = false;
-chrome.experimental.proxy.getCurrentProxySettings(
- incognito,
- function (config) {console.log(JSON.stringify(config));}
- );
+<pre>chrome.experimental.proxy.settings.get(
+ {'incognito': false},
+ function(config) {console.log(JSON.stringify(config));});
</pre>
<p>
-Note that the <code>config</code> object passed to the callback function of
-<code>useCustomProxySettings()</code> is not identical to the <code>config</code>
-object passed to <code>getCurrentProxySettings()</code>. The latter will contain
-a <code>rules.httpProxy.port</code> element.
+Note that the <code>value</code> object passed to <code>set()</code> is not
+identical to the <code>value</code> object passed to callback function of
+<code>get()</code>. The latter will contain a <code>rules.httpProxy.port</code>
+element.
</p>
<!-- END AUTHORED CONTENT -->
-
</div>
<!-- API PAGE -->
@@ -616,216 +611,20 @@ a <code>rules.httpProxy.port</code> element.
<h2>API reference: chrome.experimental.proxy</h2>
<!-- PROPERTIES -->
- <div class="apiGroup" style="display: none; ">
+ <div class="apiGroup">
<a name="properties"></a>
<h3 id="properties">Properties</h3>
<div>
- <a></a>
- <h4>getLastError</h4>
+ <a name="property-settings"></a>
+ <h4>settings</h4>
<div class="summary">
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.extension</span><span>lastError</span>
- </div>
- <div>
+ <span>chrome.experimental.proxy.</span><span>settings</span>
</div>
- </div>
-
- </div> <!-- /apiGroup -->
-
- <!-- METHODS -->
- <div id="methodsTemplate" class="apiGroup">
- <a name="global-methods"></a>
- <h3>Methods</h3>
-
- <!-- iterates over all functions -->
- <div class="apiItem">
- <a name="method-getCurrentProxySettings"></a> <!-- method-anchor -->
- <h4>getCurrentProxySettings</h4>
-
- <div class="summary"><span style="display: none; ">void</span>
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.proxy.getCurrentProxySettings</span>(<span class="null"><span style="display: none; ">, </span><span>boolean</span>
- <var><span>incognito</span></var></span><span class="null"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
-
- <div class="description">
- <p class="todo" style="display: none; ">Undocumented.</p>
- <p>Returns the currently effective proxy settings. These can originate from default values, command-line options, the extension settings API, policies and possibly other sources in the future.</p>
-
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
- <dt>
- <var>incognito</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional" style="display: none; ">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>boolean</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo" style="display: none; ">
- Undocumented.
- </dd>
- <dd>See incognito parameter of useCustomProxySettings().</dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div><div>
- <div>
- <dt>
- <var>callback</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional" style="display: none; ">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>function</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
<div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div>
- </dl>
-
- <!-- RETURNS -->
- <h4 style="display: none; ">Returns</h4>
- <dl>
- <div style="display: none; ">
- <div>
- </div>
- </div>
- </dl>
-
- <!-- CALLBACK -->
- <div>
- <div>
- <h4>Callback function</h4>
- <p>
- The callback <em>parameter</em> should specify a function
- that looks like this:
- </p>
- <p style="display: none; ">
- If you specify the <em>callback</em> parameter, it should
- specify a function that looks like this:
- </p>
-
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>ProxyConfig config</span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- <div>
- <div>
<dt>
- <var>config</var>
+ <var>settings</var>
<em>
<!-- TYPE -->
@@ -835,7 +634,7 @@ a <code>rules.httpProxy.port</code> element.
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
<span>
- <a href="experimental.proxy.html#type-ProxyConfig">ProxyConfig</a>
+ <a href="experimental.extension.html#type-Preference">Preference</a>
</span>
<span style="display: none; ">
<span>
@@ -853,7 +652,7 @@ a <code>rules.httpProxy.port</code> element.
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Configuration, not necessarily a literal copy of the configuration passed to useCustomProxySettings().</dd>
+ <dd>Proxy settings to be used. The value of this preference is a ProxyConfig object.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -890,21 +689,17 @@ a <code>rules.httpProxy.port</code> element.
</dd>
</div>
- </div>
- </dl>
- </div>
- </div>
+ </div>
- <!-- MIN_VERSION -->
- <p style="display: none; ">
- This function was added in version <b><span></span></b>.
- If you require this function, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </p>
- </div> <!-- /description -->
+ </div> <!-- /apiGroup -->
- </div><div class="apiItem">
+ <!-- METHODS -->
+ <div id="methodsTemplate" class="apiGroup">
+ <a name="global-methods"></a>
+ <h3>Methods</h3>
+
+ <!-- iterates over all functions -->
+ <div class="apiItem">
<a name="method-removeCustomProxySettings"></a> <!-- method-anchor -->
<h4>removeCustomProxySettings</h4>
@@ -1033,206 +828,6 @@ a <code>rules.httpProxy.port</code> element.
</p>
</div> <!-- /description -->
- </div><div class="apiItem">
- <a name="method-useCustomProxySettings"></a> <!-- method-anchor -->
- <h4>useCustomProxySettings</h4>
-
- <div class="summary"><span style="display: none; ">void</span>
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.experimental.proxy.useCustomProxySettings</span>(<span class="null"><span style="display: none; ">, </span><span>ProxyConfig</span>
- <var><span>config</span></var></span><span class="optional"><span>, </span><span>boolean</span>
- <var><span>incognito</span></var></span>)</div>
-
- <div class="description">
- <p class="todo" style="display: none; ">Undocumented.</p>
- <p>Apply the given proxy configuration.</p>
-
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
- <dt>
- <var>config</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional" style="display: none; ">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span>
- <a href="experimental.proxy.html#type-ProxyConfig">ProxyConfig</a>
- </span>
- <span style="display: none; ">
- <span>
- array of <span><span></span></span>
- </span>
- <span>paramType</span>
- <span></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div><div>
- <div>
- <dt>
- <var>incognito</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>boolean</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
-
- </em>
- </dt>
- <dd class="todo" style="display: none; ">
- Undocumented.
- </dd>
- <dd>If true, the proxy settings apply only to incognito windows. Otherwise they apply to regular windows (and incognito windows if no specific settings are provided for incognito windows.)</dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div>
- </dl>
-
- <!-- RETURNS -->
- <h4 style="display: none; ">Returns</h4>
- <dl>
- <div style="display: none; ">
- <div>
- </div>
- </div>
- </dl>
-
- <!-- CALLBACK -->
- <div style="display: none; ">
- <div>
- <h4>Callback function</h4>
- <p>
- The callback <em>parameter</em> should specify a function
- that looks like this:
- </p>
- <p>
- If you specify the <em>callback</em> parameter, it should
- specify a function that looks like this:
- </p>
-
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </div>
- </div>
-
- <!-- MIN_VERSION -->
- <p style="display: none; ">
- This function was added in version <b><span></span></b>.
- If you require this function, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </p>
- </div> <!-- /description -->
-
</div> <!-- /apiItem -->
</div> <!-- /apiGroup -->
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index eacba16..ef2b1f7 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -41,9 +41,8 @@
"chrome.experimental.infobars.show": "experimental.infobars.html#method-show",
"chrome.experimental.processes.getProcessIdForTab": "experimental.processes.html#method-getProcessIdForTab",
"chrome.experimental.processes.onUpdated": "experimental.processes.html#event-onUpdated",
- "chrome.experimental.proxy.getCurrentProxySettings": "experimental.proxy.html#method-getCurrentProxySettings",
+ "chrome.experimental.proxy.onProxyError": "experimental.proxy.html#event-onProxyError",
"chrome.experimental.proxy.removeCustomProxySettings": "experimental.proxy.html#method-removeCustomProxySettings",
- "chrome.experimental.proxy.useCustomProxySettings": "experimental.proxy.html#method-useCustomProxySettings",
"chrome.experimental.sidebar.collapse": "experimental.sidebar.html#method-collapse",
"chrome.experimental.sidebar.expand": "experimental.sidebar.html#method-expand",
"chrome.experimental.sidebar.getState": "experimental.sidebar.html#method-getState",
diff --git a/chrome/common/extensions/docs/static/experimental.proxy.html b/chrome/common/extensions/docs/static/experimental.proxy.html
index 13b0d31..4e7f066 100644
--- a/chrome/common/extensions/docs/static/experimental.proxy.html
+++ b/chrome/common/extensions/docs/static/experimental.proxy.html
@@ -217,8 +217,9 @@ var config = {
bypassList: ["foobar.com"]
}
};
-var incognito = false;
-chrome.experimental.proxy.useCustomProxySettings(config, incognito);
+chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ function() {});
</pre>
<p>
@@ -236,8 +237,9 @@ var config = {
"}"
}
};
-var incognito = false;
-chrome.experimental.proxy.useCustomProxySettings(config, incognito);
+chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ function() {});
</pre>
<p>
@@ -245,19 +247,16 @@ The next snippet queries the current proxy settings.
</p>
<pre>
-var incognito = false;
-chrome.experimental.proxy.getCurrentProxySettings(
- incognito,
- function (config) {console.log(JSON.stringify(config));}
- );
+chrome.experimental.proxy.settings.get(
+ {'incognito': false},
+ function(config) {console.log(JSON.stringify(config));});
</pre>
<p>
-Note that the <code>config</code> object passed to the callback function of
-<code>useCustomProxySettings()</code> is not identical to the <code>config</code>
-object passed to <code>getCurrentProxySettings()</code>. The latter will contain
-a <code>rules.httpProxy.port</code> element.
+Note that the <code>value</code> object passed to <code>set()</code> is not
+identical to the <code>value</code> object passed to callback function of
+<code>get()</code>. The latter will contain a <code>rules.httpProxy.port</code>
+element.
</p>
<!-- END AUTHORED CONTENT -->
-
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index 94accee..348f1ed 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -320,23 +320,24 @@ var chrome = chrome || {};
var customBindings = {};
function setupPreferences() {
- customBindings['Preference'] = function(prefKey, valueSchema) {
- var getSchema = this.parameters.get;
- var extendedGetSchema = extendSchema(getSchema);
+ customBindings['Preference'] =
+ function(prefKey, valueSchema, customHandlers) {
+ if (customHandlers === undefined)
+ customHandlers = {};
this.get = function(details, callback) {
+ var getSchema = this.parameters.get;
chromeHidden.validate([details, callback], getSchema);
- return sendRequest('experimental.preferences.get',
+ return sendRequest(customHandlers.get || 'experimental.preferences.get',
[prefKey, details, callback],
- extendedGetSchema);
+ extendSchema(getSchema));
};
- var setSchema = this.parameters.set.slice();
- setSchema[0].properties.value = valueSchema;
- var extendedSetSchema = extendSchema(setSchema);
this.set = function(details, callback) {
+ var setSchema = this.parameters.set.slice();
+ setSchema[0].properties.value = valueSchema;
chromeHidden.validate([details, callback], setSchema);
- return sendRequest('experimental.preferences.set',
+ return sendRequest(customHandlers.set || 'experimental.preferences.set',
[prefKey, details, callback],
- extendedSetSchema);
+ extendSchema(setSchema));
};
};
customBindings['Preference'].prototype = new CustomBindingsObject();
diff --git a/chrome/test/data/extensions/api_test/proxy/auto/test.js b/chrome/test/data/extensions/api_test/proxy/auto/test.js
index e802414..92c13a1 100644
--- a/chrome/test/data/extensions/api_test/proxy/auto/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/auto/test.js
@@ -16,12 +16,14 @@ chrome.test.runTests([
var config = {
mode: "auto_detect"
};
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.experimental.proxy.getCurrentProxySettings(
- false,
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
+ chrome.experimental.proxy.settings.get(
+ {'incognito': false},
expect(config, "invalid proxy settings"));
- chrome.experimental.proxy.getCurrentProxySettings(
- true,
+ chrome.experimental.proxy.settings.get(
+ {'incognito': true},
expect(config, "invalid proxy settings"));
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/bypass/test.js b/chrome/test/data/extensions/api_test/proxy/bypass/test.js
index 36c5872..d2a3d3c 100644
--- a/chrome/test/data/extensions/api_test/proxy/bypass/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/bypass/test.js
@@ -34,12 +34,14 @@ chrome.test.runTests([
var config = { rules: rules, mode: "fixed_servers" };
var configExpected = { rules: rulesExpected, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.experimental.proxy.getCurrentProxySettings(
- false,
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
+ chrome.experimental.proxy.settings.get(
+ {'incognito': false},
expect(configExpected, "invalid proxy settings"));
- chrome.experimental.proxy.getCurrentProxySettings(
- true,
+ chrome.experimental.proxy.settings.get(
+ {'incognito': true},
expect(configExpected, "invalid proxy settings"));
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/direct/test.js b/chrome/test/data/extensions/api_test/proxy/direct/test.js
index ebb9916..cf10f82 100644
--- a/chrome/test/data/extensions/api_test/proxy/direct/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/direct/test.js
@@ -16,12 +16,14 @@ chrome.test.runTests([
var config = {
mode: "direct",
};
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.experimental.proxy.getCurrentProxySettings(
- false,
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
+ chrome.experimental.proxy.settings.get(
+ {'incognito': false},
expect(config, "invalid proxy settings"));
- chrome.experimental.proxy.getCurrentProxySettings(
- true,
+ chrome.experimental.proxy.settings.get(
+ {'incognito': true},
expect(config, "invalid proxy settings"));
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/events/test.js b/chrome/test/data/extensions/api_test/proxy/events/test.js
index 2a55c81..d4db7c7 100644
--- a/chrome/test/data/extensions/api_test/proxy/events/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/events/test.js
@@ -17,7 +17,9 @@ var rules = {
};
var config = { rules: rules, mode: "fixed_servers" };
-chrome.experimental.proxy.useCustomProxySettings(config);
+chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
var req = new XMLHttpRequest();
req.open("GET", "http://127.0.0.1/", true);
diff --git a/chrome/test/data/extensions/api_test/proxy/individual/test.js b/chrome/test/data/extensions/api_test/proxy/individual/test.js
index 2881387..e37ccf2 100644
--- a/chrome/test/data/extensions/api_test/proxy/individual/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/individual/test.js
@@ -61,12 +61,14 @@ chrome.test.runTests([
var config = { rules: rules, mode: "fixed_servers" };
var configExpected = { rules: rulesExpected, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.experimental.proxy.getCurrentProxySettings(
- false,
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
+ chrome.experimental.proxy.settings.get(
+ {'incognito': false},
expect(configExpected, "invalid proxy settings"));
- chrome.experimental.proxy.getCurrentProxySettings(
- true,
+ chrome.experimental.proxy.settings.get(
+ {'incognito': true},
expect(configExpected, "invalid proxy settings"));
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/individual_incognito_also/test.js b/chrome/test/data/extensions/api_test/proxy/individual_incognito_also/test.js
index 1745ac2..a9ce698 100644
--- a/chrome/test/data/extensions/api_test/proxy/individual_incognito_also/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/individual_incognito_also/test.js
@@ -32,7 +32,9 @@ function setIndividualProxiesRegular() {
};
var config = { rules: rules, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config, false);
+ chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ chrome.test.callbackPass());
}
function setIndividualProxiesIncognito() {
@@ -61,13 +63,14 @@ function setIndividualProxiesIncognito() {
};
var config = { rules: rules, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config, true);
+ chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': true},
+ chrome.test.callbackPass());
}
chrome.test.runTests([
function setIndividualProxies() {
setIndividualProxiesRegular();
setIndividualProxiesIncognito();
- chrome.test.succeed();
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/individual_incognito_only/test.js b/chrome/test/data/extensions/api_test/proxy/individual_incognito_only/test.js
index 4e0dd9e..30e9994 100644
--- a/chrome/test/data/extensions/api_test/proxy/individual_incognito_only/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/individual_incognito_only/test.js
@@ -33,7 +33,8 @@ chrome.test.runTests([
};
var config = { rules: rules, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config, true);
- chrome.test.succeed();
+ chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': true},
+ chrome.test.callbackPass());
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/individual_remove/test.js b/chrome/test/data/extensions/api_test/proxy/individual_remove/test.js
index 875cce0..e9c3a39 100644
--- a/chrome/test/data/extensions/api_test/proxy/individual_remove/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/individual_remove/test.js
@@ -32,8 +32,9 @@ chrome.test.runTests([
};
var config = { rules: rules, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config, false);
+ chrome.experimental.proxy.settings.set(
+ {'value': config, 'incognito': false},
+ chrome.test.callbackPass());
chrome.experimental.proxy.removeCustomProxySettings(false);
- chrome.test.succeed();
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/pac/test.js b/chrome/test/data/extensions/api_test/proxy/pac/test.js
index d45319e..ff32268 100644
--- a/chrome/test/data/extensions/api_test/proxy/pac/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/pac/test.js
@@ -14,7 +14,8 @@ chrome.test.runTests([
mode: "pac_script",
pacScript: pacScriptObject
};
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.test.succeed();
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/pacdata/test.js b/chrome/test/data/extensions/api_test/proxy/pacdata/test.js
index 7947c32..1fbc65b 100644
--- a/chrome/test/data/extensions/api_test/proxy/pacdata/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/pacdata/test.js
@@ -24,9 +24,11 @@ chrome.test.runTests([
mode: "pac_script",
pacScript: pacScriptObject
};
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.experimental.proxy.getCurrentProxySettings(
- false,
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
+ chrome.experimental.proxy.settings.get(
+ {'incognito': false},
expect(config, "invalid proxy settings"));
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/single/test.js b/chrome/test/data/extensions/api_test/proxy/single/test.js
index 5f19b5e..6c7fa21 100644
--- a/chrome/test/data/extensions/api_test/proxy/single/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/single/test.js
@@ -17,7 +17,8 @@ chrome.test.runTests([
};
var config = { rules: rules, mode: "fixed_servers" };
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.test.succeed();
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
}
]);
diff --git a/chrome/test/data/extensions/api_test/proxy/system/test.js b/chrome/test/data/extensions/api_test/proxy/system/test.js
index 1910ca8..9f7025b 100644
--- a/chrome/test/data/extensions/api_test/proxy/system/test.js
+++ b/chrome/test/data/extensions/api_test/proxy/system/test.js
@@ -8,7 +8,8 @@
chrome.test.runTests([
function setSystemProxy() {
var config = { mode: "system" };
- chrome.experimental.proxy.useCustomProxySettings(config);
- chrome.test.succeed();
+ chrome.experimental.proxy.settings.set(
+ {'value': config},
+ chrome.test.callbackPass());
}
]);