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

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

Issue 2614073004: Add UserCounter for Top Navigation in sandbox (Closed)
Patch Set: Fix a compile error. 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 dcc8df734eb6693a9f4d2bcd51aa64eb649b7175..6e800b7dca863349a03bf5cca6e1ae003dc15e6e 100644
--- a/third_party/WebKit/Source/core/frame/Frame.cpp
+++ b/third_party/WebKit/Source/core/frame/Frame.cpp
@@ -163,9 +163,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()) {
@@ -175,12 +189,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