OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web/WebRemoteFrameImpl.h" | 5 #include "web/WebRemoteFrameImpl.h" |
6 | 6 |
7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
8 #include "bindings/core/v8/WindowProxy.h" | 8 #include "bindings/core/v8/WindowProxy.h" |
9 #include "core/dom/Fullscreen.h" | 9 #include "core/dom/Fullscreen.h" |
10 #include "core/dom/RemoteSecurityContext.h" | 10 #include "core/dom/RemoteSecurityContext.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() { | 72 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() { |
73 return this; | 73 return this; |
74 } | 74 } |
75 | 75 |
76 void WebRemoteFrameImpl::close() { | 76 void WebRemoteFrameImpl::close() { |
77 WebRemoteFrame::close(); | 77 WebRemoteFrame::close(); |
78 | 78 |
79 m_selfKeepAlive.clear(); | 79 m_selfKeepAlive.clear(); |
80 } | 80 } |
81 | 81 |
82 WebString WebRemoteFrameImpl::uniqueName() const { | |
83 NOTREACHED(); | |
84 return WebString(); | |
85 } | |
86 | |
87 WebString WebRemoteFrameImpl::assignedName() const { | 82 WebString WebRemoteFrameImpl::assignedName() const { |
88 NOTREACHED(); | 83 NOTREACHED(); |
89 return WebString(); | 84 return WebString(); |
90 } | 85 } |
91 | 86 |
92 void WebRemoteFrameImpl::setName(const WebString&) { | 87 void WebRemoteFrameImpl::setName(const WebString&) { |
93 NOTREACHED(); | 88 NOTREACHED(); |
94 } | 89 } |
95 | 90 |
96 WebVector<WebIconURL> WebRemoteFrameImpl::iconURLs(int iconTypesMask) const { | 91 WebVector<WebIconURL> WebRemoteFrameImpl::iconURLs(int iconTypesMask) const { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 } | 313 } |
319 | 314 |
320 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const { | 315 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const { |
321 NOTREACHED(); | 316 NOTREACHED(); |
322 return WebString(); | 317 return WebString(); |
323 } | 318 } |
324 | 319 |
325 WebLocalFrame* WebRemoteFrameImpl::createLocalChild( | 320 WebLocalFrame* WebRemoteFrameImpl::createLocalChild( |
326 WebTreeScopeType scope, | 321 WebTreeScopeType scope, |
327 const WebString& name, | 322 const WebString& name, |
328 const WebString& uniqueName, | |
329 WebSandboxFlags sandboxFlags, | 323 WebSandboxFlags sandboxFlags, |
330 WebFrameClient* client, | 324 WebFrameClient* client, |
331 blink::InterfaceProvider* interfaceProvider, | 325 blink::InterfaceProvider* interfaceProvider, |
332 blink::InterfaceRegistry* interfaceRegistry, | 326 blink::InterfaceRegistry* interfaceRegistry, |
333 WebFrame* previousSibling, | 327 WebFrame* previousSibling, |
334 const WebFrameOwnerProperties& frameOwnerProperties, | 328 const WebFrameOwnerProperties& frameOwnerProperties, |
335 WebFrame* opener) { | 329 WebFrame* opener) { |
336 WebLocalFrameImpl* child = WebLocalFrameImpl::create( | 330 WebLocalFrameImpl* child = WebLocalFrameImpl::create( |
337 scope, client, interfaceProvider, interfaceRegistry, opener); | 331 scope, client, interfaceProvider, interfaceRegistry, opener); |
338 insertAfter(child, previousSibling); | 332 insertAfter(child, previousSibling); |
339 RemoteFrameOwner* owner = RemoteFrameOwner::create( | 333 RemoteFrameOwner* owner = RemoteFrameOwner::create( |
340 static_cast<SandboxFlags>(sandboxFlags), frameOwnerProperties); | 334 static_cast<SandboxFlags>(sandboxFlags), frameOwnerProperties); |
341 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, | 335 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, |
342 // which may result in the browser observing two navigations to about:blank | 336 // which may result in the browser observing two navigations to about:blank |
343 // (one from the initial frame creation, and one from swapping it into the | 337 // (one from the initial frame creation, and one from swapping it into the |
344 // remote process). FrameLoader might need a special initialization function | 338 // remote process). FrameLoader might need a special initialization function |
345 // for this case to avoid that duplicate navigation. | 339 // for this case to avoid that duplicate navigation. |
346 child->initializeCoreFrame(frame()->host(), owner, name, uniqueName); | 340 child->initializeCoreFrame(frame()->host(), owner, name); |
347 // Partially related with the above FIXME--the init() call may trigger JS | 341 // Partially related with the above FIXME--the init() call may trigger JS |
348 // dispatch. However, | 342 // dispatch. However, |
349 // if the parent is remote, it should never be detached synchronously... | 343 // if the parent is remote, it should never be detached synchronously... |
350 DCHECK(child->frame()); | 344 DCHECK(child->frame()); |
351 return child; | 345 return child; |
352 } | 346 } |
353 | 347 |
354 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, | 348 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, |
355 FrameOwner* owner, | 349 FrameOwner* owner, |
356 const AtomicString& name, | 350 const AtomicString& name) { |
357 const AtomicString& uniqueName) { | |
358 setCoreFrame(RemoteFrame::create(m_frameClient.get(), | 351 setCoreFrame(RemoteFrame::create(m_frameClient.get(), |
359 host ? &host->page() : nullptr, owner)); | 352 host ? &host->page() : nullptr, owner)); |
360 frame()->createView(); | 353 frame()->createView(); |
361 m_frame->tree().setPrecalculatedName(name, uniqueName); | 354 m_frame->tree().setName(name); |
362 } | 355 } |
363 | 356 |
364 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild( | 357 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild( |
365 WebTreeScopeType scope, | 358 WebTreeScopeType scope, |
366 const WebString& name, | 359 const WebString& name, |
367 const WebString& uniqueName, | |
368 WebSandboxFlags sandboxFlags, | 360 WebSandboxFlags sandboxFlags, |
369 WebRemoteFrameClient* client, | 361 WebRemoteFrameClient* client, |
370 WebFrame* opener) { | 362 WebFrame* opener) { |
371 WebRemoteFrameImpl* child = WebRemoteFrameImpl::create(scope, client, opener); | 363 WebRemoteFrameImpl* child = WebRemoteFrameImpl::create(scope, client, opener); |
372 appendChild(child); | 364 appendChild(child); |
373 RemoteFrameOwner* owner = RemoteFrameOwner::create( | 365 RemoteFrameOwner* owner = RemoteFrameOwner::create( |
374 static_cast<SandboxFlags>(sandboxFlags), WebFrameOwnerProperties()); | 366 static_cast<SandboxFlags>(sandboxFlags), WebFrameOwnerProperties()); |
375 child->initializeCoreFrame(frame()->host(), owner, name, uniqueName); | 367 child->initializeCoreFrame(frame()->host(), owner, name); |
376 return child; | 368 return child; |
377 } | 369 } |
378 | 370 |
379 void WebRemoteFrameImpl::setWebLayer(WebLayer* layer) { | 371 void WebRemoteFrameImpl::setWebLayer(WebLayer* layer) { |
380 if (!frame()) | 372 if (!frame()) |
381 return; | 373 return; |
382 | 374 |
383 frame()->setWebLayer(layer); | 375 frame()->setWebLayer(layer); |
384 } | 376 } |
385 | 377 |
386 void WebRemoteFrameImpl::setCoreFrame(RemoteFrame* frame) { | 378 void WebRemoteFrameImpl::setCoreFrame(RemoteFrame* frame) { |
387 m_frame = frame; | 379 m_frame = frame; |
388 } | 380 } |
389 | 381 |
390 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) { | 382 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) { |
391 if (!frame.client()) | 383 if (!frame.client()) |
392 return nullptr; | 384 return nullptr; |
393 return static_cast<RemoteFrameClientImpl*>(frame.client())->webFrame(); | 385 return static_cast<RemoteFrameClientImpl*>(frame.client())->webFrame(); |
394 } | 386 } |
395 | 387 |
396 void WebRemoteFrameImpl::setReplicatedOrigin( | 388 void WebRemoteFrameImpl::setReplicatedOrigin(const WebSecurityOrigin& origin) { |
397 const WebSecurityOrigin& origin) const { | |
398 DCHECK(frame()); | 389 DCHECK(frame()); |
399 frame()->securityContext()->setReplicatedOrigin(origin); | 390 frame()->securityContext()->setReplicatedOrigin(origin); |
400 | 391 |
401 // If the origin of a remote frame changed, the accessibility object for the | 392 // If the origin of a remote frame changed, the accessibility object for the |
402 // owner element now points to a different child. | 393 // owner element now points to a different child. |
403 // | 394 // |
404 // TODO(dmazzoni, dcheng): there's probably a better way to solve this. | 395 // TODO(dmazzoni, dcheng): there's probably a better way to solve this. |
405 // Run SitePerProcessAccessibilityBrowserTest.TwoCrossSiteNavigations to | 396 // Run SitePerProcessAccessibilityBrowserTest.TwoCrossSiteNavigations to |
406 // ensure an alternate fix works. http://crbug.com/566222 | 397 // ensure an alternate fix works. http://crbug.com/566222 |
407 FrameOwner* owner = frame()->owner(); | 398 FrameOwner* owner = frame()->owner(); |
408 if (owner && owner->isLocal()) { | 399 if (owner && owner->isLocal()) { |
409 HTMLElement* ownerElement = toHTMLFrameOwnerElement(owner); | 400 HTMLElement* ownerElement = toHTMLFrameOwnerElement(owner); |
410 AXObjectCache* cache = ownerElement->document().existingAXObjectCache(); | 401 AXObjectCache* cache = ownerElement->document().existingAXObjectCache(); |
411 if (cache) | 402 if (cache) |
412 cache->childrenChanged(ownerElement); | 403 cache->childrenChanged(ownerElement); |
413 } | 404 } |
414 } | 405 } |
415 | 406 |
416 void WebRemoteFrameImpl::setReplicatedSandboxFlags( | 407 void WebRemoteFrameImpl::setReplicatedSandboxFlags(WebSandboxFlags flags) { |
417 WebSandboxFlags flags) const { | |
418 DCHECK(frame()); | 408 DCHECK(frame()); |
419 frame()->securityContext()->enforceSandboxFlags( | 409 frame()->securityContext()->enforceSandboxFlags( |
420 static_cast<SandboxFlags>(flags)); | 410 static_cast<SandboxFlags>(flags)); |
421 } | 411 } |
422 | 412 |
423 void WebRemoteFrameImpl::setReplicatedName(const WebString& name, | 413 void WebRemoteFrameImpl::setReplicatedName(const WebString& name) { |
424 const WebString& uniqueName) const { | |
425 DCHECK(frame()); | 414 DCHECK(frame()); |
426 frame()->tree().setPrecalculatedName(name, uniqueName); | 415 frame()->tree().setName(name); |
427 } | 416 } |
428 | 417 |
429 void WebRemoteFrameImpl::setReplicatedFeaturePolicyHeader( | 418 void WebRemoteFrameImpl::setReplicatedFeaturePolicyHeader( |
430 const WebParsedFeaturePolicy& parsedHeader) const { | 419 const WebParsedFeaturePolicy& parsedHeader) { |
431 if (RuntimeEnabledFeatures::featurePolicyEnabled()) { | 420 if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |
432 WebFeaturePolicy* parentFeaturePolicy = nullptr; | 421 WebFeaturePolicy* parentFeaturePolicy = nullptr; |
433 if (parent()) { | 422 if (parent()) { |
434 Frame* parentFrame = frame()->client()->parent(); | 423 Frame* parentFrame = frame()->client()->parent(); |
435 parentFeaturePolicy = parentFrame->securityContext()->getFeaturePolicy(); | 424 parentFeaturePolicy = parentFrame->securityContext()->getFeaturePolicy(); |
436 } | 425 } |
437 WebParsedFeaturePolicy containerPolicy; | 426 WebParsedFeaturePolicy containerPolicy; |
438 if (frame() && frame()->owner()) { | 427 if (frame() && frame()->owner()) { |
439 containerPolicy = getContainerPolicyFromAllowedFeatures( | 428 containerPolicy = getContainerPolicyFromAllowedFeatures( |
440 frame()->owner()->allowedFeatures(), | 429 frame()->owner()->allowedFeatures(), |
441 frame()->securityContext()->getSecurityOrigin()); | 430 frame()->securityContext()->getSecurityOrigin()); |
442 } | 431 } |
443 frame()->securityContext()->initializeFeaturePolicy( | 432 frame()->securityContext()->initializeFeaturePolicy( |
444 parsedHeader, containerPolicy, parentFeaturePolicy); | 433 parsedHeader, containerPolicy, parentFeaturePolicy); |
445 } | 434 } |
446 } | 435 } |
447 | 436 |
448 void WebRemoteFrameImpl::addReplicatedContentSecurityPolicyHeader( | 437 void WebRemoteFrameImpl::addReplicatedContentSecurityPolicyHeader( |
449 const WebString& headerValue, | 438 const WebString& headerValue, |
450 WebContentSecurityPolicyType type, | 439 WebContentSecurityPolicyType type, |
451 WebContentSecurityPolicySource source) const { | 440 WebContentSecurityPolicySource source) { |
452 frame()->securityContext()->contentSecurityPolicy()->addPolicyFromHeaderValue( | 441 frame()->securityContext()->contentSecurityPolicy()->addPolicyFromHeaderValue( |
453 headerValue, static_cast<ContentSecurityPolicyHeaderType>(type), | 442 headerValue, static_cast<ContentSecurityPolicyHeaderType>(type), |
454 static_cast<ContentSecurityPolicyHeaderSource>(source)); | 443 static_cast<ContentSecurityPolicyHeaderSource>(source)); |
455 } | 444 } |
456 | 445 |
457 void WebRemoteFrameImpl::resetReplicatedContentSecurityPolicy() const { | 446 void WebRemoteFrameImpl::resetReplicatedContentSecurityPolicy() { |
458 frame()->securityContext()->resetReplicatedContentSecurityPolicy(); | 447 frame()->securityContext()->resetReplicatedContentSecurityPolicy(); |
459 } | 448 } |
460 | 449 |
461 void WebRemoteFrameImpl::setReplicatedInsecureRequestPolicy( | 450 void WebRemoteFrameImpl::setReplicatedInsecureRequestPolicy( |
462 WebInsecureRequestPolicy policy) const { | 451 WebInsecureRequestPolicy policy) { |
463 DCHECK(frame()); | 452 DCHECK(frame()); |
464 frame()->securityContext()->setInsecureRequestPolicy(policy); | 453 frame()->securityContext()->setInsecureRequestPolicy(policy); |
465 } | 454 } |
466 | 455 |
467 void WebRemoteFrameImpl::setReplicatedPotentiallyTrustworthyUniqueOrigin( | 456 void WebRemoteFrameImpl::setReplicatedPotentiallyTrustworthyUniqueOrigin( |
468 bool isUniqueOriginPotentiallyTrustworthy) const { | 457 bool isUniqueOriginPotentiallyTrustworthy) { |
469 DCHECK(frame()); | 458 DCHECK(frame()); |
470 // If |isUniqueOriginPotentiallyTrustworthy| is true, then the origin must be | 459 // If |isUniqueOriginPotentiallyTrustworthy| is true, then the origin must be |
471 // unique. | 460 // unique. |
472 DCHECK(!isUniqueOriginPotentiallyTrustworthy || | 461 DCHECK(!isUniqueOriginPotentiallyTrustworthy || |
473 frame()->securityContext()->getSecurityOrigin()->isUnique()); | 462 frame()->securityContext()->getSecurityOrigin()->isUnique()); |
474 frame() | 463 frame() |
475 ->securityContext() | 464 ->securityContext() |
476 ->getSecurityOrigin() | 465 ->getSecurityOrigin() |
477 ->setUniqueOriginIsPotentiallyTrustworthy( | 466 ->setUniqueOriginIsPotentiallyTrustworthy( |
478 isUniqueOriginPotentiallyTrustworthy); | 467 isUniqueOriginPotentiallyTrustworthy); |
479 } | 468 } |
480 | 469 |
481 void WebRemoteFrameImpl::dispatchLoadEventOnFrameOwner() const { | 470 void WebRemoteFrameImpl::dispatchLoadEventOnFrameOwner() { |
482 DCHECK(frame()->owner()->isLocal()); | 471 DCHECK(frame()->owner()->isLocal()); |
483 frame()->owner()->dispatchLoad(); | 472 frame()->owner()->dispatchLoad(); |
484 } | 473 } |
485 | 474 |
486 void WebRemoteFrameImpl::didStartLoading() { | 475 void WebRemoteFrameImpl::didStartLoading() { |
487 frame()->setIsLoading(true); | 476 frame()->setIsLoading(true); |
488 } | 477 } |
489 | 478 |
490 void WebRemoteFrameImpl::didStopLoading() { | 479 void WebRemoteFrameImpl::didStopLoading() { |
491 frame()->setIsLoading(false); | 480 frame()->setIsLoading(false); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 529 } |
541 | 530 |
542 WebRemoteFrameImpl::WebRemoteFrameImpl(WebTreeScopeType scope, | 531 WebRemoteFrameImpl::WebRemoteFrameImpl(WebTreeScopeType scope, |
543 WebRemoteFrameClient* client) | 532 WebRemoteFrameClient* client) |
544 : WebRemoteFrame(scope), | 533 : WebRemoteFrame(scope), |
545 m_frameClient(RemoteFrameClientImpl::create(this)), | 534 m_frameClient(RemoteFrameClientImpl::create(this)), |
546 m_client(client), | 535 m_client(client), |
547 m_selfKeepAlive(this) {} | 536 m_selfKeepAlive(this) {} |
548 | 537 |
549 } // namespace blink | 538 } // namespace blink |
OLD | NEW |