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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2873223003: CSP: Measure the frequency of `postMessage` violating `connect-src` (Closed)
Patch Set: Rebase. Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "core/frame/FrameView.h" 58 #include "core/frame/FrameView.h"
59 #include "core/frame/History.h" 59 #include "core/frame/History.h"
60 #include "core/frame/LocalFrame.h" 60 #include "core/frame/LocalFrame.h"
61 #include "core/frame/LocalFrameClient.h" 61 #include "core/frame/LocalFrameClient.h"
62 #include "core/frame/Navigator.h" 62 #include "core/frame/Navigator.h"
63 #include "core/frame/Screen.h" 63 #include "core/frame/Screen.h"
64 #include "core/frame/ScrollToOptions.h" 64 #include "core/frame/ScrollToOptions.h"
65 #include "core/frame/Settings.h" 65 #include "core/frame/Settings.h"
66 #include "core/frame/SuspendableTimer.h" 66 #include "core/frame/SuspendableTimer.h"
67 #include "core/frame/VisualViewport.h" 67 #include "core/frame/VisualViewport.h"
68 #include "core/frame/csp/ContentSecurityPolicy.h"
68 #include "core/html/HTMLFrameOwnerElement.h" 69 #include "core/html/HTMLFrameOwnerElement.h"
69 #include "core/input/EventHandler.h" 70 #include "core/input/EventHandler.h"
70 #include "core/inspector/ConsoleMessage.h" 71 #include "core/inspector/ConsoleMessage.h"
71 #include "core/inspector/InspectorTraceEvents.h" 72 #include "core/inspector/InspectorTraceEvents.h"
72 #include "core/loader/DocumentLoader.h" 73 #include "core/loader/DocumentLoader.h"
73 #include "core/loader/appcache/ApplicationCache.h" 74 #include "core/loader/appcache/ApplicationCache.h"
74 #include "core/page/ChromeClient.h" 75 #include "core/page/ChromeClient.h"
75 #include "core/page/CreateWindow.h" 76 #include "core/page/CreateWindow.h"
76 #include "core/page/Page.h" 77 #include "core/page/Page.h"
77 #include "core/page/WindowFeatures.h" 78 #include "core/page/WindowFeatures.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 "') does not match the recipient window's origin ('" + 697 "') does not match the recipient window's origin ('" +
697 document()->GetSecurityOrigin()->ToString() + "')."); 698 document()->GetSecurityOrigin()->ToString() + "').");
698 ConsoleMessage* console_message = 699 ConsoleMessage* console_message =
699 ConsoleMessage::Create(kSecurityMessageSource, kErrorMessageLevel, 700 ConsoleMessage::Create(kSecurityMessageSource, kErrorMessageLevel,
700 message, std::move(location)); 701 message, std::move(location));
701 GetFrameConsole()->AddMessage(console_message); 702 GetFrameConsole()->AddMessage(console_message);
702 return; 703 return;
703 } 704 }
704 } 705 }
705 706
707 KURL sender(kParsedURLString, static_cast<MessageEvent*>(event)->origin());
708 if (!document()->GetContentSecurityPolicy()->AllowConnectToSource(
709 sender, RedirectStatus::kNoRedirect,
710 SecurityViolationReportingPolicy::kSuppressReporting)) {
711 UseCounter::Count(
712 GetFrame(), UseCounter::kPostMessageIncomingWouldBeBlockedByConnectSrc);
713 }
714
706 DispatchEvent(event); 715 DispatchEvent(event);
707 } 716 }
708 717
709 DOMSelection* LocalDOMWindow::getSelection() { 718 DOMSelection* LocalDOMWindow::getSelection() {
710 if (!IsCurrentlyDisplayedInFrame()) 719 if (!IsCurrentlyDisplayedInFrame())
711 return nullptr; 720 return nullptr;
712 721
713 return document()->GetSelection(); 722 return document()->GetSelection();
714 } 723 }
715 724
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 DOMWindow::Trace(visitor); 1704 DOMWindow::Trace(visitor);
1696 Supplementable<LocalDOMWindow>::Trace(visitor); 1705 Supplementable<LocalDOMWindow>::Trace(visitor);
1697 } 1706 }
1698 1707
1699 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { 1708 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) {
1700 visitor->TraceWrappers(custom_elements_); 1709 visitor->TraceWrappers(custom_elements_);
1701 DOMWindow::TraceWrappers(visitor); 1710 DOMWindow::TraceWrappers(visitor);
1702 } 1711 }
1703 1712
1704 } // namespace blink 1713 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMWindow.cpp ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698