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

Side by Side Diff: chrome/browser/extensions/api/proxy/proxy_api.cc

Issue 10696208: Move ExtensionEventRouter and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed bug + latest master Created 8 years, 5 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
OLDNEW
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"
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/extensions/api/proxy/proxy_api_constants.h" 13 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h"
14 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h" 14 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h"
15 #include "chrome/browser/extensions/extension_event_router_forwarder.h" 15 #include "chrome/browser/extensions/event_router_forwarder.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/prefs/proxy_config_dictionary.h" 17 #include "chrome/browser/prefs/proxy_config_dictionary.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 namespace helpers = proxy_api_helpers; 22 namespace helpers = proxy_api_helpers;
23 namespace keys = proxy_api_constants; 23 namespace keys = proxy_api_constants;
24 24
25 // static 25 // static
26 ProxyEventRouter* ProxyEventRouter::GetInstance() { 26 ProxyEventRouter* ProxyEventRouter::GetInstance() {
27 return Singleton<ProxyEventRouter>::get(); 27 return Singleton<ProxyEventRouter>::get();
28 } 28 }
29 29
30 ProxyEventRouter::ProxyEventRouter() { 30 ProxyEventRouter::ProxyEventRouter() {
31 } 31 }
32 32
33 ProxyEventRouter::~ProxyEventRouter() { 33 ProxyEventRouter::~ProxyEventRouter() {
34 } 34 }
35 35
36 void ProxyEventRouter::OnProxyError( 36 void ProxyEventRouter::OnProxyError(
37 ExtensionEventRouterForwarder* event_router, 37 EventRouterForwarder* event_router,
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, &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
59 void ProxyEventRouter::OnPACScriptError( 59 void ProxyEventRouter::OnPACScriptError(
60 ExtensionEventRouterForwarder* event_router, 60 EventRouterForwarder* event_router,
61 void* profile, 61 void* profile,
62 int line_number, 62 int line_number,
63 const string16& error) { 63 const string16& error) {
64 ListValue args; 64 ListValue args;
65 DictionaryValue* dict = new DictionaryValue(); 65 DictionaryValue* dict = new DictionaryValue();
66 dict->SetBoolean(keys::kProxyEventFatal, false); 66 dict->SetBoolean(keys::kProxyEventFatal, false);
67 dict->SetString(keys::kProxyEventError, 67 dict->SetString(keys::kProxyEventError,
68 net::ErrorToString(net::ERR_PAC_SCRIPT_FAILED)); 68 net::ErrorToString(net::ERR_PAC_SCRIPT_FAILED));
69 std::string error_msg; 69 std::string error_msg;
70 if (line_number != -1) { 70 if (line_number != -1) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/proxy/proxy_api.h ('k') | chrome/browser/extensions/api/runtime/runtime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698