| OLD | NEW |
| 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 r
ights reserved. | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 9 * rights reserved. |
| 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
| 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 11 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 11 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 12 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 12 * Copyright (C) 2008 Google Inc. | 13 * Copyright (C) 2008 Google Inc. |
| 13 * | 14 * |
| 14 * This library is free software; you can redistribute it and/or | 15 * This library is free software; you can redistribute it and/or |
| 15 * modify it under the terms of the GNU Library General Public | 16 * modify it under the terms of the GNU Library General Public |
| 16 * License as published by the Free Software Foundation; either | 17 * License as published by the Free Software Foundation; either |
| 17 * version 2 of the License, or (at your option) any later version. | 18 * version 2 of the License, or (at your option) any later version. |
| 18 * | 19 * |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return false; | 141 return false; |
| 141 | 142 |
| 142 const bool isLocalActiveOrigin = activeSecurityOrigin.isLocal(); | 143 const bool isLocalActiveOrigin = activeSecurityOrigin.isLocal(); |
| 143 for (const Frame* ancestorFrame = targetFrame; ancestorFrame; | 144 for (const Frame* ancestorFrame = targetFrame; ancestorFrame; |
| 144 ancestorFrame = ancestorFrame->tree().parent()) { | 145 ancestorFrame = ancestorFrame->tree().parent()) { |
| 145 const SecurityOrigin* ancestorSecurityOrigin = | 146 const SecurityOrigin* ancestorSecurityOrigin = |
| 146 ancestorFrame->securityContext()->getSecurityOrigin(); | 147 ancestorFrame->securityContext()->getSecurityOrigin(); |
| 147 if (activeSecurityOrigin.canAccess(ancestorSecurityOrigin)) | 148 if (activeSecurityOrigin.canAccess(ancestorSecurityOrigin)) |
| 148 return true; | 149 return true; |
| 149 | 150 |
| 150 // Allow file URL descendant navigation even when allowFileAccessFromFileURL
s is false. | 151 // Allow file URL descendant navigation even when |
| 151 // FIXME: It's a bit strange to special-case local origins here. Should we b
e doing | 152 // allowFileAccessFromFileURLs is false. |
| 152 // something more general instead? | 153 // FIXME: It's a bit strange to special-case local origins here. Should we |
| 154 // be doing something more general instead? |
| 153 if (isLocalActiveOrigin && ancestorSecurityOrigin->isLocal()) | 155 if (isLocalActiveOrigin && ancestorSecurityOrigin->isLocal()) |
| 154 return true; | 156 return true; |
| 155 } | 157 } |
| 156 | 158 |
| 157 return false; | 159 return false; |
| 158 } | 160 } |
| 159 | 161 |
| 160 bool Frame::canNavigate(const Frame& targetFrame) { | 162 bool Frame::canNavigate(const Frame& targetFrame) { |
| 161 String errorReason; | 163 String errorReason; |
| 162 bool isAllowedNavigation = | 164 bool isAllowedNavigation = |
| 163 canNavigateWithoutFramebusting(targetFrame, errorReason); | 165 canNavigateWithoutFramebusting(targetFrame, errorReason); |
| 164 | 166 |
| 165 if (targetFrame != this && | 167 if (targetFrame != this && |
| 166 !securityContext()->isSandboxed(SandboxTopNavigation) && | 168 !securityContext()->isSandboxed(SandboxTopNavigation) && |
| 167 targetFrame == tree().top()) { | 169 targetFrame == tree().top()) { |
| 168 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram, | 170 DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram, |
| 169 ("WebCore.Framebust", 4)); | 171 ("WebCore.Framebust", 4)); |
| 170 const unsigned userGestureBit = 0x1; | 172 const unsigned userGestureBit = 0x1; |
| 171 const unsigned allowedBit = 0x2; | 173 const unsigned allowedBit = 0x2; |
| 172 unsigned framebustParams = 0; | 174 unsigned framebustParams = 0; |
| 173 UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame); | 175 UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame); |
| 174 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); | 176 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); |
| 175 if (hasUserGesture) | 177 if (hasUserGesture) |
| 176 framebustParams |= userGestureBit; | 178 framebustParams |= userGestureBit; |
| 177 if (isAllowedNavigation) | 179 if (isAllowedNavigation) |
| 178 framebustParams |= allowedBit; | 180 framebustParams |= allowedBit; |
| 179 framebustHistogram.count(framebustParams); | 181 framebustHistogram.count(framebustParams); |
| 180 // Frame-busting used to be generally allowed in most situations, but may no
w blocked if there is no user gesture. | 182 // Frame-busting used to be generally allowed in most situations, but may |
| 183 // now blocked if there is no user gesture. |
| 181 if (!RuntimeEnabledFeatures:: | 184 if (!RuntimeEnabledFeatures:: |
| 182 framebustingNeedsSameOriginOrUserGestureEnabled()) | 185 framebustingNeedsSameOriginOrUserGestureEnabled()) |
| 183 return true; | 186 return true; |
| 184 if (hasUserGesture || isAllowedNavigation) | 187 if (hasUserGesture || isAllowedNavigation) |
| 185 return true; | 188 return true; |
| 186 errorReason = | 189 errorReason = |
| 187 "The frame attempting navigation is targeting its top-level window, " | 190 "The frame attempting navigation is targeting its top-level window, " |
| 188 "but is neither same-origin with its target nor is it processing a " | 191 "but is neither same-origin with its target nor is it processing a " |
| 189 "user gesture. See " | 192 "user gesture. See " |
| 190 "https://www.chromestatus.com/features/5851021045661696."; | 193 "https://www.chromestatus.com/features/5851021045661696."; |
| 191 printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); | 194 printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); |
| 192 if (isLocalFrame()) | 195 if (isLocalFrame()) |
| 193 toLocalFrame(this)->navigationScheduler().schedulePageBlock( | 196 toLocalFrame(this)->navigationScheduler().schedulePageBlock( |
| 194 toLocalFrame(this)->document()); | 197 toLocalFrame(this)->document()); |
| 195 return false; | 198 return false; |
| 196 } | 199 } |
| 197 if (!isAllowedNavigation && !errorReason.isNull()) | 200 if (!isAllowedNavigation && !errorReason.isNull()) |
| 198 printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); | 201 printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); |
| 199 return isAllowedNavigation; | 202 return isAllowedNavigation; |
| 200 } | 203 } |
| 201 | 204 |
| 202 bool Frame::canNavigateWithoutFramebusting(const Frame& targetFrame, | 205 bool Frame::canNavigateWithoutFramebusting(const Frame& targetFrame, |
| 203 String& reason) { | 206 String& reason) { |
| 204 if (securityContext()->isSandboxed(SandboxNavigation)) { | 207 if (securityContext()->isSandboxed(SandboxNavigation)) { |
| 205 // Sandboxed frames can navigate their own children. | 208 // Sandboxed frames can navigate their own children. |
| 206 if (targetFrame.tree().isDescendantOf(this)) | 209 if (targetFrame.tree().isDescendantOf(this)) |
| 207 return true; | 210 return true; |
| 208 | 211 |
| 209 // They can also navigate popups, if the 'allow-sandbox-escape-via-popup' fl
ag is specified. | 212 // They can also navigate popups, if the 'allow-sandbox-escape-via-popup' |
| 213 // flag is specified. |
| 210 if (targetFrame == targetFrame.tree().top() && | 214 if (targetFrame == targetFrame.tree().top() && |
| 211 targetFrame.tree().top() != tree().top() && | 215 targetFrame.tree().top() != tree().top() && |
| 212 !securityContext()->isSandboxed( | 216 !securityContext()->isSandboxed( |
| 213 SandboxPropagatesToAuxiliaryBrowsingContexts)) | 217 SandboxPropagatesToAuxiliaryBrowsingContexts)) |
| 214 return true; | 218 return true; |
| 215 | 219 |
| 216 // Top navigation can be opted-in. | 220 // Top navigation can be opted-in. |
| 217 if (!securityContext()->isSandboxed(SandboxTopNavigation) && | 221 if (!securityContext()->isSandboxed(SandboxTopNavigation) && |
| 218 targetFrame == tree().top()) | 222 targetFrame == tree().top()) |
| 219 return true; | 223 return true; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 330 |
| 327 ASSERT(page()); | 331 ASSERT(page()); |
| 328 | 332 |
| 329 if (m_owner) | 333 if (m_owner) |
| 330 m_owner->setContentFrame(*this); | 334 m_owner->setContentFrame(*this); |
| 331 else | 335 else |
| 332 page()->setMainFrame(this); | 336 page()->setMainFrame(this); |
| 333 } | 337 } |
| 334 | 338 |
| 335 } // namespace blink | 339 } // namespace blink |
| OLD | NEW |