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