| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Implementation of the Chrome Extensions Proxy Settings API. | 5 // Implementation of the Chrome Extensions Proxy Settings API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/proxy/proxy_api.h" | 7 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void* profile, | 38 void* profile, |
| 39 int error_code) { | 39 int error_code) { |
| 40 ListValue args; | 40 ListValue args; |
| 41 DictionaryValue* dict = new DictionaryValue(); | 41 DictionaryValue* dict = new DictionaryValue(); |
| 42 dict->SetBoolean(keys::kProxyEventFatal, true); | 42 dict->SetBoolean(keys::kProxyEventFatal, true); |
| 43 dict->SetString(keys::kProxyEventError, net::ErrorToString(error_code)); | 43 dict->SetString(keys::kProxyEventError, net::ErrorToString(error_code)); |
| 44 dict->SetString(keys::kProxyEventDetails, ""); | 44 dict->SetString(keys::kProxyEventDetails, ""); |
| 45 args.Append(dict); | 45 args.Append(dict); |
| 46 | 46 |
| 47 std::string json_args; | 47 std::string json_args; |
| 48 base::JSONWriter::Write(&args, false, &json_args); | 48 base::JSONWriter::Write(&args, &json_args); |
| 49 | 49 |
| 50 if (profile) { | 50 if (profile) { |
| 51 event_router->DispatchEventToRenderers( | 51 event_router->DispatchEventToRenderers( |
| 52 keys::kProxyEventOnProxyError, json_args, profile, true, GURL()); | 52 keys::kProxyEventOnProxyError, json_args, profile, true, GURL()); |
| 53 } else { | 53 } else { |
| 54 event_router->BroadcastEventToRenderers( | 54 event_router->BroadcastEventToRenderers( |
| 55 keys::kProxyEventOnProxyError, json_args, GURL()); | 55 keys::kProxyEventOnProxyError, json_args, GURL()); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 if (line_number != -1) { | 70 if (line_number != -1) { |
| 71 base::SStringPrintf( | 71 base::SStringPrintf( |
| 72 &error_msg, "line: %d: %s", line_number, UTF16ToUTF8(error).c_str()); | 72 &error_msg, "line: %d: %s", line_number, UTF16ToUTF8(error).c_str()); |
| 73 } else { | 73 } else { |
| 74 error_msg = UTF16ToUTF8(error); | 74 error_msg = UTF16ToUTF8(error); |
| 75 } | 75 } |
| 76 dict->SetString(keys::kProxyEventDetails, error_msg); | 76 dict->SetString(keys::kProxyEventDetails, error_msg); |
| 77 args.Append(dict); | 77 args.Append(dict); |
| 78 | 78 |
| 79 std::string json_args; | 79 std::string json_args; |
| 80 base::JSONWriter::Write(&args, false, &json_args); | 80 base::JSONWriter::Write(&args, &json_args); |
| 81 | 81 |
| 82 if (profile) { | 82 if (profile) { |
| 83 event_router->DispatchEventToRenderers( | 83 event_router->DispatchEventToRenderers( |
| 84 keys::kProxyEventOnProxyError, json_args, profile, true, GURL()); | 84 keys::kProxyEventOnProxyError, json_args, profile, true, GURL()); |
| 85 } else { | 85 } else { |
| 86 event_router->BroadcastEventToRenderers( | 86 event_router->BroadcastEventToRenderers( |
| 87 keys::kProxyEventOnProxyError, json_args, GURL()); | 87 keys::kProxyEventOnProxyError, json_args, GURL()); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); | 179 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); |
| 180 break; | 180 break; |
| 181 } | 181 } |
| 182 case ProxyPrefs::kModeCount: | 182 case ProxyPrefs::kModeCount: |
| 183 NOTREACHED(); | 183 NOTREACHED(); |
| 184 } | 184 } |
| 185 return extension_pref.release(); | 185 return extension_pref.release(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |