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

Unified Diff: extensions/browser/api/web_request/web_request_event_details.cc

Issue 2449913002: Support WebSocket in WebRequest API. (Closed)
Patch Set: git cl format Created 3 years, 10 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
Index: extensions/browser/api/web_request/web_request_event_details.cc
diff --git a/extensions/browser/api/web_request/web_request_event_details.cc b/extensions/browser/api/web_request/web_request_event_details.cc
index 5f7badbaf511cc90b4fd259c2a1bd980c0b52e21..8a3e87473763872143e6aea6c18fcb049d6324c7 100644
--- a/extensions/browser/api/web_request/web_request_event_details.cc
+++ b/extensions/browser/api/web_request/web_request_event_details.cc
@@ -9,6 +9,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/resource_request_info.h"
+#include "content/public/browser/websocket_handshake_request_info.h"
#include "content/public/common/child_process_host.h"
#include "extensions/browser/api/web_request/upload_data_presenter.h"
#include "extensions/browser/api/web_request/web_request_api_constants.h"
@@ -39,9 +40,18 @@ WebRequestEventDetails::WebRequestEventDetails(const net::URLRequest* request,
if (info) {
render_process_id_ = info->GetChildID();
render_frame_id_ = info->GetRenderFrameID();
+ } else if (resource_type == WebRequestResourceType::WEB_SOCKET) {
+ // TODO(pkalinnikov): Consider embedding WebSocketHandshakeRequestInfo into
+ // UrlRequestUserData.
+ const content::WebSocketHandshakeRequestInfo* ws_info =
+ content::WebSocketHandshakeRequestInfo::ForRequest(request);
+ if (ws_info) {
+ render_process_id_ = ws_info->GetChildId();
+ render_frame_id_ = ws_info->GetRenderFrameId();
+ }
} else {
- // Fallback for requests that are not allocated by a ResourceDispatcherHost,
- // such as the TemplateURLFetcher.
+ // Fallback for requests that are not allocated by a
+ // ResourceDispatcherHost, such as the TemplateURLFetcher.
content::ResourceRequestInfo::GetRenderFrameForRequest(
request, &render_process_id_, &render_frame_id_);
}

Powered by Google App Engine
This is Rietveld 408576698