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

Unified Diff: third_party/WebKit/Source/core/frame/Frame.cpp

Issue 2621043002: Add UserCounter for Top Navigation in sandbox (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/Frame.cpp
diff --git a/third_party/WebKit/Source/core/frame/Frame.cpp b/third_party/WebKit/Source/core/frame/Frame.cpp
index 871e6409dd5ca9a5b6ef51096e78d289621edc2e..d811923901b46e41a801181ee9714374ca76c3df 100644
--- a/third_party/WebKit/Source/core/frame/Frame.cpp
+++ b/third_party/WebKit/Source/core/frame/Frame.cpp
@@ -161,9 +161,23 @@ static bool canAccessAncestor(const SecurityOrigin& activeSecurityOrigin,
bool Frame::canNavigate(const Frame& targetFrame) {
String errorReason;
- bool isAllowedNavigation =
+ const bool isAllowedNavigation =
canNavigateWithoutFramebusting(targetFrame, errorReason);
+ const bool sandboxed = securityContext()->getSandboxFlags() != SandboxNone;
+ const bool hasUserGesture =
+ isLocalFrame() ? toLocalFrame(this)->document()->hasReceivedUserGesture()
+ : false;
+
+ // Top navigation in sandbox with or w/o 'allow-top-navigation'.
+ if (targetFrame != this && sandboxed && targetFrame == tree().top()) {
+ UseCounter::count(&targetFrame, UseCounter::TopNavInSandbox);
+ if (!hasUserGesture) {
+ UseCounter::count(&targetFrame,
+ UseCounter::TopNavInSandboxWithoutGesture);
+ }
+ }
+ // Top navigation w/o sandbox or in sandbox with 'allow-top-navigation'.
if (targetFrame != this &&
!securityContext()->isSandboxed(SandboxTopNavigation) &&
targetFrame == tree().top()) {
@@ -173,12 +187,17 @@ bool Frame::canNavigate(const Frame& targetFrame) {
const unsigned allowedBit = 0x2;
unsigned framebustParams = 0;
UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame);
- bool hasUserGesture =
- isLocalFrame()
- ? toLocalFrame(this)->document()->hasReceivedUserGesture()
- : false;
+
if (hasUserGesture)
framebustParams |= userGestureBit;
+ if (sandboxed) { // Sandboxed with 'allow-top-navigation'.
+ UseCounter::count(&targetFrame, UseCounter::TopNavInSandboxWithPerm);
+ if (!hasUserGesture) {
+ UseCounter::count(&targetFrame,
+ UseCounter::TopNavInSandboxWithPermButNoGesture);
+ }
+ }
+
if (isAllowedNavigation)
framebustParams |= allowedBit;
framebustHistogram.count(framebustParams);
« 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