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

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

Issue 2877893002: Make UseCounter take a LocaFrame instead of any Frame (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) 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 bool Frame::CanNavigate(const Frame& target_frame) { 168 bool Frame::CanNavigate(const Frame& target_frame) {
169 String error_reason; 169 String error_reason;
170 const bool is_allowed_navigation = 170 const bool is_allowed_navigation =
171 CanNavigateWithoutFramebusting(target_frame, error_reason); 171 CanNavigateWithoutFramebusting(target_frame, error_reason);
172 const bool sandboxed = 172 const bool sandboxed =
173 GetSecurityContext()->GetSandboxFlags() != kSandboxNone; 173 GetSecurityContext()->GetSandboxFlags() != kSandboxNone;
174 const bool has_user_gesture = 174 const bool has_user_gesture =
175 IsLocalFrame() ? ToLocalFrame(this)->HasReceivedUserGesture() : false; 175 IsLocalFrame() ? ToLocalFrame(this)->HasReceivedUserGesture() : false;
176 176
177 // Top navigation in sandbox with or w/o 'allow-top-navigation'. 177 // Top navigation in sandbox with or w/o 'allow-top-navigation'.
178 if (target_frame != this && sandboxed && target_frame == Tree().Top()) { 178 if (IsLocalFrame() && target_frame != this && sandboxed &&
dcheng 2017/05/12 22:15:18 I think this can actually only be called on a loca
Rick Byers 2017/05/25 15:32:31 Good catch, and looks like it wasn't too hard to m
179 UseCounter::Count(&target_frame, UseCounter::kTopNavInSandbox); 179 target_frame == Tree().Top()) {
180 UseCounter::Count(ToLocalFrame(this), UseCounter::kTopNavInSandbox);
180 if (!has_user_gesture) { 181 if (!has_user_gesture) {
181 UseCounter::Count(&target_frame, 182 UseCounter::Count(ToLocalFrame(this),
182 UseCounter::kTopNavInSandboxWithoutGesture); 183 UseCounter::kTopNavInSandboxWithoutGesture);
183 } 184 }
184 } 185 }
185 186
186 // Top navigation w/o sandbox or in sandbox with 'allow-top-navigation'. 187 // Top navigation w/o sandbox or in sandbox with 'allow-top-navigation'.
187 if (target_frame != this && 188 if (target_frame != this &&
188 !GetSecurityContext()->IsSandboxed(kSandboxTopNavigation) && 189 !GetSecurityContext()->IsSandboxed(kSandboxTopNavigation) &&
189 target_frame == Tree().Top()) { 190 target_frame == Tree().Top()) {
190 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebust_histogram, 191 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebust_histogram,
191 ("WebCore.Framebust", 4)); 192 ("WebCore.Framebust", 4));
192 const unsigned kUserGestureBit = 0x1; 193 const unsigned kUserGestureBit = 0x1;
193 const unsigned kAllowedBit = 0x2; 194 const unsigned kAllowedBit = 0x2;
194 unsigned framebust_params = 0; 195 unsigned framebust_params = 0;
195 UseCounter::Count(&target_frame, UseCounter::kTopNavigationFromSubFrame);
196 196
197 if (has_user_gesture) 197 if (has_user_gesture)
198 framebust_params |= kUserGestureBit; 198 framebust_params |= kUserGestureBit;
199 if (sandboxed) { // Sandboxed with 'allow-top-navigation'. 199
200 UseCounter::Count(&target_frame, UseCounter::kTopNavInSandboxWithPerm); 200 if (IsLocalFrame()) {
201 if (!has_user_gesture) { 201 UseCounter::Count(ToLocalFrame(this),
202 UseCounter::Count(&target_frame, 202 UseCounter::kTopNavigationFromSubFrame);
203 UseCounter::kTopNavInSandboxWithPermButNoGesture); 203 if (sandboxed) { // Sandboxed with 'allow-top-navigation'.
204 UseCounter::Count(ToLocalFrame(this),
205 UseCounter::kTopNavInSandboxWithPerm);
206 if (!has_user_gesture) {
207 UseCounter::Count(ToLocalFrame(this),
208 UseCounter::kTopNavInSandboxWithPermButNoGesture);
209 }
204 } 210 }
205 } 211 }
206 212
207 if (is_allowed_navigation) 213 if (is_allowed_navigation)
208 framebust_params |= kAllowedBit; 214 framebust_params |= kAllowedBit;
209 framebust_histogram.Count(framebust_params); 215 framebust_histogram.Count(framebust_params);
210 if (has_user_gesture || is_allowed_navigation) 216 if (has_user_gesture || is_allowed_navigation)
211 return true; 217 return true;
212 // Frame-busting used to be generally allowed in most situations, but may 218 // Frame-busting used to be generally allowed in most situations, but may
213 // now blocked if the document initiating the navigation has never received 219 // now blocked if the document initiating the navigation has never received
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 is_loading_(false) { 436 is_loading_(false) {
431 InstanceCounters::IncrementCounter(InstanceCounters::kFrameCounter); 437 InstanceCounters::IncrementCounter(InstanceCounters::kFrameCounter);
432 438
433 if (owner_) 439 if (owner_)
434 owner_->SetContentFrame(*this); 440 owner_->SetContentFrame(*this);
435 else 441 else
436 page_->SetMainFrame(this); 442 page_->SetMainFrame(this);
437 } 443 }
438 444
439 } // namespace blink 445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698