summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 15:04:31 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 15:04:31 +0000
commit3daf923017ac77b354513b53259e80b4fb2a609d (patch)
treeef6bc2ec2d228ba2a447329959eedc43d4f9cbd5 /chrome/browser/extensions
parentc6bf65190096bf85d921b7073825967811a35447 (diff)
downloadchromium_src-3daf923017ac77b354513b53259e80b4fb2a609d.zip
chromium_src-3daf923017ac77b354513b53259e80b4fb2a609d.tar.gz
chromium_src-3daf923017ac77b354513b53259e80b4fb2a609d.tar.bz2
Pass PAC script errors to the proxy API
BUG=48930 TEST=browser tests Review URL: http://codereview.chromium.org/6923003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_proxy_api.cc34
-rw-r--r--chrome/browser/extensions/extension_proxy_api.h6
2 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_proxy_api.cc b/chrome/browser/extensions/extension_proxy_api.cc
index 5b562b5..c3761555 100644
--- a/chrome/browser/extensions/extension_proxy_api.cc
+++ b/chrome/browser/extensions/extension_proxy_api.cc
@@ -7,6 +7,8 @@
#include "chrome/browser/extensions/extension_proxy_api.h"
#include "base/json/json_writer.h"
+#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_event_router_forwarder.h"
#include "chrome/browser/extensions/extension_proxy_api_constants.h"
@@ -52,6 +54,38 @@ void ExtensionProxyEventRouter::OnProxyError(
}
}
+void ExtensionProxyEventRouter::OnPACScriptError(
+ ExtensionEventRouterForwarder* event_router,
+ ProfileId profile_id,
+ int line_number,
+ const string16& error) {
+ ListValue args;
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetBoolean(keys::kProxyEventFatal, false);
+ dict->SetString(keys::kProxyEventError,
+ net::ErrorToString(net::ERR_PAC_SCRIPT_FAILED));
+ std::string error_msg;
+ if (line_number != -1) {
+ base::SStringPrintf(
+ &error_msg, "line: %d: %s", line_number, UTF16ToUTF8(error).c_str());
+ } else {
+ error_msg = UTF16ToUTF8(error);
+ }
+ dict->SetString(keys::kProxyEventDetails, error_msg);
+ args.Append(dict);
+
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+
+ if (profile_id != Profile::kInvalidProfileId) {
+ event_router->DispatchEventToRenderers(
+ keys::kProxyEventOnProxyError, json_args, profile_id, true, GURL());
+ } else {
+ event_router->BroadcastEventToRenderers(
+ keys::kProxyEventOnProxyError, json_args, GURL());
+ }
+}
+
ProxyPrefTransformer::ProxyPrefTransformer() {
}
diff --git a/chrome/browser/extensions/extension_proxy_api.h b/chrome/browser/extensions/extension_proxy_api.h
index e30235d..8a8fb4d 100644
--- a/chrome/browser/extensions/extension_proxy_api.h
+++ b/chrome/browser/extensions/extension_proxy_api.h
@@ -11,6 +11,7 @@
#include <string>
#include "base/memory/singleton.h"
+#include "base/string16.h"
#include "chrome/browser/extensions/extension_preference_api.h"
#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/browser/profiles/profile.h"
@@ -47,6 +48,11 @@ class ExtensionProxyEventRouter {
ProfileId profile_id,
int error_code);
+ void OnPACScriptError(ExtensionEventRouterForwarder* event_router,
+ ProfileId profile_id,
+ int line_number,
+ const string16& error);
+
private:
friend struct DefaultSingletonTraits<ExtensionProxyEventRouter>;