1 /* 2 * Copyright (C) 2007 Kevin Ollivier <kevino (at) theolliviers.com> 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include "config.h" 29 #include "FrameLoaderClientWx.h" 30 31 #include <JavaScriptCore/JavaScript.h> 32 #include <JavaScriptCore/APICast.h> 33 34 #include "DocumentLoader.h" 35 #include "FormState.h" 36 #include "Frame.h" 37 #include "FrameLoaderTypes.h" 38 #include "FrameView.h" 39 #include "FrameTree.h" 40 #include "PluginView.h" 41 #include "HTMLFormElement.h" 42 #include "HTMLFrameOwnerElement.h" 43 #include "NotImplemented.h" 44 #include "Page.h" 45 #include "PlatformString.h" 46 #include "PluginView.h" 47 #include "ProgressTracker.h" 48 #include "RenderPart.h" 49 #include "ResourceError.h" 50 #include "ResourceResponse.h" 51 #include "ScriptController.h" 52 #include "ScriptString.h" 53 #include <wtf/PassRefPtr.h> 54 #include <wtf/RefPtr.h> 55 56 #include <stdio.h> 57 58 #include "WebFrame.h" 59 #include "WebFramePrivate.h" 60 #include "WebView.h" 61 #include "WebViewPrivate.h" 62 63 namespace WebCore { 64 65 inline int wxNavTypeFromWebNavType(NavigationType type){ 66 if (type == NavigationTypeLinkClicked) 67 return wxWEBVIEW_NAV_LINK_CLICKED; 68 69 if (type == NavigationTypeFormSubmitted) 70 return wxWEBVIEW_NAV_FORM_SUBMITTED; 71 72 if (type == NavigationTypeBackForward) 73 return wxWEBVIEW_NAV_BACK_NEXT; 74 75 if (type == NavigationTypeReload) 76 return wxWEBVIEW_NAV_RELOAD; 77 78 if (type == NavigationTypeFormResubmitted) 79 return wxWEBVIEW_NAV_FORM_RESUBMITTED; 80 81 return wxWEBVIEW_NAV_OTHER; 82 } 83 84 FrameLoaderClientWx::FrameLoaderClientWx() 85 : m_frame(0) 86 , m_pluginView(0) 87 , m_hasSentResponseToPlugin(false) 88 , m_webFrame(0) 89 { 90 } 91 92 93 FrameLoaderClientWx::~FrameLoaderClientWx() 94 { 95 } 96 97 void FrameLoaderClientWx::setFrame(wxWebFrame *frame) 98 { 99 m_webFrame = frame; 100 m_frame = m_webFrame->m_impl->frame; 101 } 102 103 void FrameLoaderClientWx::setWebView(wxWebView *webview) 104 { 105 m_webView = webview; 106 } 107 108 bool FrameLoaderClientWx::hasWebView() const 109 { 110 return m_webView != NULL; 111 } 112 113 bool FrameLoaderClientWx::hasBackForwardList() const 114 { 115 notImplemented(); 116 return true; 117 } 118 119 120 void FrameLoaderClientWx::resetBackForwardList() 121 { 122 notImplemented(); 123 } 124 125 126 bool FrameLoaderClientWx::provisionalItemIsTarget() const 127 { 128 notImplemented(); 129 return false; 130 } 131 132 void FrameLoaderClientWx::makeRepresentation(DocumentLoader*) 133 { 134 notImplemented(); 135 } 136 137 138 void FrameLoaderClientWx::forceLayout() 139 { 140 notImplemented(); 141 } 142 143 144 void FrameLoaderClientWx::forceLayoutForNonHTML() 145 { 146 notImplemented(); 147 } 148 149 150 void FrameLoaderClientWx::updateHistoryForCommit() 151 { 152 notImplemented(); 153 } 154 155 156 void FrameLoaderClientWx::updateHistoryForBackForwardNavigation() 157 { 158 notImplemented(); 159 } 160 161 162 void FrameLoaderClientWx::updateHistoryForReload() 163 { 164 notImplemented(); 165 } 166 167 168 void FrameLoaderClientWx::updateHistoryForStandardLoad() 169 { 170 notImplemented(); 171 } 172 173 174 void FrameLoaderClientWx::updateHistoryForInternalLoad() 175 { 176 notImplemented(); 177 } 178 179 180 void FrameLoaderClientWx::updateHistoryAfterClientRedirect() 181 { 182 notImplemented(); 183 } 184 185 186 void FrameLoaderClientWx::setCopiesOnScroll() 187 { 188 // apparently mac specific 189 notImplemented(); 190 } 191 192 193 LoadErrorResetToken* FrameLoaderClientWx::tokenForLoadErrorReset() 194 { 195 notImplemented(); 196 return 0; 197 } 198 199 200 void FrameLoaderClientWx::resetAfterLoadError(LoadErrorResetToken*) 201 { 202 notImplemented(); 203 } 204 205 206 void FrameLoaderClientWx::doNotResetAfterLoadError(LoadErrorResetToken*) 207 { 208 notImplemented(); 209 } 210 211 212 void FrameLoaderClientWx::willCloseDocument() 213 { 214 notImplemented(); 215 } 216 217 218 void FrameLoaderClientWx::detachedFromParent2() 219 { 220 notImplemented(); 221 } 222 223 224 void FrameLoaderClientWx::detachedFromParent3() 225 { 226 notImplemented(); 227 } 228 229 void FrameLoaderClientWx::dispatchDidHandleOnloadEvents() 230 { 231 if (m_webView) { 232 wxWebViewLoadEvent wkEvent(m_webView); 233 wkEvent.SetState(wxWEBVIEW_LOAD_ONLOAD_HANDLED); 234 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string()); 235 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 236 } 237 } 238 239 240 void FrameLoaderClientWx::dispatchDidReceiveServerRedirectForProvisionalLoad() 241 { 242 notImplemented(); 243 } 244 245 246 void FrameLoaderClientWx::dispatchDidCancelClientRedirect() 247 { 248 notImplemented(); 249 } 250 251 252 void FrameLoaderClientWx::dispatchWillPerformClientRedirect(const KURL&, 253 double interval, 254 double fireDate) 255 { 256 notImplemented(); 257 } 258 259 260 void FrameLoaderClientWx::dispatchDidChangeLocationWithinPage() 261 { 262 notImplemented(); 263 } 264 265 void FrameLoaderClientWx::dispatchDidPushStateWithinPage() 266 { 267 notImplemented(); 268 } 269 270 void FrameLoaderClientWx::dispatchDidReplaceStateWithinPage() 271 { 272 notImplemented(); 273 } 274 275 void FrameLoaderClientWx::dispatchDidPopStateWithinPage() 276 { 277 notImplemented(); 278 } 279 280 void FrameLoaderClientWx::dispatchWillClose() 281 { 282 notImplemented(); 283 } 284 285 286 void FrameLoaderClientWx::dispatchDidStartProvisionalLoad() 287 { 288 if (m_webView) { 289 wxWebViewLoadEvent wkEvent(m_webView); 290 wkEvent.SetState(wxWEBVIEW_LOAD_NEGOTIATING); 291 wkEvent.SetURL(m_frame->loader()->provisionalDocumentLoader()->request().url().string()); 292 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 293 } 294 } 295 296 297 void FrameLoaderClientWx::dispatchDidReceiveTitle(const String& title) 298 { 299 if (m_webView) { 300 m_webView->SetPageTitle(title); 301 wxWebViewReceivedTitleEvent wkEvent(m_webView); 302 wkEvent.SetTitle(title); 303 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 304 } 305 } 306 307 308 void FrameLoaderClientWx::dispatchDidCommitLoad() 309 { 310 if (m_webView) { 311 wxWebViewLoadEvent wkEvent(m_webView); 312 wkEvent.SetState(wxWEBVIEW_LOAD_TRANSFERRING); 313 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string()); 314 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 315 } 316 } 317 318 void FrameLoaderClientWx::dispatchDidFinishDocumentLoad() 319 { 320 if (m_webView) { 321 wxWebViewLoadEvent wkEvent(m_webView); 322 wkEvent.SetState(wxWEBVIEW_LOAD_DOC_COMPLETED); 323 wkEvent.SetURL(m_frame->loader()->url().string()); 324 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 325 } 326 } 327 328 void FrameLoaderClientWx::dispatchDidFinishLoad() 329 { 330 notImplemented(); 331 } 332 333 334 void FrameLoaderClientWx::dispatchDidFirstLayout() 335 { 336 notImplemented(); 337 } 338 339 void FrameLoaderClientWx::dispatchDidFirstVisuallyNonEmptyLayout() 340 { 341 notImplemented(); 342 } 343 344 void FrameLoaderClientWx::dispatchShow() 345 { 346 notImplemented(); 347 } 348 349 350 void FrameLoaderClientWx::cancelPolicyCheck() 351 { 352 notImplemented(); 353 } 354 355 356 void FrameLoaderClientWx::dispatchWillSubmitForm(FramePolicyFunction function, 357 PassRefPtr<FormState>) 358 { 359 // FIXME: Send an event to allow for alerts and cancellation 360 if (!m_webFrame) 361 return; 362 (m_frame->loader()->policyChecker()->*function)(PolicyUse); 363 } 364 365 366 void FrameLoaderClientWx::dispatchDidLoadMainResource(DocumentLoader*) 367 { 368 notImplemented(); 369 } 370 371 372 void FrameLoaderClientWx::revertToProvisionalState(DocumentLoader*) 373 { 374 notImplemented(); 375 } 376 377 void FrameLoaderClientWx::postProgressStartedNotification() 378 { 379 notImplemented(); 380 } 381 382 void FrameLoaderClientWx::postProgressEstimateChangedNotification() 383 { 384 notImplemented(); 385 } 386 387 void FrameLoaderClientWx::postProgressFinishedNotification() 388 { 389 if (m_webView) { 390 wxWebViewLoadEvent wkEvent(m_webView); 391 wkEvent.SetState(wxWEBVIEW_LOAD_DL_COMPLETED); 392 wkEvent.SetURL(m_frame->loader()->url().string()); 393 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 394 } 395 } 396 397 void FrameLoaderClientWx::progressStarted() 398 { 399 notImplemented(); 400 } 401 402 403 void FrameLoaderClientWx::progressCompleted() 404 { 405 notImplemented(); 406 } 407 408 409 void FrameLoaderClientWx::setMainFrameDocumentReady(bool b) 410 { 411 notImplemented(); 412 // this is only interesting once we provide an external API for the DOM 413 } 414 415 416 void FrameLoaderClientWx::willChangeTitle(DocumentLoader*) 417 { 418 notImplemented(); 419 } 420 421 422 void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l) 423 { 424 setTitle(l->title(), l->url()); 425 } 426 427 428 void FrameLoaderClientWx::finishedLoading(DocumentLoader*) 429 { 430 if (m_pluginView) { 431 m_pluginView->didFinishLoading(); 432 m_pluginView = 0; 433 m_hasSentResponseToPlugin = false; 434 } 435 } 436 437 438 bool FrameLoaderClientWx::canShowMIMEType(const String& MIMEType) const 439 { 440 notImplemented(); 441 return true; 442 } 443 444 445 bool FrameLoaderClientWx::representationExistsForURLScheme(const String& URLScheme) const 446 { 447 notImplemented(); 448 return false; 449 } 450 451 452 String FrameLoaderClientWx::generatedMIMETypeForURLScheme(const String& URLScheme) const 453 { 454 notImplemented(); 455 return String(); 456 } 457 458 459 void FrameLoaderClientWx::frameLoadCompleted() 460 { 461 notImplemented(); 462 } 463 464 void FrameLoaderClientWx::saveViewStateToItem(HistoryItem*) 465 { 466 notImplemented(); 467 } 468 469 void FrameLoaderClientWx::restoreViewState() 470 { 471 notImplemented(); 472 } 473 474 void FrameLoaderClientWx::restoreScrollPositionAndViewState() 475 { 476 notImplemented(); 477 } 478 479 480 void FrameLoaderClientWx::provisionalLoadStarted() 481 { 482 notImplemented(); 483 } 484 485 486 bool FrameLoaderClientWx::shouldTreatURLAsSameAsCurrent(const KURL&) const 487 { 488 notImplemented(); 489 return false; 490 } 491 492 493 void FrameLoaderClientWx::addHistoryItemForFragmentScroll() 494 { 495 notImplemented(); 496 } 497 498 499 void FrameLoaderClientWx::didFinishLoad() 500 { 501 notImplemented(); 502 } 503 504 505 void FrameLoaderClientWx::prepareForDataSourceReplacement() 506 { 507 notImplemented(); 508 } 509 510 511 void FrameLoaderClientWx::setTitle(const String& title, const KURL&) 512 { 513 notImplemented(); 514 } 515 516 517 String FrameLoaderClientWx::userAgent(const KURL&) 518 { 519 // FIXME: Use the new APIs introduced by the GTK port to fill in these values. 520 return String("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3"); 521 } 522 523 void FrameLoaderClientWx::dispatchDidReceiveIcon() 524 { 525 notImplemented(); 526 } 527 528 void FrameLoaderClientWx::frameLoaderDestroyed() 529 { 530 if (m_webFrame) 531 delete m_webFrame; 532 m_webFrame = 0; 533 m_frame = 0; 534 delete this; 535 } 536 537 bool FrameLoaderClientWx::canHandleRequest(const WebCore::ResourceRequest&) const 538 { 539 notImplemented(); 540 return true; 541 } 542 543 void FrameLoaderClientWx::partClearedInBegin() 544 { 545 notImplemented(); 546 } 547 548 void FrameLoaderClientWx::updateGlobalHistory() 549 { 550 notImplemented(); 551 } 552 553 void FrameLoaderClientWx::updateGlobalHistoryRedirectLinks() 554 { 555 notImplemented(); 556 } 557 558 bool FrameLoaderClientWx::shouldGoToHistoryItem(WebCore::HistoryItem*) const 559 { 560 notImplemented(); 561 return true; 562 } 563 564 void FrameLoaderClientWx::dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const 565 { 566 } 567 568 void FrameLoaderClientWx::dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const 569 { 570 } 571 572 void FrameLoaderClientWx::dispatchDidChangeBackForwardIndex() const 573 { 574 } 575 576 void FrameLoaderClientWx::didDisplayInsecureContent() 577 { 578 notImplemented(); 579 } 580 581 void FrameLoaderClientWx::didRunInsecureContent(WebCore::SecurityOrigin*) 582 { 583 notImplemented(); 584 } 585 586 void FrameLoaderClientWx::saveScrollPositionAndViewStateToItem(WebCore::HistoryItem*) 587 { 588 notImplemented(); 589 } 590 591 bool FrameLoaderClientWx::canCachePage() const 592 { 593 return false; 594 } 595 596 void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) 597 { 598 notImplemented(); 599 } 600 601 void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length) 602 { 603 if (!m_webFrame) 604 return; 605 if (!m_pluginView) { 606 FrameLoader* fl = loader->frameLoader(); 607 fl->setEncoding(m_response.textEncodingName(), false); 608 fl->addData(data, length); 609 } 610 611 // We re-check here as the plugin can have been created 612 if (m_pluginView) { 613 if (!m_hasSentResponseToPlugin) { 614 m_pluginView->didReceiveResponse(loader->response()); 615 // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in 616 // setting up this stream can cause the main document load to be cancelled, setting m_pluginView 617 // to null 618 if (!m_pluginView) 619 return; 620 m_hasSentResponseToPlugin = true; 621 } 622 m_pluginView->didReceiveData(data, length); 623 } 624 } 625 626 WebCore::ResourceError FrameLoaderClientWx::cancelledError(const WebCore::ResourceRequest& request) 627 { 628 notImplemented(); 629 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String()); 630 } 631 632 WebCore::ResourceError FrameLoaderClientWx::blockedError(const ResourceRequest& request) 633 { 634 notImplemented(); 635 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String()); 636 } 637 638 WebCore::ResourceError FrameLoaderClientWx::cannotShowURLError(const WebCore::ResourceRequest& request) 639 { 640 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String()); 641 } 642 643 WebCore::ResourceError FrameLoaderClientWx::interruptForPolicyChangeError(const WebCore::ResourceRequest& request) 644 { 645 notImplemented(); 646 return ResourceError(String(), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), String()); 647 } 648 649 WebCore::ResourceError FrameLoaderClientWx::cannotShowMIMETypeError(const WebCore::ResourceResponse& response) 650 { 651 notImplemented(); 652 return ResourceError(String(), WebKitErrorCannotShowMIMEType, response.url().string(), String()); 653 } 654 655 WebCore::ResourceError FrameLoaderClientWx::fileDoesNotExistError(const WebCore::ResourceResponse& response) 656 { 657 notImplemented(); 658 return ResourceError(String(), WebKitErrorCannotShowURL, response.url().string(), String()); 659 } 660 661 bool FrameLoaderClientWx::shouldFallBack(const WebCore::ResourceError& error) 662 { 663 notImplemented(); 664 return false; 665 } 666 667 WTF::PassRefPtr<DocumentLoader> FrameLoaderClientWx::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) 668 { 669 return DocumentLoader::create(request, substituteData); 670 } 671 672 void FrameLoaderClientWx::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) 673 { 674 notImplemented(); 675 } 676 677 void FrameLoaderClientWx::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) 678 { 679 notImplemented(); 680 } 681 682 void FrameLoaderClientWx::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest& request, const ResourceResponse& response) 683 { 684 notImplemented(); 685 } 686 687 bool FrameLoaderClientWx::shouldUseCredentialStorage(DocumentLoader*, unsigned long) 688 { 689 notImplemented(); 690 return false; 691 } 692 693 void FrameLoaderClientWx::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) 694 { 695 notImplemented(); 696 } 697 698 void FrameLoaderClientWx::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) 699 { 700 notImplemented(); 701 } 702 703 void FrameLoaderClientWx::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long id, const ResourceResponse& response) 704 { 705 notImplemented(); 706 m_response = response; 707 m_firstData = true; 708 } 709 710 void FrameLoaderClientWx::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long id, int length) 711 { 712 notImplemented(); 713 } 714 715 void FrameLoaderClientWx::dispatchDidFinishLoading(DocumentLoader*, unsigned long) 716 { 717 notImplemented(); 718 } 719 720 void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&) 721 { 722 if (m_webView) { 723 wxWebViewLoadEvent wkEvent(m_webView); 724 wkEvent.SetState(wxWEBVIEW_LOAD_FAILED); 725 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string()); 726 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 727 } 728 } 729 730 bool FrameLoaderClientWx::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int) 731 { 732 notImplemented(); 733 return false; 734 } 735 736 void FrameLoaderClientWx::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const ScriptString&) 737 { 738 notImplemented(); 739 } 740 741 void FrameLoaderClientWx::dispatchDidFailProvisionalLoad(const ResourceError&) 742 { 743 notImplemented(); 744 } 745 746 void FrameLoaderClientWx::dispatchDidFailLoad(const ResourceError&) 747 { 748 notImplemented(); 749 } 750 751 Frame* FrameLoaderClientWx::dispatchCreatePage() 752 { 753 notImplemented(); 754 return false; 755 } 756 757 void FrameLoaderClientWx::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimetype, const ResourceRequest& request) 758 { 759 if (!m_webFrame) 760 return; 761 762 notImplemented(); 763 (m_frame->loader()->policyChecker()->*function)(PolicyUse); 764 } 765 766 void FrameLoaderClientWx::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest& request, PassRefPtr<FormState>, const String& targetName) 767 { 768 if (!m_webFrame) 769 return; 770 771 if (m_webView) { 772 wxWebViewNewWindowEvent wkEvent(m_webView); 773 wkEvent.SetURL(request.url().string()); 774 wkEvent.SetTargetName(targetName); 775 if (m_webView->GetEventHandler()->ProcessEvent(wkEvent)) { 776 // if the app handles and doesn't skip the event, 777 // from WebKit's perspective treat it as blocked / ignored 778 (m_frame->loader()->policyChecker()->*function)(PolicyIgnore); 779 return; 780 } 781 } 782 783 (m_frame->loader()->policyChecker()->*function)(PolicyUse); 784 } 785 786 void FrameLoaderClientWx::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState>) 787 { 788 if (!m_webFrame) 789 return; 790 791 if (m_webView) { 792 wxWebViewBeforeLoadEvent wkEvent(m_webView); 793 wkEvent.SetNavigationType(wxNavTypeFromWebNavType(action.type())); 794 wkEvent.SetURL(request.url().string()); 795 796 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 797 if (wkEvent.IsCancelled()) 798 (m_frame->loader()->policyChecker()->*function)(PolicyIgnore); 799 else 800 (m_frame->loader()->policyChecker()->*function)(PolicyUse); 801 802 } 803 } 804 805 void FrameLoaderClientWx::dispatchUnableToImplementPolicy(const ResourceError&) 806 { 807 notImplemented(); 808 } 809 810 void FrameLoaderClientWx::startDownload(const ResourceRequest&) 811 { 812 notImplemented(); 813 } 814 815 PassRefPtr<Frame> FrameLoaderClientWx::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, 816 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) 817 { 818 WebViewFrameData* data = new WebViewFrameData(); 819 data->name = name; 820 data->ownerElement = ownerElement; 821 data->url = url; 822 data->referrer = referrer; 823 data->allowsScrolling = allowsScrolling; 824 data->marginWidth = marginWidth; 825 data->marginHeight = marginHeight; 826 827 wxWebFrame* newFrame = new wxWebFrame(m_webView, m_webFrame, data); 828 829 RefPtr<Frame> childFrame = adoptRef(newFrame->m_impl->frame); 830 831 // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. 832 if (!childFrame->page()) 833 return 0; 834 835 childFrame->loader()->loadURLIntoChildFrame(url, referrer, childFrame.get()); 836 837 // The frame's onload handler may have removed it from the document. 838 if (!childFrame->tree()->parent()) 839 return 0; 840 841 return childFrame.release(); 842 } 843 844 ObjectContentType FrameLoaderClientWx::objectContentType(const KURL& url, const String& mimeType) 845 { 846 notImplemented(); 847 return ObjectContentType(); 848 } 849 850 PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) 851 { 852 #if __WXMSW__ || __WXMAC__ 853 RefPtr<PluginView> pv = PluginView::create(m_frame, size, element, url, paramNames, paramValues, mimeType, loadManually); 854 if (pv->status() == PluginStatusLoadedSuccessfully) 855 return pv; 856 #endif 857 return 0; 858 } 859 860 void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget) 861 { 862 ASSERT(!m_pluginView); 863 m_pluginView = static_cast<PluginView*>(pluginWidget); 864 m_hasSentResponseToPlugin = false; 865 } 866 867 ResourceError FrameLoaderClientWx::pluginWillHandleLoadError(const ResourceResponse& response) 868 { 869 notImplemented(); 870 return ResourceError(String(), WebKitErrorCannotLoadPlugIn, response.url().string(), String()); 871 } 872 873 PassRefPtr<Widget> FrameLoaderClientWx::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, 874 const Vector<String>& paramNames, const Vector<String>& paramValues) 875 { 876 notImplemented(); 877 return 0; 878 } 879 880 String FrameLoaderClientWx::overrideMediaType() const 881 { 882 notImplemented(); 883 return String(); 884 } 885 886 void FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) 887 { 888 if (world != mainThreadNormalWorld()) 889 return; 890 891 if (m_webView) { 892 wxWebViewWindowObjectClearedEvent wkEvent(m_webView); 893 Frame* coreFrame = m_webView->GetMainFrame()->GetFrame(); 894 JSGlobalContextRef context = toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()); 895 JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld())); 896 wkEvent.SetJSContext(context); 897 wkEvent.SetWindowObject(windowObject); 898 m_webView->GetEventHandler()->ProcessEvent(wkEvent); 899 } 900 } 901 902 void FrameLoaderClientWx::documentElementAvailable() 903 { 904 } 905 906 void FrameLoaderClientWx::didPerformFirstNavigation() const 907 { 908 notImplemented(); 909 } 910 911 void FrameLoaderClientWx::registerForIconNotification(bool listen) 912 { 913 notImplemented(); 914 } 915 916 void FrameLoaderClientWx::savePlatformDataToCachedFrame(CachedFrame*) 917 { 918 notImplemented(); 919 } 920 921 void FrameLoaderClientWx::transitionToCommittedFromCachedFrame(CachedFrame*) 922 { 923 notImplemented(); 924 } 925 926 void FrameLoaderClientWx::transitionToCommittedForNewPage() 927 { 928 ASSERT(m_webFrame); 929 ASSERT(m_frame); 930 ASSERT(m_webView); 931 932 IntSize size = IntRect(m_webView->GetRect()).size(); 933 // FIXME: This value should be gotten from m_webView->IsTransparent(); 934 // but transitionToCommittedForNewPage() can be called while m_webView is 935 // still being initialized. 936 bool transparent = false; 937 Color backgroundColor = transparent ? WebCore::Color::transparent : WebCore::Color::white; 938 939 if (m_frame) 940 m_frame->createView(size, backgroundColor, transparent, IntSize(), false); 941 } 942 943 bool FrameLoaderClientWx::shouldUsePluginDocument(const String &mimeType) const 944 { 945 // NOTE: Plugin Documents are used for viewing PDFs, etc. inline, and should 946 // not be used for pages with plugins in them. 947 return false; 948 } 949 950 } 951