OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 ? ToLocalFrame(content_frame_)->GetDocument() | 199 ? ToLocalFrame(content_frame_)->GetDocument() |
200 : 0; | 200 : 0; |
201 } | 201 } |
202 | 202 |
203 DOMWindow* HTMLFrameOwnerElement::contentWindow() const { | 203 DOMWindow* HTMLFrameOwnerElement::contentWindow() const { |
204 return content_frame_ ? content_frame_->DomWindow() : 0; | 204 return content_frame_ ? content_frame_->DomWindow() : 0; |
205 } | 205 } |
206 | 206 |
207 void HTMLFrameOwnerElement::SetSandboxFlags(SandboxFlags flags) { | 207 void HTMLFrameOwnerElement::SetSandboxFlags(SandboxFlags flags) { |
208 sandbox_flags_ = flags; | 208 sandbox_flags_ = flags; |
209 // Don't notify about updates if contentFrame() is null, for example when | 209 // Recalculate the container policy in case the allow-same-origin flag has |
| 210 // changed. |
| 211 container_policy_ = GetContainerPolicyFromAllowedFeatures( |
| 212 AllowedFeatures(), GetOriginForFeaturePolicy()); |
| 213 |
| 214 // Don't notify about updates if ContentFrame() is null, for example when |
210 // the subframe hasn't been created yet. | 215 // the subframe hasn't been created yet. |
211 if (ContentFrame()) | 216 if (ContentFrame()) { |
212 GetDocument().GetFrame()->Loader().Client()->DidChangeSandboxFlags( | 217 GetDocument().GetFrame()->Loader().Client()->DidChangeFramePolicy( |
213 ContentFrame(), flags); | 218 ContentFrame(), sandbox_flags_, container_policy_); |
| 219 } |
214 } | 220 } |
215 | 221 |
216 bool HTMLFrameOwnerElement::IsKeyboardFocusable() const { | 222 bool HTMLFrameOwnerElement::IsKeyboardFocusable() const { |
217 return content_frame_ && HTMLElement::IsKeyboardFocusable(); | 223 return content_frame_ && HTMLElement::IsKeyboardFocusable(); |
218 } | 224 } |
219 | 225 |
220 void HTMLFrameOwnerElement::DisposeFrameOrPluginSoon( | 226 void HTMLFrameOwnerElement::DisposeFrameOrPluginSoon( |
221 FrameOrPlugin* frame_or_plugin) { | 227 FrameOrPlugin* frame_or_plugin) { |
222 if (g_update_suspend_count) { | 228 if (g_update_suspend_count) { |
223 FrameOrPluginsPendingDispose().push_back(frame_or_plugin); | 229 FrameOrPluginsPendingDispose().push_back(frame_or_plugin); |
224 return; | 230 return; |
225 } | 231 } |
226 frame_or_plugin->Dispose(); | 232 frame_or_plugin->Dispose(); |
227 } | 233 } |
228 | 234 |
| 235 void HTMLFrameOwnerElement::UpdateContainerPolicy() { |
| 236 container_policy_ = GetContainerPolicyFromAllowedFeatures( |
| 237 AllowedFeatures(), GetOriginForFeaturePolicy()); |
| 238 // Don't notify about updates if ContentFrame() is null, for example when |
| 239 // the subframe hasn't been created yet. |
| 240 if (ContentFrame()) { |
| 241 GetDocument().GetFrame()->Loader().Client()->DidChangeFramePolicy( |
| 242 ContentFrame(), sandbox_flags_, container_policy_); |
| 243 } |
| 244 } |
| 245 |
229 void HTMLFrameOwnerElement::FrameOwnerPropertiesChanged() { | 246 void HTMLFrameOwnerElement::FrameOwnerPropertiesChanged() { |
230 // Don't notify about updates if contentFrame() is null, for example when | 247 // Don't notify about updates if ContentFrame() is null, for example when |
231 // the subframe hasn't been created yet. | 248 // the subframe hasn't been created yet. |
232 if (ContentFrame()) | 249 if (ContentFrame()) { |
233 GetDocument().GetFrame()->Loader().Client()->DidChangeFrameOwnerProperties( | 250 GetDocument().GetFrame()->Loader().Client()->DidChangeFrameOwnerProperties( |
234 this); | 251 this); |
| 252 } |
235 } | 253 } |
236 | 254 |
237 void HTMLFrameOwnerElement::DispatchLoad() { | 255 void HTMLFrameOwnerElement::DispatchLoad() { |
238 DispatchScopedEvent(Event::Create(EventTypeNames::load)); | 256 DispatchScopedEvent(Event::Create(EventTypeNames::load)); |
239 } | 257 } |
240 | 258 |
241 const WebVector<WebFeaturePolicyFeature>& | 259 const WebVector<WebFeaturePolicyFeature>& |
242 HTMLFrameOwnerElement::AllowedFeatures() const { | 260 HTMLFrameOwnerElement::AllowedFeatures() const { |
243 DEFINE_STATIC_LOCAL(WebVector<WebFeaturePolicyFeature>, features, ()); | 261 DEFINE_STATIC_LOCAL(WebVector<WebFeaturePolicyFeature>, features, ()); |
244 return features; | 262 return features; |
245 } | 263 } |
246 | 264 |
| 265 const WebParsedFeaturePolicy& HTMLFrameOwnerElement::ContainerPolicy() const { |
| 266 return container_policy_; |
| 267 } |
| 268 |
247 Document* HTMLFrameOwnerElement::getSVGDocument( | 269 Document* HTMLFrameOwnerElement::getSVGDocument( |
248 ExceptionState& exception_state) const { | 270 ExceptionState& exception_state) const { |
249 Document* doc = contentDocument(); | 271 Document* doc = contentDocument(); |
250 if (doc && doc->IsSVGDocument()) | 272 if (doc && doc->IsSVGDocument()) |
251 return doc; | 273 return doc; |
252 return nullptr; | 274 return nullptr; |
253 } | 275 } |
254 | 276 |
255 void HTMLFrameOwnerElement::SetWidget(FrameViewBase* frame_view_base) { | 277 void HTMLFrameOwnerElement::SetWidget(FrameViewBase* frame_view_base) { |
256 if (frame_view_base == widget_) | 278 if (frame_view_base == widget_) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 327 } |
306 | 328 |
307 FrameViewBase* HTMLFrameOwnerElement::OwnedWidget() const { | 329 FrameViewBase* HTMLFrameOwnerElement::OwnedWidget() const { |
308 return widget_.Get(); | 330 return widget_.Get(); |
309 } | 331 } |
310 | 332 |
311 bool HTMLFrameOwnerElement::LoadOrRedirectSubframe( | 333 bool HTMLFrameOwnerElement::LoadOrRedirectSubframe( |
312 const KURL& url, | 334 const KURL& url, |
313 const AtomicString& frame_name, | 335 const AtomicString& frame_name, |
314 bool replace_current_item) { | 336 bool replace_current_item) { |
| 337 UpdateContainerPolicy(); |
| 338 |
315 LocalFrame* parent_frame = GetDocument().GetFrame(); | 339 LocalFrame* parent_frame = GetDocument().GetFrame(); |
316 if (ContentFrame()) { | 340 if (ContentFrame()) { |
317 ContentFrame()->Navigate(GetDocument(), url, replace_current_item, | 341 ContentFrame()->Navigate(GetDocument(), url, replace_current_item, |
318 UserGestureStatus::kNone); | 342 UserGestureStatus::kNone); |
319 return true; | 343 return true; |
320 } | 344 } |
321 | 345 |
322 if (!GetDocument().GetSecurityOrigin()->CanDisplay(url)) { | 346 if (!GetDocument().GetSecurityOrigin()->CanDisplay(url)) { |
323 FrameLoader::ReportLocalLoadFailed(parent_frame, url.GetString()); | 347 FrameLoader::ReportLocalLoadFailed(parent_frame, url.GetString()); |
324 return false; | 348 return false; |
(...skipping 20 matching lines...) Expand all Loading... |
345 } | 369 } |
346 | 370 |
347 DEFINE_TRACE(HTMLFrameOwnerElement) { | 371 DEFINE_TRACE(HTMLFrameOwnerElement) { |
348 visitor->Trace(content_frame_); | 372 visitor->Trace(content_frame_); |
349 visitor->Trace(widget_); | 373 visitor->Trace(widget_); |
350 HTMLElement::Trace(visitor); | 374 HTMLElement::Trace(visitor); |
351 FrameOwner::Trace(visitor); | 375 FrameOwner::Trace(visitor); |
352 } | 376 } |
353 | 377 |
354 } // namespace blink | 378 } // namespace blink |
OLD | NEW |