| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // place at this point since we are no longer associated with the Page. | 335 // place at this point since we are no longer associated with the Page. |
| 336 m_webFrame->setClient(0); | 336 m_webFrame->setClient(0); |
| 337 | 337 |
| 338 client->frameDetached(m_webFrame, | 338 client->frameDetached(m_webFrame, |
| 339 static_cast<WebFrameClient::DetachType>(type)); | 339 static_cast<WebFrameClient::DetachType>(type)); |
| 340 // Clear our reference to LocalFrame at the very end, in case the client | 340 // Clear our reference to LocalFrame at the very end, in case the client |
| 341 // refers to it. | 341 // refers to it. |
| 342 m_webFrame->setCoreFrame(nullptr); | 342 m_webFrame->setCoreFrame(nullptr); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void FrameLoaderClientImpl::dispatchWillSendRequest(ResourceRequest& request) { | 345 void FrameLoaderClientImpl::willSendRequest(ResourceRequest& request, |
| 346 FrameLoadType type) { |
| 346 // Give the WebFrameClient a crack at the request. | 347 // Give the WebFrameClient a crack at the request. |
| 347 if (m_webFrame->client()) { | 348 if (m_webFrame->client()) { |
| 348 WrappedResourceRequest webreq(request); | 349 WrappedResourceRequest webreq(request); |
| 349 m_webFrame->client()->willSendRequest(m_webFrame, webreq); | 350 m_webFrame->client()->willSendRequest(m_webFrame, webreq, |
| 351 static_cast<WebFrameLoadType>(type)); |
| 350 } | 352 } |
| 351 } | 353 } |
| 352 | 354 |
| 353 void FrameLoaderClientImpl::dispatchDidReceiveResponse( | 355 void FrameLoaderClientImpl::dispatchDidReceiveResponse( |
| 354 const ResourceResponse& response) { | 356 const ResourceResponse& response) { |
| 355 if (m_webFrame->client()) { | 357 if (m_webFrame->client()) { |
| 356 WrappedResourceResponse webresp(response); | 358 WrappedResourceResponse webresp(response); |
| 357 m_webFrame->client()->didReceiveResponse(webresp); | 359 m_webFrame->client()->didReceiveResponse(webresp); |
| 358 } | 360 } |
| 359 } | 361 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 380 m_webFrame->client()->didHandleOnloadEvents(m_webFrame); | 382 m_webFrame->client()->didHandleOnloadEvents(m_webFrame); |
| 381 } | 383 } |
| 382 | 384 |
| 383 void FrameLoaderClientImpl:: | 385 void FrameLoaderClientImpl:: |
| 384 dispatchDidReceiveServerRedirectForProvisionalLoad() { | 386 dispatchDidReceiveServerRedirectForProvisionalLoad() { |
| 385 if (m_webFrame->client()) | 387 if (m_webFrame->client()) |
| 386 m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad( | 388 m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad( |
| 387 m_webFrame); | 389 m_webFrame); |
| 388 } | 390 } |
| 389 | 391 |
| 390 void FrameLoaderClientImpl::dispatchDidNavigateWithinPage( | 392 void FrameLoaderClientImpl::didNavigateWithinPage(DocumentLoader* loader, |
| 391 HistoryItem* item, | 393 FrameLoadType frameLoadType, |
| 392 HistoryCommitType commitType, | 394 HistoryItem* item, |
| 393 bool contentInitiated) { | 395 HistoryCommitType commitType, |
| 396 bool contentInitiated) { |
| 394 bool shouldCreateHistoryEntry = commitType == StandardCommit; | 397 bool shouldCreateHistoryEntry = commitType == StandardCommit; |
| 395 // TODO(dglazkov): Does this need to be called for subframes? | 398 // TODO(dglazkov): Does this need to be called for subframes? |
| 396 m_webFrame->viewImpl()->didCommitLoad(shouldCreateHistoryEntry, true); | 399 m_webFrame->viewImpl()->didCommitLoad(shouldCreateHistoryEntry, true); |
| 397 if (m_webFrame->client()) | 400 if (m_webFrame->client()) { |
| 398 m_webFrame->client()->didNavigateWithinPage( | 401 m_webFrame->client()->didNavigateWithinPage( |
| 399 m_webFrame, WebHistoryItem(item), | 402 WebDataSourceImpl::fromDocumentLoader(loader), |
| 403 static_cast<WebFrameLoadType>(frameLoadType), WebHistoryItem(item), |
| 400 static_cast<WebHistoryCommitType>(commitType), contentInitiated); | 404 static_cast<WebHistoryCommitType>(commitType), contentInitiated); |
| 405 } |
| 401 } | 406 } |
| 402 | 407 |
| 403 void FrameLoaderClientImpl::dispatchWillCommitProvisionalLoad() { | 408 void FrameLoaderClientImpl::dispatchWillCommitProvisionalLoad() { |
| 404 if (m_webFrame->client()) | 409 if (m_webFrame->client()) |
| 405 m_webFrame->client()->willCommitProvisionalLoad(m_webFrame); | 410 m_webFrame->client()->willCommitProvisionalLoad(m_webFrame); |
| 406 } | 411 } |
| 407 | 412 |
| 408 void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad() { | 413 void FrameLoaderClientImpl::didStartProvisionalLoad( |
| 409 if (m_webFrame->client()) | 414 DocumentLoader* loader, |
| 410 m_webFrame->client()->didStartProvisionalLoad(m_webFrame); | 415 FrameLoadType frameLoadType) { |
| 416 if (m_webFrame->client()) { |
| 417 m_webFrame->client()->didStartProvisionalLoad( |
| 418 WebDataSourceImpl::fromDocumentLoader(loader), |
| 419 static_cast<WebFrameLoadType>(frameLoadType)); |
| 420 } |
| 411 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) | 421 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) |
| 412 devTools->didStartProvisionalLoad(m_webFrame->frame()); | 422 devTools->didStartProvisionalLoad(m_webFrame->frame()); |
| 413 } | 423 } |
| 414 | 424 |
| 415 void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title) { | 425 void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title) { |
| 416 if (m_webFrame->client()) | 426 if (m_webFrame->client()) |
| 417 m_webFrame->client()->didReceiveTitle(m_webFrame, title, | 427 m_webFrame->client()->didReceiveTitle(m_webFrame, title, |
| 418 WebTextDirectionLeftToRight); | 428 WebTextDirectionLeftToRight); |
| 419 } | 429 } |
| 420 | 430 |
| 421 void FrameLoaderClientImpl::dispatchDidChangeIcons(IconType type) { | 431 void FrameLoaderClientImpl::dispatchDidChangeIcons(IconType type) { |
| 422 if (m_webFrame->client()) | 432 if (m_webFrame->client()) |
| 423 m_webFrame->client()->didChangeIcon(m_webFrame, | 433 m_webFrame->client()->didChangeIcon(m_webFrame, |
| 424 static_cast<WebIconURL::Type>(type)); | 434 static_cast<WebIconURL::Type>(type)); |
| 425 } | 435 } |
| 426 | 436 |
| 427 void FrameLoaderClientImpl::dispatchDidCommitLoad( | 437 void FrameLoaderClientImpl::didCommitProvisionalLoad( |
| 438 DocumentLoader* loader, |
| 439 FrameLoadType frameLoadType, |
| 428 HistoryItem* item, | 440 HistoryItem* item, |
| 429 HistoryCommitType commitType) { | 441 HistoryCommitType commitType) { |
| 430 if (!m_webFrame->parent()) { | 442 if (!m_webFrame->parent()) { |
| 431 m_webFrame->viewImpl()->didCommitLoad(commitType == StandardCommit, false); | 443 m_webFrame->viewImpl()->didCommitLoad(commitType == StandardCommit, false); |
| 432 } | 444 } |
| 433 | 445 |
| 434 if (m_webFrame->client()) | 446 if (m_webFrame->client()) { |
| 435 m_webFrame->client()->didCommitProvisionalLoad( | 447 m_webFrame->client()->didCommitProvisionalLoad( |
| 436 m_webFrame, WebHistoryItem(item), | 448 WebDataSourceImpl::fromDocumentLoader(loader), |
| 449 static_cast<WebFrameLoadType>(frameLoadType), WebHistoryItem(item), |
| 437 static_cast<WebHistoryCommitType>(commitType)); | 450 static_cast<WebHistoryCommitType>(commitType)); |
| 451 } |
| 438 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) | 452 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) |
| 439 devTools->didCommitLoadForLocalFrame(m_webFrame->frame()); | 453 devTools->didCommitLoadForLocalFrame(m_webFrame->frame()); |
| 440 } | 454 } |
| 441 | 455 |
| 442 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad( | 456 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad( |
| 443 const ResourceError& error, | 457 const ResourceError& error, |
| 444 HistoryCommitType commitType) { | 458 HistoryCommitType commitType) { |
| 445 m_webFrame->didFail(error, true, commitType); | 459 m_webFrame->didFail(error, true, commitType); |
| 446 } | 460 } |
| 447 | 461 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 NavigationPolicy userPolicy; | 511 NavigationPolicy userPolicy; |
| 498 if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, | 512 if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, |
| 499 &userPolicy)) | 513 &userPolicy)) |
| 500 return false; | 514 return false; |
| 501 return userPolicy == NavigationPolicyNewBackgroundTab; | 515 return userPolicy == NavigationPolicyNewBackgroundTab; |
| 502 } | 516 } |
| 503 | 517 |
| 504 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation( | 518 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation( |
| 505 const ResourceRequest& request, | 519 const ResourceRequest& request, |
| 506 DocumentLoader* loader, | 520 DocumentLoader* loader, |
| 507 NavigationType type, | |
| 508 NavigationPolicy policy, | 521 NavigationPolicy policy, |
| 509 bool replacesCurrentHistoryItem, | 522 FrameLoadType frameLoadType, |
| 510 bool isClientRedirect, | 523 bool isClientRedirect, |
| 511 HTMLFormElement* form) { | 524 HTMLFormElement* form) { |
| 512 if (!m_webFrame->client()) | 525 if (!m_webFrame->client()) |
| 513 return NavigationPolicyIgnore; | 526 return NavigationPolicyIgnore; |
| 514 | 527 |
| 515 if (policy == NavigationPolicyNewBackgroundTab && | 528 if (policy == NavigationPolicyNewBackgroundTab && |
| 516 !allowCreatingBackgroundTabs() && | 529 !allowCreatingBackgroundTabs() && |
| 517 !UIEventWithKeyState::newTabModifierSetFromIsolatedWorld()) | 530 !UIEventWithKeyState::newTabModifierSetFromIsolatedWorld()) |
| 518 policy = NavigationPolicyNewForegroundTab; | 531 policy = NavigationPolicyNewForegroundTab; |
| 519 | 532 |
| 520 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); | 533 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); |
| 521 | 534 |
| 522 // Newly created child frames may need to be navigated to a history item | |
| 523 // during a back/forward navigation. This will only happen when the parent | |
| 524 // is a LocalFrame doing a back/forward navigation that has not completed. | |
| 525 // (If the load has completed and the parent later adds a frame with script, | |
| 526 // we do not want to use a history item for it.) | |
| 527 bool isHistoryNavigationInNewChildFrame = | |
| 528 m_webFrame->parent() && m_webFrame->parent()->isWebLocalFrame() && | |
| 529 isBackForwardLoadType(toWebLocalFrameImpl(m_webFrame->parent()) | |
| 530 ->frame() | |
| 531 ->loader() | |
| 532 .documentLoader() | |
| 533 ->loadType()) && | |
| 534 !toWebLocalFrameImpl(m_webFrame->parent()) | |
| 535 ->frame() | |
| 536 ->document() | |
| 537 ->loadEventFinished(); | |
| 538 | |
| 539 WrappedResourceRequest wrappedResourceRequest(request); | 535 WrappedResourceRequest wrappedResourceRequest(request); |
| 540 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); | 536 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); |
| 541 navigationInfo.navigationType = static_cast<WebNavigationType>(type); | |
| 542 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); | 537 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); |
| 543 navigationInfo.extraData = ds ? ds->getExtraData() : nullptr; | 538 navigationInfo.extraData = ds ? ds->getExtraData() : nullptr; |
| 544 navigationInfo.replacesCurrentHistoryItem = replacesCurrentHistoryItem; | 539 navigationInfo.loadType = static_cast<WebFrameLoadType>(frameLoadType); |
| 545 navigationInfo.isHistoryNavigationInNewChildFrame = | |
| 546 isHistoryNavigationInNewChildFrame; | |
| 547 navigationInfo.isClientRedirect = isClientRedirect; | 540 navigationInfo.isClientRedirect = isClientRedirect; |
| 548 // Caching could be disabled for requests initiated by DevTools. | 541 // Caching could be disabled for requests initiated by DevTools. |
| 549 // TODO(ananta) | 542 // TODO(ananta) |
| 550 // We should extract the network cache state into a global component which | 543 // We should extract the network cache state into a global component which |
| 551 // can be queried here and wherever necessary. | 544 // can be queried here and wherever necessary. |
| 552 navigationInfo.isCacheDisabled = | 545 navigationInfo.isCacheDisabled = |
| 553 devToolsAgent() ? devToolsAgent()->cacheDisabled() : false; | 546 devToolsAgent() ? devToolsAgent()->cacheDisabled() : false; |
| 554 if (form) | 547 if (form) |
| 555 navigationInfo.form = WebFormElement(form); | 548 navigationInfo.form = WebFormElement(form); |
| 556 | 549 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 581 } | 574 } |
| 582 | 575 |
| 583 void FrameLoaderClientImpl::didStopLoading() { | 576 void FrameLoaderClientImpl::didStopLoading() { |
| 584 if (m_webFrame->client()) | 577 if (m_webFrame->client()) |
| 585 m_webFrame->client()->didStopLoading(); | 578 m_webFrame->client()->didStopLoading(); |
| 586 } | 579 } |
| 587 | 580 |
| 588 void FrameLoaderClientImpl::loadURLExternally(const ResourceRequest& request, | 581 void FrameLoaderClientImpl::loadURLExternally(const ResourceRequest& request, |
| 589 NavigationPolicy policy, | 582 NavigationPolicy policy, |
| 590 const String& suggestedName, | 583 const String& suggestedName, |
| 591 bool shouldReplaceCurrentEntry) { | 584 FrameLoadType loadType) { |
| 592 if (!m_webFrame->client()) | 585 if (!m_webFrame->client()) |
| 593 return; | 586 return; |
| 594 DCHECK(m_webFrame->frame()->document()); | 587 DCHECK(m_webFrame->frame()->document()); |
| 595 Fullscreen::fullyExitFullscreen(*m_webFrame->frame()->document()); | 588 Fullscreen::fullyExitFullscreen(*m_webFrame->frame()->document()); |
| 596 m_webFrame->client()->loadURLExternally( | 589 m_webFrame->client()->loadURLExternally( |
| 597 WrappedResourceRequest(request), static_cast<WebNavigationPolicy>(policy), | 590 WrappedResourceRequest(request), static_cast<WebNavigationPolicy>(policy), |
| 598 suggestedName, shouldReplaceCurrentEntry); | 591 suggestedName, static_cast<WebFrameLoadType>(loadType)); |
| 599 } | 592 } |
| 600 | 593 |
| 601 void FrameLoaderClientImpl::loadErrorPage(int reason) { | 594 void FrameLoaderClientImpl::loadErrorPage(int reason) { |
| 602 if (m_webFrame->client()) | 595 if (m_webFrame->client()) |
| 603 m_webFrame->client()->loadErrorPage(reason); | 596 m_webFrame->client()->loadErrorPage(reason); |
| 604 } | 597 } |
| 605 | 598 |
| 606 bool FrameLoaderClientImpl::navigateBackForward(int offset) const { | 599 bool FrameLoaderClientImpl::navigateBackForward(int offset) const { |
| 607 WebViewImpl* webview = m_webFrame->viewImpl(); | 600 WebViewImpl* webview = m_webFrame->viewImpl(); |
| 608 if (!webview->client()) | 601 if (!webview->client()) |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 KURL FrameLoaderClientImpl::overrideFlashEmbedWithHTML(const KURL& url) { | 992 KURL FrameLoaderClientImpl::overrideFlashEmbedWithHTML(const KURL& url) { |
| 1000 return m_webFrame->client()->overrideFlashEmbedWithHTML(WebURL(url)); | 993 return m_webFrame->client()->overrideFlashEmbedWithHTML(WebURL(url)); |
| 1001 } | 994 } |
| 1002 | 995 |
| 1003 void FrameLoaderClientImpl::setHasReceivedUserGesture() { | 996 void FrameLoaderClientImpl::setHasReceivedUserGesture() { |
| 1004 if (m_webFrame->client()) | 997 if (m_webFrame->client()) |
| 1005 m_webFrame->client()->setHasReceivedUserGesture(); | 998 m_webFrame->client()->setHasReceivedUserGesture(); |
| 1006 } | 999 } |
| 1007 | 1000 |
| 1008 } // namespace blink | 1001 } // namespace blink |
| OLD | NEW |