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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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_web_socket_proxy_private_api.h" 5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/internal_auth.h" 10 #include "chrome/browser/internal_auth.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "content/common/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "net/base/escape.h" 15 #include "net/base/escape.h"
16 16
17 #if defined(OS_CHROMEOS) 17 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/chromeos/web_socket_proxy_controller.h" 18 #include "chrome/browser/chromeos/web_socket_proxy_controller.h"
19 #endif 19 #endif
20 20
21 WebSocketProxyPrivate::WebSocketProxyPrivate() 21 WebSocketProxyPrivate::WebSocketProxyPrivate()
22 : is_finalized_(false), listening_port_(-1) { 22 : is_finalized_(false), listening_port_(-1) {
23 } 23 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int port = -1; 77 int port = -1;
78 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port)); 78 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port));
79 79
80 if (chromeos::WebSocketProxyController::CheckCredentials( 80 if (chromeos::WebSocketProxyController::CheckCredentials(
81 extension_id(), hostname, port, 81 extension_id(), hostname, port,
82 chromeos::WebSocketProxyController::PLAIN_TCP)) { 82 chromeos::WebSocketProxyController::PLAIN_TCP)) {
83 if (!chromeos::WebSocketProxyController::IsInitiated()) { 83 if (!chromeos::WebSocketProxyController::IsInitiated()) {
84 delay_response = true; 84 delay_response = true;
85 registrar_.Add( 85 registrar_.Add(
86 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED, 86 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED,
87 NotificationService::AllSources()); 87 content::NotificationService::AllSources());
88 chromeos::WebSocketProxyController::Initiate(); 88 chromeos::WebSocketProxyController::Initiate();
89 } 89 }
90 90
91 std::map<std::string, std::string> map; 91 std::map<std::string, std::string> map;
92 map["hostname"] = hostname; 92 map["hostname"] = hostname;
93 map["port"] = base::IntToString(port); 93 map["port"] = base::IntToString(port);
94 map["extension_id"] = extension_id(); 94 map["extension_id"] = extension_id();
95 StringValue* passport = Value::CreateStringValue( 95 StringValue* passport = Value::CreateStringValue(
96 browser::InternalAuthGeneration::GeneratePassport( 96 browser::InternalAuthGeneration::GeneratePassport(
97 "web_socket_proxy", map)); 97 "web_socket_proxy", map));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 } 130 }
131 if (chromeos::WebSocketProxyController::CheckCredentials( 131 if (chromeos::WebSocketProxyController::CheckCredentials(
132 extension_id(), hostname, port, 132 extension_id(), hostname, port,
133 do_tls ? chromeos::WebSocketProxyController::TLS_OVER_TCP : 133 do_tls ? chromeos::WebSocketProxyController::TLS_OVER_TCP :
134 chromeos::WebSocketProxyController::PLAIN_TCP)) { 134 chromeos::WebSocketProxyController::PLAIN_TCP)) {
135 if (!chromeos::WebSocketProxyController::IsInitiated()) { 135 if (!chromeos::WebSocketProxyController::IsInitiated()) {
136 delay_response = true; 136 delay_response = true;
137 registrar_.Add( 137 registrar_.Add(
138 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED, 138 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED,
139 NotificationService::AllSources()); 139 content::NotificationService::AllSources());
140 chromeos::WebSocketProxyController::Initiate(); 140 chromeos::WebSocketProxyController::Initiate();
141 } 141 }
142 142
143 std::map<std::string, std::string> map; 143 std::map<std::string, std::string> map;
144 map["hostname"] = hostname; 144 map["hostname"] = hostname;
145 map["port"] = base::IntToString(port); 145 map["port"] = base::IntToString(port);
146 map["extension_id"] = extension_id(); 146 map["extension_id"] = extension_id();
147 map["tls"] = do_tls ? "true" : "false"; 147 map["tls"] = do_tls ? "true" : "false";
148 std::string passport = browser::InternalAuthGeneration::GeneratePassport( 148 std::string passport = browser::InternalAuthGeneration::GeneratePassport(
149 "web_socket_proxy", map); 149 "web_socket_proxy", map);
150 query_ = std::string("hostname=") + 150 query_ = std::string("hostname=") +
151 net::EscapeQueryParamValue(hostname, false) + "&port=" + map["port"] + 151 net::EscapeQueryParamValue(hostname, false) + "&port=" + map["port"] +
152 "&tls=" + map["tls"] + "&passport=" + 152 "&tls=" + map["tls"] + "&passport=" +
153 net::EscapeQueryParamValue(passport, false); 153 net::EscapeQueryParamValue(passport, false);
154 } 154 }
155 #endif // defined(OS_CHROMEOS) 155 #endif // defined(OS_CHROMEOS)
156 156
157 if (delay_response) { 157 if (delay_response) {
158 const int kTimeout = 3; 158 const int kTimeout = 3;
159 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeout), 159 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeout),
160 this, &WebSocketProxyPrivate::Finalize); 160 this, &WebSocketProxyPrivate::Finalize);
161 } else { 161 } else {
162 Finalize(); 162 Finalize();
163 } 163 }
164 return true; 164 return true;
165 } 165 }
166 166
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_warning_set.cc ('k') | chrome/browser/extensions/extension_webnavigation_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698