]> khamidou — GitHub mirrors - electron.git/commitdiff
Filter out x-frame-options header on user's request.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 11 Aug 2014 07:03:57 +0000 (15:03 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 11 Aug 2014 07:03:57 +0000 (15:03 +0800)
atom/browser/atom_resource_dispatcher_host_delegate.cc

index 49038e61767138f635ef716e14b7de9efd9bf45d..cc656b6c01a2a1b405a0618088c0b791351aa01b 100644 (file)
@@ -5,11 +5,19 @@
 #include "atom/browser/atom_resource_dispatcher_host_delegate.h"
 
 #include "base/logging.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/resource_request_info.h"
 #include "net/http/http_response_headers.h"
 #include "net/url_request/url_request.h"
 
 namespace atom {
 
+namespace {
+
+const char* kDisableXFrameOptions = "disable-x-frame-options";
+
+}  // namespace
+
 AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
 }
 
@@ -21,11 +29,20 @@ void AtomResourceDispatcherHostDelegate::OnResponseStarted(
     content::ResourceContext* resource_context,
     content::ResourceResponse* response,
     IPC::Sender* sender) {
-  /*
+  // Check if frame's name contains "disable-x-frame-options"
+  int p, f;
+  if (!content::ResourceRequestInfo::GetRenderFrameForRequest(request, &p, &f))
+    return;
+  content::RenderFrameHost* frame = content::RenderFrameHost::FromID(p, f);
+  if (!frame)
+    return;
+  if (frame->GetFrameName().find(kDisableXFrameOptions) == std::string::npos)
+    return;
+
+  // Remove the "X-Frame-Options" from response headers.
   net::HttpResponseHeaders* response_headers = request->response_headers();
   if (response_headers && response_headers->HasHeader("x-frame-options"))
     response_headers->RemoveHeader("x-frame-options");
-  */
 }
 
 }  // namespace atom