Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Side by Side Diff: chrome/browser/extensions/extension_proxy_api.cc

Issue 6598002: Make the ChromeNetworkDelegate use the ExtensionEventRouterForwarder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/extensions/extension_proxy_api.h" 5 #include "chrome/browser/extensions/extension_proxy_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/prefs/proxy_config_dictionary.h" 13 #include "chrome/browser/prefs/proxy_config_dictionary.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/extensions/extension_io_event_router.h" 15 #include "chrome/browser/extensions/extension_event_router_forwarder.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/common/extensions/extension_error_utils.h" 17 #include "chrome/common/extensions/extension_error_utils.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/proxy/proxy_config.h" 20 #include "net/proxy/proxy_config.h"
21 21
22 namespace { 22 namespace {
23 23
24 // The scheme for which to use a manually specified proxy, not of the proxy URI 24 // The scheme for which to use a manually specified proxy, not of the proxy URI
25 // itself. 25 // itself.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return Singleton<ExtensionProxyEventRouter>::get(); 116 return Singleton<ExtensionProxyEventRouter>::get();
117 } 117 }
118 118
119 ExtensionProxyEventRouter::ExtensionProxyEventRouter() { 119 ExtensionProxyEventRouter::ExtensionProxyEventRouter() {
120 } 120 }
121 121
122 ExtensionProxyEventRouter::~ExtensionProxyEventRouter() { 122 ExtensionProxyEventRouter::~ExtensionProxyEventRouter() {
123 } 123 }
124 124
125 void ExtensionProxyEventRouter::OnProxyError( 125 void ExtensionProxyEventRouter::OnProxyError(
126 const ExtensionIOEventRouter* event_router, 126 ExtensionEventRouterForwarder* event_router,
127 Profile* profile,
127 int error_code) { 128 int error_code) {
128 ListValue args; 129 ListValue args;
129 DictionaryValue* dict = new DictionaryValue(); 130 DictionaryValue* dict = new DictionaryValue();
130 dict->SetBoolean(kProxyEventFatal, true); 131 dict->SetBoolean(kProxyEventFatal, true);
131 dict->SetString(kProxyEventError, net::ErrorToString(error_code)); 132 dict->SetString(kProxyEventError, net::ErrorToString(error_code));
132 dict->SetString(kProxyEventDetails, ""); 133 dict->SetString(kProxyEventDetails, "");
133 args.Append(dict); 134 args.Append(dict);
134 135
135 std::string json_args; 136 std::string json_args;
136 base::JSONWriter::Write(&args, false, &json_args); 137 base::JSONWriter::Write(&args, false, &json_args);
137 event_router->DispatchEventToRenderers( 138
138 kProxyEventOnProxyError, json_args, GURL()); 139 if (profile) {
140 event_router->DispatchEventToRenderers(
141 kProxyEventOnProxyError, json_args, profile, true, GURL());
142 } else {
143 event_router->BroadcastEventToRenderers(
144 kProxyEventOnProxyError, json_args, GURL());
145 }
139 } 146 }
140 147
141 bool SetProxySettingsFunction::GetProxyServer( 148 bool SetProxySettingsFunction::GetProxyServer(
142 const DictionaryValue* dict, 149 const DictionaryValue* dict,
143 net::ProxyServer::Scheme default_scheme, 150 net::ProxyServer::Scheme default_scheme,
144 net::ProxyServer* proxy_server) { 151 net::ProxyServer* proxy_server) {
145 std::string scheme_string; // optional. 152 std::string scheme_string; // optional.
146 // We can safely assume that this is ASCII due to the allowed enumeration 153 // We can safely assume that this is ASCII due to the allowed enumeration
147 // values specified in extension_api.json. 154 // values specified in extension_api.json.
148 dict->GetStringASCII(kProxyCfgScheme, &scheme_string); 155 dict->GetStringASCII(kProxyCfgScheme, &scheme_string);
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 break; 554 break;
548 case net::ProxyServer::SCHEME_DIRECT: 555 case net::ProxyServer::SCHEME_DIRECT:
549 case net::ProxyServer::SCHEME_INVALID: 556 case net::ProxyServer::SCHEME_INVALID:
550 NOTREACHED(); 557 NOTREACHED();
551 return out; 558 return out;
552 } 559 }
553 out->SetString(kProxyCfgRuleHost, proxy.host_port_pair().host()); 560 out->SetString(kProxyCfgRuleHost, proxy.host_port_pair().host());
554 out->SetInteger(kProxyCfgRulePort, proxy.host_port_pair().port()); 561 out->SetInteger(kProxyCfgRulePort, proxy.host_port_pair().port());
555 return out; 562 return out;
556 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698