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

Side by Side 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 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 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // be doing something more general instead? 156 // be doing something more general instead?
157 if (isLocalActiveOrigin && ancestorSecurityOrigin->isLocal()) 157 if (isLocalActiveOrigin && ancestorSecurityOrigin->isLocal())
158 return true; 158 return true;
159 } 159 }
160 160
161 return false; 161 return false;
162 } 162 }
163 163
164 bool Frame::canNavigate(const Frame& targetFrame) { 164 bool Frame::canNavigate(const Frame& targetFrame) {
165 String errorReason; 165 String errorReason;
166 bool isAllowedNavigation = 166 const bool isAllowedNavigation =
167 canNavigateWithoutFramebusting(targetFrame, errorReason); 167 canNavigateWithoutFramebusting(targetFrame, errorReason);
168 const bool sandboxed = securityContext()->getSandboxFlags() != SandboxNone;
169 const bool hasUserGesture =
170 isLocalFrame() ? toLocalFrame(this)->document()->hasReceivedUserGesture()
171 : false;
168 172
173 // Top navigation in sandbox with or w/o 'allow-top-navigation'.
174 if (targetFrame != this && sandboxed && targetFrame == tree().top()) {
175 UseCounter::count(&targetFrame, UseCounter::TopNavInSandbox);
176 if (!hasUserGesture) {
177 UseCounter::count(&targetFrame,
178 UseCounter::TopNavInSandboxWithoutGesture);
179 }
180 }
181
182 // Top navigation w/o sandbox or in sandbox with 'allow-top-navigation'.
169 if (targetFrame != this && 183 if (targetFrame != this &&
170 !securityContext()->isSandboxed(SandboxTopNavigation) && 184 !securityContext()->isSandboxed(SandboxTopNavigation) &&
171 targetFrame == tree().top()) { 185 targetFrame == tree().top()) {
172 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram, 186 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram,
173 ("WebCore.Framebust", 4)); 187 ("WebCore.Framebust", 4));
174 const unsigned userGestureBit = 0x1; 188 const unsigned userGestureBit = 0x1;
175 const unsigned allowedBit = 0x2; 189 const unsigned allowedBit = 0x2;
176 unsigned framebustParams = 0; 190 unsigned framebustParams = 0;
177 UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame); 191 UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame);
178 bool hasUserGesture = 192
179 isLocalFrame()
180 ? toLocalFrame(this)->document()->hasReceivedUserGesture()
181 : false;
182 if (hasUserGesture) 193 if (hasUserGesture)
183 framebustParams |= userGestureBit; 194 framebustParams |= userGestureBit;
195 if (sandboxed) { // Sandboxed with 'allow-top-navigation'.
196 UseCounter::count(&targetFrame, UseCounter::TopNavInSandboxWithPerm);
197 if (!hasUserGesture) {
198 UseCounter::count(&targetFrame,
199 UseCounter::TopNavInSandboxWithPermButNoGesture);
200 }
201 }
202
184 if (isAllowedNavigation) 203 if (isAllowedNavigation)
185 framebustParams |= allowedBit; 204 framebustParams |= allowedBit;
186 framebustHistogram.count(framebustParams); 205 framebustHistogram.count(framebustParams);
187 // Frame-busting used to be generally allowed in most situations, but may 206 // Frame-busting used to be generally allowed in most situations, but may
188 // now blocked if there is no user gesture. 207 // now blocked if there is no user gesture.
189 if (!RuntimeEnabledFeatures:: 208 if (!RuntimeEnabledFeatures::
190 framebustingNeedsSameOriginOrUserGestureEnabled()) 209 framebustingNeedsSameOriginOrUserGestureEnabled())
191 return true; 210 return true;
192 if (hasUserGesture || isAllowedNavigation) 211 if (hasUserGesture || isAllowedNavigation)
193 return true; 212 return true;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 364
346 ASSERT(page()); 365 ASSERT(page());
347 366
348 if (m_owner) 367 if (m_owner)
349 m_owner->setContentFrame(*this); 368 m_owner->setContentFrame(*this);
350 else 369 else
351 page()->setMainFrame(this); 370 page()->setMainFrame(this);
352 } 371 }
353 372
354 } // namespace blink 373 } // 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