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

Unified Diff: content/browser/renderer_host/websocket_host.cc

Issue 2003253002: [Devtools] Allow User-Agent header override for Websockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/websocket_host.cc
diff --git a/content/browser/renderer_host/websocket_host.cc b/content/browser/renderer_host/websocket_host.cc
index cce4485b3d4d67801e5037ee042d88fd5aaaaa41..e0efc202978bb3178348448fffb621ac6524bff8 100644
--- a/content/browser/renderer_host/websocket_host.cc
+++ b/content/browser/renderer_host/websocket_host.cc
@@ -399,22 +399,26 @@ void WebSocketHost::OnAddChannelRequest(
const GURL& socket_url,
const std::vector<std::string>& requested_protocols,
const url::Origin& origin,
+ const std::string& user_agent_override,
int render_frame_id) {
DVLOG(3) << "WebSocketHost::OnAddChannelRequest"
<< " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
<< "\" requested_protocols=\""
<< base::JoinString(requested_protocols, ", ") << "\" origin=\""
- << origin << "\"";
+ << origin << "\" user_agent_override=\"" << user_agent_override
+ << "\"";
DCHECK(!channel_);
if (delay_ > base::TimeDelta()) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(),
- socket_url, requested_protocols, origin, render_frame_id),
+ socket_url, requested_protocols, origin,
+ user_agent_override, render_frame_id),
delay_);
} else {
- AddChannel(socket_url, requested_protocols, origin, render_frame_id);
+ AddChannel(socket_url, requested_protocols, origin,
+ user_agent_override, render_frame_id);
}
// |this| may have been deleted here.
}
@@ -423,12 +427,14 @@ void WebSocketHost::AddChannel(
const GURL& socket_url,
const std::vector<std::string>& requested_protocols,
const url::Origin& origin,
+ const std::string& user_agent_override,
int render_frame_id) {
DVLOG(3) << "WebSocketHost::AddChannel"
<< " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
<< "\" requested_protocols=\""
<< base::JoinString(requested_protocols, ", ") << "\" origin=\""
- << origin << "\"";
+ << origin << "\" user_agent_override=\""
+ << user_agent_override << "\"";
DCHECK(!channel_);
@@ -451,7 +457,20 @@ void WebSocketHost::AddChannel(
pending_flow_control_quota_ = 0;
}
- channel_->SendAddChannelRequest(socket_url, requested_protocols, origin);
+ std::string additional_headers;
+ if (user_agent_override != "") {
+ if (!net::HttpUtil::IsValidHeaderValue(user_agent_override)) {
+ bad_message::ReceivedBadMessage(
+ dispatcher_, bad_message::WSH_INVALID_HEADER_VALUE);
+ return;
+ }
+ additional_headers = base::StringPrintf("%s:%s",
+ net::HttpRequestHeaders::kUserAgent,
+ user_agent_override.c_str());
+ }
+ channel_->SendAddChannelRequest(
+ socket_url, requested_protocols, origin,
+ additional_headers);
// |this| may have been deleted here.
}
« no previous file with comments | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698