1 /* 2 * Copyright (C) 2006 Zack Rusin <zack (at) kde.org> 3 * Copyright (C) 2006, 2011 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 5 * Copyright (C) 2008 Collabora Ltd. All rights reserved. 6 * Copyright (C) 2008 Holger Hans Peter Freyther 7 * Copyright (C) 2008 Kenneth Rohde Christiansen 8 * Copyright (C) 2009-2010 ProFUSION embedded systems 9 * Copyright (C) 2009-2010 Samsung Electronics 10 * 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 30 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include "config.h" 36 #include "FrameLoaderClientEfl.h" 37 38 #include "DocumentLoader.h" 39 #include "EWebKit.h" 40 #include "FormState.h" 41 #include "FrameLoader.h" 42 #include "FrameNetworkingContextEfl.h" 43 #include "FrameTree.h" 44 #include "FrameView.h" 45 #include "HTMLFormElement.h" 46 #include "MIMETypeRegistry.h" 47 #include "NotImplemented.h" 48 #include "Page.h" 49 #include "PluginDatabase.h" 50 #include "ProgressTracker.h" 51 #include "RenderPart.h" 52 #include "ResourceRequest.h" 53 #include "WebKitVersion.h" 54 #include "ewk_private.h" 55 #include <wtf/text/CString.h> 56 #include <wtf/text/StringConcatenate.h> 57 58 #if OS(UNIX) 59 #include <sys/utsname.h> 60 #elif OS(WINDOWS) 61 #include "SystemInfo.h" 62 #endif 63 64 #include <Ecore_Evas.h> 65 66 using namespace WebCore; 67 68 namespace WebCore { 69 70 FrameLoaderClientEfl::FrameLoaderClientEfl(Evas_Object *view) 71 : m_view(view) 72 , m_frame(0) 73 , m_userAgent("") 74 , m_customUserAgent("") 75 , m_pluginView(0) 76 , m_hasSentResponseToPlugin(false) 77 { 78 } 79 80 static String agentOS() 81 { 82 #if OS(DARWIN) 83 #if CPU(X86) 84 return "Intel Mac OS X"; 85 #else 86 return "PPC Mac OS X"; 87 #endif 88 #elif OS(UNIX) 89 struct utsname name; 90 if (uname(&name) != -1) 91 return makeString(name.sysname, ' ', name.machine); 92 93 return "Unknown"; 94 #elif OS(WINDOWS) 95 return windowsVersionForUAString(); 96 #else 97 notImplemented(); 98 return "Unknown"; 99 #endif 100 } 101 102 static String composeUserAgent() 103 { 104 String webKitVersion = String::format("%d.%d", WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION); 105 return makeString("Mozilla/5.0 (", agentOS(), ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) Safari/", webKitVersion); 106 } 107 108 void FrameLoaderClientEfl::setCustomUserAgent(const String &agent) 109 { 110 m_customUserAgent = agent; 111 } 112 113 const String& FrameLoaderClientEfl::customUserAgent() const 114 { 115 return m_customUserAgent; 116 } 117 118 String FrameLoaderClientEfl::userAgent(const KURL&) 119 { 120 if (!m_customUserAgent.isEmpty()) 121 return m_customUserAgent; 122 123 if (m_userAgent.isEmpty()) 124 m_userAgent = composeUserAgent(); 125 return m_userAgent; 126 } 127 128 void FrameLoaderClientEfl::callPolicyFunction(FramePolicyFunction function, PolicyAction action) 129 { 130 Frame* f = ewk_frame_core_get(m_frame); 131 ASSERT(f); 132 (f->loader()->policyChecker()->*function)(action); 133 } 134 135 WTF::PassRefPtr<DocumentLoader> FrameLoaderClientEfl::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) 136 { 137 RefPtr<DocumentLoader> loader = DocumentLoader::create(request, substituteData); 138 if (substituteData.isValid()) 139 loader->setDeferMainResourceDataLoad(false); 140 return loader.release(); 141 } 142 143 void FrameLoaderClientEfl::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState>) 144 { 145 // FIXME: This is surely too simple 146 ASSERT(function); 147 callPolicyFunction(function, PolicyUse); 148 } 149 150 void FrameLoaderClientEfl::committedLoad(DocumentLoader* loader, const char* data, int length) 151 { 152 if (!m_pluginView) 153 loader->commitData(data, length); 154 155 // We re-check here as the plugin can have been created 156 if (m_pluginView) { 157 if (!m_hasSentResponseToPlugin) { 158 m_pluginView->didReceiveResponse(loader->response()); 159 m_hasSentResponseToPlugin = true; 160 } 161 m_pluginView->didReceiveData(data, length); 162 } 163 } 164 165 void FrameLoaderClientEfl::dispatchDidReplaceStateWithinPage() 166 { 167 notImplemented(); 168 } 169 170 void FrameLoaderClientEfl::dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const 171 { 172 notImplemented(); 173 } 174 175 void FrameLoaderClientEfl::dispatchDidPushStateWithinPage() 176 { 177 notImplemented(); 178 } 179 180 void FrameLoaderClientEfl::dispatchDidPopStateWithinPage() 181 { 182 notImplemented(); 183 } 184 185 void FrameLoaderClientEfl::dispatchDidChangeBackForwardIndex() const 186 { 187 notImplemented(); 188 } 189 190 void FrameLoaderClientEfl::dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const 191 { 192 notImplemented(); 193 } 194 195 void FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) 196 { 197 notImplemented(); 198 } 199 200 void FrameLoaderClientEfl::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) 201 { 202 notImplemented(); 203 } 204 205 void FrameLoaderClientEfl::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) 206 { 207 notImplemented(); 208 } 209 210 void FrameLoaderClientEfl::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& coreRequest, const ResourceResponse& coreResponse) 211 { 212 CString url = coreRequest.url().string().utf8(); 213 DBG("Resource url=%s", url.data()); 214 215 Ewk_Frame_Resource_Request request = { 0, identifier }; 216 Ewk_Frame_Resource_Request orig = request; /* Initialize const fields. */ 217 218 orig.url = request.url = url.data(); 219 220 ewk_frame_request_will_send(m_frame, &request); 221 222 if (request.url != orig.url) { 223 coreRequest.setURL(KURL(KURL(), request.url)); 224 225 // Calling client might have changed our url pointer. 226 // Free the new allocated string. 227 free(const_cast<char*>(request.url)); 228 } 229 } 230 231 bool FrameLoaderClientEfl::shouldUseCredentialStorage(DocumentLoader*, unsigned long) 232 { 233 notImplemented(); 234 return false; 235 } 236 237 void FrameLoaderClientEfl::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest& coreRequest) 238 { 239 CString url = coreRequest.url().string().utf8(); 240 DBG("Resource url=%s", url.data()); 241 242 Ewk_Frame_Resource_Request request = { 0, identifier }; 243 ewk_frame_request_assign_identifier(m_frame, &request); 244 } 245 246 void FrameLoaderClientEfl::postProgressStartedNotification() 247 { 248 ewk_frame_load_started(m_frame); 249 postProgressEstimateChangedNotification(); 250 } 251 252 void FrameLoaderClientEfl::postProgressEstimateChangedNotification() 253 { 254 ewk_frame_load_progress_changed(m_frame); 255 } 256 257 void FrameLoaderClientEfl::postProgressFinishedNotification() 258 { 259 if (m_loadError.isNull()) 260 ewk_frame_load_finished(m_frame, 0, 0, 0, 0, 0); 261 else { 262 ewk_frame_load_finished(m_frame, 263 m_loadError.domain().utf8().data(), 264 m_loadError.errorCode(), 265 m_loadError.isCancellation(), 266 m_loadError.localizedDescription().utf8().data(), 267 m_loadError.failingURL().utf8().data()); 268 } 269 } 270 271 void FrameLoaderClientEfl::frameLoaderDestroyed() 272 { 273 if (m_frame) 274 ewk_frame_core_gone(m_frame); 275 m_frame = 0; 276 277 delete this; 278 } 279 280 void FrameLoaderClientEfl::dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse& response) 281 { 282 m_response = response; 283 } 284 285 void FrameLoaderClientEfl::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest&) 286 { 287 // we need to call directly here (currently callPolicyFunction does that!) 288 ASSERT(function); 289 if (canShowMIMEType(response.mimeType())) 290 callPolicyFunction(function, PolicyUse); 291 else 292 callPolicyFunction(function, PolicyDownload); 293 } 294 295 void FrameLoaderClientEfl::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest&, PassRefPtr<FormState>, const String&) 296 { 297 ASSERT(function); 298 ASSERT(m_frame); 299 // if not acceptNavigationRequest - look at Qt -> PolicyIgnore; 300 // FIXME: do proper check and only reset forms when on PolicyIgnore 301 Frame* f = ewk_frame_core_get(m_frame); 302 f->loader()->resetMultipleFormSubmissionProtection(); 303 callPolicyFunction(function, PolicyUse); 304 } 305 306 void FrameLoaderClientEfl::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>) 307 { 308 ASSERT(function); 309 ASSERT(m_frame); 310 // if not acceptNavigationRequest - look at Qt -> PolicyIgnore; 311 // FIXME: do proper check and only reset forms when on PolicyIgnore 312 char* url = strdup(resourceRequest.url().string().utf8().data()); 313 Ewk_Frame_Resource_Request request = { url, 0 }; 314 Eina_Bool ret = ewk_view_navigation_policy_decision(m_view, &request); 315 free(url); 316 317 PolicyAction policy; 318 if (!ret) 319 policy = PolicyIgnore; 320 else { 321 if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted) { 322 Frame* f = ewk_frame_core_get(m_frame); 323 f->loader()->resetMultipleFormSubmissionProtection(); 324 } 325 policy = PolicyUse; 326 } 327 callPolicyFunction(function, policy); 328 } 329 330 PassRefPtr<Widget> FrameLoaderClientEfl::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) 331 { 332 ASSERT(m_frame); 333 ASSERT(m_view); 334 335 return ewk_view_plugin_create(m_view, m_frame, pluginSize, 336 element, url, paramNames, paramValues, 337 mimeType, loadManually); 338 } 339 340 PassRefPtr<Frame> FrameLoaderClientEfl::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) 341 { 342 ASSERT(m_frame); 343 ASSERT(m_view); 344 345 return ewk_view_frame_create(m_view, m_frame, name, ownerElement, url, referrer); 346 } 347 348 void FrameLoaderClientEfl::didTransferChildFrameToNewDocument(Page*) 349 { 350 } 351 352 void FrameLoaderClientEfl::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*) 353 { 354 } 355 356 void FrameLoaderClientEfl::redirectDataToPlugin(Widget* pluginWidget) 357 { 358 ASSERT(!m_pluginView); 359 m_pluginView = static_cast<PluginView*>(pluginWidget); 360 m_hasSentResponseToPlugin = false; 361 } 362 363 PassRefPtr<Widget> FrameLoaderClientEfl::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, 364 const Vector<String>& paramNames, const Vector<String>& paramValues) 365 { 366 notImplemented(); 367 return 0; 368 } 369 370 ObjectContentType FrameLoaderClientEfl::objectContentType(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages) 371 { 372 // FIXME: once plugin support is enabled, this method needs to correctly handle the 'shouldPreferPlugInsForImages' flag. See 373 // WebCore::FrameLoader::defaultObjectContentType() for an example. 374 UNUSED_PARAM(shouldPreferPlugInsForImages); 375 376 if (url.isEmpty() && mimeType.isEmpty()) 377 return ObjectContentNone; 378 379 // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure 380 String type = mimeType; 381 if (type.isEmpty()) 382 type = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); 383 384 if (type.isEmpty()) 385 return ObjectContentFrame; 386 387 if (MIMETypeRegistry::isSupportedImageMIMEType(type)) 388 return ObjectContentImage; 389 390 #if 0 // PluginDatabase is disabled until we have Plugin system done. 391 if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) 392 return ObjectContentNetscapePlugin; 393 #endif 394 395 if (MIMETypeRegistry::isSupportedNonImageMIMEType(type)) 396 return ObjectContentFrame; 397 398 if (url.protocol() == "about") 399 return ObjectContentFrame; 400 401 return ObjectContentNone; 402 } 403 404 String FrameLoaderClientEfl::overrideMediaType() const 405 { 406 notImplemented(); 407 return String(); 408 } 409 410 void FrameLoaderClientEfl::windowObjectCleared() 411 { 412 notImplemented(); 413 } 414 415 void FrameLoaderClientEfl::documentElementAvailable() 416 { 417 return; 418 } 419 420 void FrameLoaderClientEfl::didPerformFirstNavigation() const 421 { 422 ewk_frame_did_perform_first_navigation(m_frame); 423 } 424 425 void FrameLoaderClientEfl::registerForIconNotification(bool) 426 { 427 notImplemented(); 428 } 429 430 void FrameLoaderClientEfl::setMainFrameDocumentReady(bool) 431 { 432 // this is only interesting once we provide an external API for the DOM 433 } 434 435 bool FrameLoaderClientEfl::hasWebView() const 436 { 437 // notImplemented(); 438 return true; 439 } 440 441 bool FrameLoaderClientEfl::hasFrameView() const 442 { 443 notImplemented(); 444 return true; 445 } 446 447 void FrameLoaderClientEfl::dispatchDidFinishLoad() 448 { 449 m_loadError = ResourceError(); /* clears previous error */ 450 } 451 452 void FrameLoaderClientEfl::frameLoadCompleted() 453 { 454 // Note: Can be called multiple times. 455 } 456 457 void FrameLoaderClientEfl::saveViewStateToItem(HistoryItem* item) 458 { 459 ewk_frame_view_state_save(m_frame, item); 460 } 461 462 void FrameLoaderClientEfl::restoreViewState() 463 { 464 ASSERT(m_frame); 465 ASSERT(m_view); 466 467 ewk_view_restore_state(m_view, m_frame); 468 } 469 470 void FrameLoaderClientEfl::updateGlobalHistoryRedirectLinks() 471 { 472 } 473 474 bool FrameLoaderClientEfl::shouldGoToHistoryItem(HistoryItem* item) const 475 { 476 // FIXME: This is a very simple implementation. More sophisticated 477 // implementation would delegate the decision to a PolicyDelegate. 478 // See mac implementation for example. 479 return item; 480 } 481 482 bool FrameLoaderClientEfl::shouldStopLoadingForHistoryItem(HistoryItem* item) const 483 { 484 return true; 485 } 486 487 void FrameLoaderClientEfl::didDisplayInsecureContent() 488 { 489 notImplemented(); 490 } 491 492 void FrameLoaderClientEfl::didRunInsecureContent(SecurityOrigin*, const KURL&) 493 { 494 notImplemented(); 495 } 496 497 void FrameLoaderClientEfl::makeRepresentation(DocumentLoader*) 498 { 499 notImplemented(); 500 } 501 502 void FrameLoaderClientEfl::forceLayout() 503 { 504 ewk_frame_force_layout(m_frame); 505 } 506 507 void FrameLoaderClientEfl::forceLayoutForNonHTML() 508 { 509 } 510 511 void FrameLoaderClientEfl::setCopiesOnScroll() 512 { 513 // apparently mac specific (Qt comment) 514 } 515 516 void FrameLoaderClientEfl::detachedFromParent2() 517 { 518 } 519 520 void FrameLoaderClientEfl::detachedFromParent3() 521 { 522 } 523 524 void FrameLoaderClientEfl::loadedFromCachedPage() 525 { 526 notImplemented(); 527 } 528 529 void FrameLoaderClientEfl::dispatchDidHandleOnloadEvents() 530 { 531 notImplemented(); 532 } 533 534 void FrameLoaderClientEfl::dispatchDidReceiveServerRedirectForProvisionalLoad() 535 { 536 notImplemented(); 537 } 538 539 void FrameLoaderClientEfl::dispatchDidCancelClientRedirect() 540 { 541 notImplemented(); 542 } 543 544 void FrameLoaderClientEfl::dispatchWillPerformClientRedirect(const KURL&, double, double) 545 { 546 notImplemented(); 547 } 548 549 void FrameLoaderClientEfl::dispatchDidChangeLocationWithinPage() 550 { 551 ewk_frame_uri_changed(m_frame); 552 553 if (ewk_view_frame_main_get(m_view) != m_frame) 554 return; 555 ewk_view_uri_changed(m_view); 556 } 557 558 void FrameLoaderClientEfl::dispatchWillClose() 559 { 560 notImplemented(); 561 } 562 563 void FrameLoaderClientEfl::dispatchDidReceiveIcon() 564 { 565 /* report received favicon only for main frame. */ 566 if (ewk_view_frame_main_get(m_view) != m_frame) 567 return; 568 569 ewk_view_frame_main_icon_received(m_view); 570 } 571 572 void FrameLoaderClientEfl::dispatchDidStartProvisionalLoad() 573 { 574 ewk_frame_load_provisional(m_frame); 575 if (ewk_view_frame_main_get(m_view) == m_frame) 576 ewk_view_load_provisional(m_view); 577 } 578 579 void FrameLoaderClientEfl::dispatchDidReceiveTitle(const StringWithDirection& title) 580 { 581 // FIXME: use direction of title. 582 CString cs = title.string().utf8(); 583 ewk_frame_title_set(m_frame, cs.data()); 584 585 if (ewk_view_frame_main_get(m_view) != m_frame) 586 return; 587 ewk_view_title_set(m_view, cs.data()); 588 } 589 590 void FrameLoaderClientEfl::dispatchDidChangeIcons() 591 { 592 notImplemented(); 593 } 594 595 void FrameLoaderClientEfl::dispatchDidCommitLoad() 596 { 597 ewk_frame_uri_changed(m_frame); 598 if (ewk_view_frame_main_get(m_view) != m_frame) 599 return; 600 ewk_view_title_set(m_view, 0); 601 ewk_view_uri_changed(m_view); 602 } 603 604 void FrameLoaderClientEfl::dispatchDidFinishDocumentLoad() 605 { 606 ewk_frame_load_document_finished(m_frame); 607 } 608 609 void FrameLoaderClientEfl::dispatchDidFirstLayout() 610 { 611 ewk_frame_load_firstlayout_finished(m_frame); 612 } 613 614 void FrameLoaderClientEfl::dispatchDidFirstVisuallyNonEmptyLayout() 615 { 616 ewk_frame_load_firstlayout_nonempty_finished(m_frame); 617 } 618 619 void FrameLoaderClientEfl::dispatchShow() 620 { 621 ewk_view_load_show(m_view); 622 } 623 624 void FrameLoaderClientEfl::cancelPolicyCheck() 625 { 626 notImplemented(); 627 } 628 629 void FrameLoaderClientEfl::dispatchDidLoadMainResource(DocumentLoader*) 630 { 631 notImplemented(); 632 } 633 634 void FrameLoaderClientEfl::revertToProvisionalState(DocumentLoader*) 635 { 636 notImplemented(); 637 } 638 639 void FrameLoaderClientEfl::willChangeTitle(DocumentLoader*) 640 { 641 // no need for, dispatchDidReceiveTitle is the right callback 642 } 643 644 void FrameLoaderClientEfl::didChangeTitle(DocumentLoader *l) 645 { 646 // no need for, dispatchDidReceiveTitle is the right callback 647 } 648 649 bool FrameLoaderClientEfl::canHandleRequest(const ResourceRequest&) const 650 { 651 notImplemented(); 652 return true; 653 } 654 655 bool FrameLoaderClientEfl::canShowMIMETypeAsHTML(const String& MIMEType) const 656 { 657 notImplemented(); 658 return false; 659 } 660 661 bool FrameLoaderClientEfl::canShowMIMEType(const String& MIMEType) const 662 { 663 if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType)) 664 return true; 665 666 if (MIMETypeRegistry::isSupportedNonImageMIMEType(MIMEType)) 667 return true; 668 669 #if 0 // PluginDatabase is disabled until we have Plugin system done. 670 if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(MIMEType)) 671 return true; 672 #endif 673 674 return false; 675 } 676 677 bool FrameLoaderClientEfl::representationExistsForURLScheme(const String&) const 678 { 679 return false; 680 } 681 682 String FrameLoaderClientEfl::generatedMIMETypeForURLScheme(const String&) const 683 { 684 notImplemented(); 685 return String(); 686 } 687 688 void FrameLoaderClientEfl::finishedLoading(DocumentLoader* loader) 689 { 690 if (!m_pluginView) 691 return; 692 m_pluginView->didFinishLoading(); 693 m_pluginView = 0; 694 m_hasSentResponseToPlugin = false; 695 } 696 697 698 void FrameLoaderClientEfl::provisionalLoadStarted() 699 { 700 notImplemented(); 701 } 702 703 void FrameLoaderClientEfl::didFinishLoad() 704 { 705 notImplemented(); 706 } 707 708 void FrameLoaderClientEfl::prepareForDataSourceReplacement() 709 { 710 notImplemented(); 711 } 712 713 void FrameLoaderClientEfl::setTitle(const StringWithDirection& title, const KURL& url) 714 { 715 // no need for, dispatchDidReceiveTitle is the right callback 716 } 717 718 void FrameLoaderClientEfl::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength) 719 { 720 notImplemented(); 721 } 722 723 void FrameLoaderClientEfl::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) 724 { 725 notImplemented(); 726 } 727 728 void FrameLoaderClientEfl::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const ResourceError& err) 729 { 730 notImplemented(); 731 } 732 733 bool FrameLoaderClientEfl::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) 734 { 735 notImplemented(); 736 return false; 737 } 738 739 void FrameLoaderClientEfl::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const String&) 740 { 741 notImplemented(); 742 } 743 744 void FrameLoaderClientEfl::dispatchDidFailProvisionalLoad(const ResourceError& err) 745 { 746 dispatchDidFailLoad(err); 747 } 748 749 void FrameLoaderClientEfl::dispatchDidFailLoad(const ResourceError& err) 750 { 751 if (!shouldFallBack(err)) 752 return; 753 754 m_loadError = err; 755 ewk_frame_load_error(m_frame, 756 m_loadError.domain().utf8().data(), 757 m_loadError.errorCode(), m_loadError.isCancellation(), 758 m_loadError.localizedDescription().utf8().data(), 759 m_loadError.failingURL().utf8().data()); 760 } 761 762 void FrameLoaderClientEfl::download(ResourceHandle*, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse&) 763 { 764 if (!m_view) 765 return; 766 767 CString url = request.url().string().utf8(); 768 Ewk_Download download; 769 770 download.url = url.data(); 771 ewk_view_download_request(m_view, &download); 772 } 773 774 // copied from WebKit/Misc/WebKitErrors[Private].h 775 enum { 776 WebKitErrorCannotShowMIMEType = 100, 777 WebKitErrorCannotShowURL = 101, 778 WebKitErrorFrameLoadInterruptedByPolicyChange = 102, 779 WebKitErrorCannotUseRestrictedPort = 103, 780 WebKitErrorCannotFindPlugIn = 200, 781 WebKitErrorCannotLoadPlugIn = 201, 782 WebKitErrorJavaUnavailable = 202, 783 }; 784 785 ResourceError FrameLoaderClientEfl::cancelledError(const ResourceRequest& request) 786 { 787 ResourceError error("Error", -999, request.url().string(), 788 "Request cancelled"); 789 error.setIsCancellation(true); 790 return error; 791 } 792 793 ResourceError FrameLoaderClientEfl::blockedError(const ResourceRequest& request) 794 { 795 return ResourceError("Error", WebKitErrorCannotUseRestrictedPort, request.url().string(), 796 "Request blocked"); 797 } 798 799 ResourceError FrameLoaderClientEfl::cannotShowURLError(const ResourceRequest& request) 800 { 801 return ResourceError("Error", WebKitErrorCannotShowURL, request.url().string(), 802 "Cannot show URL"); 803 } 804 805 ResourceError FrameLoaderClientEfl::interruptForPolicyChangeError(const ResourceRequest& request) 806 { 807 return ResourceError("Error", WebKitErrorFrameLoadInterruptedByPolicyChange, 808 request.url().string(), "Frame load interrupted by policy change"); 809 } 810 811 ResourceError FrameLoaderClientEfl::cannotShowMIMETypeError(const ResourceResponse& response) 812 { 813 return ResourceError("Error", WebKitErrorCannotShowMIMEType, response.url().string(), 814 "Cannot show mimetype"); 815 } 816 817 ResourceError FrameLoaderClientEfl::fileDoesNotExistError(const ResourceResponse& response) 818 { 819 return ResourceError("Error", -998 /* ### */, response.url().string(), 820 "File does not exist"); 821 } 822 823 ResourceError FrameLoaderClientEfl::pluginWillHandleLoadError(const ResourceResponse&) 824 { 825 notImplemented(); 826 return ResourceError("Error", 0, "", ""); 827 } 828 829 bool FrameLoaderClientEfl::shouldFallBack(const ResourceError& error) 830 { 831 return !(error.isCancellation() || (error.errorCode() == WebKitErrorFrameLoadInterruptedByPolicyChange)); 832 } 833 834 bool FrameLoaderClientEfl::canCachePage() const 835 { 836 return false; 837 } 838 839 Frame* FrameLoaderClientEfl::dispatchCreatePage(const NavigationAction&) 840 { 841 if (!m_view) 842 return 0; 843 844 Evas_Object* newView = ewk_view_window_create(m_view, EINA_FALSE, 0); 845 Evas_Object* mainFrame; 846 if (!newView) 847 mainFrame = m_frame; 848 else 849 mainFrame = ewk_view_frame_main_get(newView); 850 851 return ewk_frame_core_get(mainFrame); 852 } 853 854 void FrameLoaderClientEfl::dispatchUnableToImplementPolicy(const ResourceError&) 855 { 856 notImplemented(); 857 } 858 859 void FrameLoaderClientEfl::setMainDocumentError(DocumentLoader* loader, const ResourceError& error) 860 { 861 if (!m_pluginView) 862 return; 863 m_pluginView->didFail(error); 864 m_pluginView = 0; 865 m_hasSentResponseToPlugin = false; 866 } 867 868 void FrameLoaderClientEfl::startDownload(const ResourceRequest&) 869 { 870 notImplemented(); 871 } 872 873 void FrameLoaderClientEfl::updateGlobalHistory() 874 { 875 notImplemented(); 876 } 877 878 void FrameLoaderClientEfl::savePlatformDataToCachedFrame(CachedFrame*) 879 { 880 notImplemented(); 881 } 882 883 void FrameLoaderClientEfl::transitionToCommittedFromCachedFrame(CachedFrame*) 884 { 885 } 886 887 void FrameLoaderClientEfl::transitionToCommittedForNewPage() 888 { 889 ASSERT(m_frame); 890 ASSERT(m_view); 891 892 ewk_frame_view_create_for_view(m_frame, m_view); 893 894 if (m_frame == ewk_view_frame_main_get(m_view)) 895 ewk_view_frame_main_cleared(m_view); 896 } 897 898 void FrameLoaderClientEfl::didSaveToPageCache() 899 { 900 } 901 902 void FrameLoaderClientEfl::didRestoreFromPageCache() 903 { 904 } 905 906 void FrameLoaderClientEfl::dispatchDidBecomeFrameset(bool) 907 { 908 } 909 910 PassRefPtr<FrameNetworkingContext> FrameLoaderClientEfl::createNetworkingContext() 911 { 912 return FrameNetworkingContextEfl::create(ewk_frame_core_get(m_frame)); 913 } 914 915 } 916