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

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

Issue 2651593003: Add a counter for postMessage from insecure to secure top-level frames (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/frame/DOMWindow.h" 5 #include "core/frame/DOMWindow.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/dom/SecurityContext.h" 10 #include "core/dom/SecurityContext.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 : securityOrigin->toString(); 226 : securityOrigin->toString();
227 String sourceSuborigin = 227 String sourceSuborigin =
228 hasSuborigin ? securityOrigin->suborigin()->name() : String(); 228 hasSuborigin ? securityOrigin->suborigin()->name() : String();
229 229
230 KURL targetUrl = 230 KURL targetUrl =
231 isLocalDOMWindow() 231 isLocalDOMWindow()
232 ? document()->url() 232 ? document()->url()
233 : KURL(KURL(), 233 : KURL(KURL(),
234 frame()->securityContext()->getSecurityOrigin()->toString()); 234 frame()->securityContext()->getSecurityOrigin()->toString());
235 if (MixedContentChecker::isMixedContent(sourceDocument->getSecurityOrigin(), 235 if (MixedContentChecker::isMixedContent(sourceDocument->getSecurityOrigin(),
236 targetUrl)) 236 targetUrl)) {
237 UseCounter::count(frame(), UseCounter::PostMessageFromSecureToInsecure); 237 UseCounter::count(frame(), UseCounter::PostMessageFromSecureToInsecure);
238 else if (MixedContentChecker::isMixedContent( 238 } else if (MixedContentChecker::isMixedContent(
239 frame()->securityContext()->getSecurityOrigin(), 239 frame()->securityContext()->getSecurityOrigin(),
240 sourceDocument->url())) 240 sourceDocument->url())) {
241 UseCounter::count(frame(), UseCounter::PostMessageFromInsecureToSecure); 241 UseCounter::count(frame(), UseCounter::PostMessageFromInsecureToSecure);
242 if (frame()->isMainFrame()) {
Mike West 2017/01/23 08:59:22 That is, I think the goal of the counter is to det
243 UseCounter::count(frame(),
244 UseCounter::PostMessageFromInsecureToSecureToplevel);
245 }
246 }
242 247
243 MessageEvent* event = 248 MessageEvent* event =
244 MessageEvent::create(std::move(channels), std::move(message), 249 MessageEvent::create(std::move(channels), std::move(message),
245 sourceOrigin, String(), source, sourceSuborigin); 250 sourceOrigin, String(), source, sourceSuborigin);
246 251
247 schedulePostMessage(event, std::move(target), sourceDocument); 252 schedulePostMessage(event, std::move(target), sourceDocument);
248 } 253 }
249 254
250 // FIXME: Once we're throwing exceptions for cross-origin access violations, we 255 // FIXME: Once we're throwing exceptions for cross-origin access violations, we
251 // will always sanitize the target frame details, so we can safely combine 256 // will always sanitize the target frame details, so we can safely combine
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */); 441 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */);
437 } 442 }
438 443
439 DEFINE_TRACE(DOMWindow) { 444 DEFINE_TRACE(DOMWindow) {
440 visitor->trace(m_frame); 445 visitor->trace(m_frame);
441 visitor->trace(m_location); 446 visitor->trace(m_location);
442 EventTargetWithInlineData::trace(visitor); 447 EventTargetWithInlineData::trace(visitor);
443 } 448 }
444 449
445 } // namespace blink 450 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698