1/* 2 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 3 * Copyright (C) 2011 Apple Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "FrameLoaderClientWinCE.h" 28 29#include "DocumentLoader.h" 30#include "FrameLoader.h" 31#include "FrameNetworkingContextWinCE.h" 32#include "FrameView.h" 33#include "HTMLFormElement.h" 34#include "MIMETypeRegistry.h" 35#include "MainFrame.h" 36#include "NotImplemented.h" 37#include "Page.h" 38#include "PluginDatabase.h" 39#include "PolicyChecker.h" 40#include "RenderWidget.h" 41#include "SystemInfo.h" 42#include "WebKitVersion.h" 43#include "WebView.h" 44#include <wtf/text/StringConcatenate.h> 45 46using namespace WebCore; 47 48namespace WebKit { 49 50FrameLoaderClientWinCE::FrameLoaderClientWinCE(WebView* view) 51 : m_webView(view) 52 , m_pluginView(0) 53{ 54 ASSERT(m_webView); 55} 56 57FrameLoaderClientWinCE::~FrameLoaderClientWinCE() 58{ 59} 60 61String FrameLoaderClientWinCE::userAgent(const URL&) 62{ 63 DEPRECATED_DEFINE_STATIC_LOCAL(String, userAgentString, ()); 64 65 if (userAgentString.isNull()) { 66 String webKitVersion = String::format("%d.%d", WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION); 67 userAgentString = makeString("Mozilla/5.0 (", windowsVersionForUAString(), ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) Mobile Safari/", webKitVersion); 68 } 69 70 return userAgentString; 71} 72 73PassRefPtr<DocumentLoader> FrameLoaderClientWinCE::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData) 74{ 75 return DocumentLoader::create(request, substituteData); 76} 77 78void FrameLoaderClientWinCE::committedLoad(DocumentLoader* loader, const char* data, int length) 79{ 80 if (m_pluginView) { 81 if (!m_hasSentResponseToPlugin) { 82 m_pluginView->didReceiveResponse(loader->response()); 83 m_hasSentResponseToPlugin = true; 84 } 85 m_pluginView->didReceiveData(data, length); 86 } else 87 loader->commitData(data, length); 88} 89 90bool FrameLoaderClientWinCE::shouldUseCredentialStorage(DocumentLoader*, unsigned long) 91{ 92 notImplemented(); 93 return false; 94} 95 96void FrameLoaderClientWinCE::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) 97{ 98 notImplemented(); 99} 100 101void FrameLoaderClientWinCE::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) 102{ 103 notImplemented(); 104} 105 106void FrameLoaderClientWinCE::dispatchWillSendRequest(DocumentLoader*, unsigned long, WebCore::ResourceRequest&, const WebCore::ResourceResponse&) 107{ 108 notImplemented(); 109} 110 111void FrameLoaderClientWinCE::assignIdentifierToInitialRequest(unsigned long, DocumentLoader*, const WebCore::ResourceRequest&) 112{ 113 notImplemented(); 114} 115 116void FrameLoaderClientWinCE::postProgressStartedNotification() 117{ 118 notImplemented(); 119} 120 121void FrameLoaderClientWinCE::postProgressEstimateChangedNotification() 122{ 123 notImplemented(); 124} 125 126void FrameLoaderClientWinCE::postProgressFinishedNotification() 127{ 128 notImplemented(); 129} 130 131void FrameLoaderClientWinCE::frameLoaderDestroyed() 132{ 133 m_webView = 0; 134 m_frame = 0; 135 delete this; 136} 137 138void FrameLoaderClientWinCE::dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse& response) 139{ 140 m_response = response; 141} 142 143void FrameLoaderClientWinCE::dispatchDecidePolicyForResponse(const WebCore::ResourceResponse& response, const WebCore::ResourceRequest&, FramePolicyFunction policyFunction) 144{ 145 if (canShowMIMEType(response.mimeType())) 146 policyFunction(PolicyUse); 147 else 148 policyFunction(PolicyDownload); 149} 150 151void FrameLoaderClientWinCE::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const String&, FramePolicyFunction policyFunction) 152{ 153 policyFunction(PolicyUse); 154} 155 156void FrameLoaderClientWinCE::dispatchDecidePolicyForNavigationAction(const NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, FramePolicyFunction policyFunction) 157{ 158 policyFunction(PolicyUse); 159} 160 161void FrameLoaderClientWinCE::dispatchWillSubmitForm(PassRefPtr<FormState>, FramePolicyFunction policyFunction) 162{ 163 policyFunction(PolicyUse); 164} 165 166PassRefPtr<Widget> FrameLoaderClientWinCE::createPlugin(const IntSize&, HTMLPlugInElement*, const URL&, const Vector<String>&, const Vector<String>&, const String&, bool) 167{ 168 return 0; 169} 170 171PassRefPtr<Frame> FrameLoaderClientWinCE::createFrame(const URL& url, const String& name, HTMLFrameOwnerElement* ownerElement, 172 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) 173{ 174 return m_webView->createFrame(url, name, ownerElement, referrer, allowsScrolling, marginWidth, marginHeight, m_frame); 175} 176 177void FrameLoaderClientWinCE::redirectDataToPlugin(Widget* pluginWidget) 178{ 179 m_pluginView = toPluginView(pluginWidget); 180 if (pluginWidget) 181 m_hasSentResponseToPlugin = false; 182} 183 184PassRefPtr<Widget> FrameLoaderClientWinCE::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const URL&, const Vector<String>&, const Vector<String>&) 185{ 186 notImplemented(); 187 return 0; 188} 189 190ObjectContentType FrameLoaderClientWinCE::objectContentType(const URL& url, const String& mimeType, bool shouldPreferPlugInsForImages) 191{ 192 return FrameLoader::defaultObjectContentType(url, mimeType, shouldPreferPlugInsForImages); 193} 194 195String FrameLoaderClientWinCE::overrideMediaType() const 196{ 197 notImplemented(); 198 return String(); 199} 200 201void FrameLoaderClientWinCE::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) 202{ 203 notImplemented(); 204} 205 206void FrameLoaderClientWinCE::registerForIconNotification(bool) 207{ 208 notImplemented(); 209} 210 211void FrameLoaderClientWinCE::setMainFrameDocumentReady(bool) 212{ 213 notImplemented(); 214} 215 216bool FrameLoaderClientWinCE::hasWebView() const 217{ 218 return true; 219} 220 221void FrameLoaderClientWinCE::dispatchDidFinishLoad() 222{ 223 notImplemented(); 224} 225 226void FrameLoaderClientWinCE::frameLoadCompleted() 227{ 228 notImplemented(); 229} 230 231void FrameLoaderClientWinCE::saveViewStateToItem(HistoryItem*) 232{ 233 notImplemented(); 234} 235 236void FrameLoaderClientWinCE::restoreViewState() 237{ 238 notImplemented(); 239} 240 241bool FrameLoaderClientWinCE::shouldGoToHistoryItem(HistoryItem* item) const 242{ 243 return item; 244} 245 246void FrameLoaderClientWinCE::didDisplayInsecureContent() 247{ 248 notImplemented(); 249} 250 251void FrameLoaderClientWinCE::didRunInsecureContent(SecurityOrigin*, const URL&) 252{ 253 notImplemented(); 254} 255 256void FrameLoaderClientWinCE::didDetectXSS(const URL&, bool) 257{ 258 notImplemented(); 259} 260 261void FrameLoaderClientWinCE::makeRepresentation(DocumentLoader*) 262{ 263 notImplemented(); 264} 265 266void FrameLoaderClientWinCE::forceLayout() 267{ 268 notImplemented(); 269} 270 271void FrameLoaderClientWinCE::forceLayoutForNonHTML() 272{ 273 notImplemented(); 274} 275 276void FrameLoaderClientWinCE::setCopiesOnScroll() 277{ 278 notImplemented(); 279} 280 281void FrameLoaderClientWinCE::detachedFromParent2() 282{ 283 notImplemented(); 284} 285 286void FrameLoaderClientWinCE::detachedFromParent3() 287{ 288 notImplemented(); 289} 290 291void FrameLoaderClientWinCE::dispatchDidHandleOnloadEvents() 292{ 293 notImplemented(); 294} 295 296void FrameLoaderClientWinCE::dispatchDidReceiveServerRedirectForProvisionalLoad() 297{ 298 notImplemented(); 299} 300 301void FrameLoaderClientWinCE::dispatchDidCancelClientRedirect() 302{ 303 notImplemented(); 304} 305 306void FrameLoaderClientWinCE::dispatchWillPerformClientRedirect(const URL&, double, double) 307{ 308 notImplemented(); 309} 310 311void FrameLoaderClientWinCE::dispatchDidChangeLocationWithinPage() 312{ 313 notImplemented(); 314} 315 316void FrameLoaderClientWinCE::dispatchDidPushStateWithinPage() 317{ 318 notImplemented(); 319} 320 321void FrameLoaderClientWinCE::dispatchDidReplaceStateWithinPage() 322{ 323 notImplemented(); 324} 325 326void FrameLoaderClientWinCE::dispatchDidPopStateWithinPage() 327{ 328 notImplemented(); 329} 330 331void FrameLoaderClientWinCE::dispatchWillClose() 332{ 333 notImplemented(); 334} 335 336void FrameLoaderClientWinCE::dispatchDidReceiveIcon() 337{ 338 notImplemented(); 339} 340 341void FrameLoaderClientWinCE::dispatchDidStartProvisionalLoad() 342{ 343 notImplemented(); 344} 345 346void FrameLoaderClientWinCE::dispatchDidReceiveTitle(const StringWithDirection&) 347{ 348 notImplemented(); 349} 350 351void FrameLoaderClientWinCE::dispatchDidChangeIcons(WebCore::IconType) 352{ 353 notImplemented(); 354} 355 356void FrameLoaderClientWinCE::dispatchDidCommitLoad() 357{ 358 notImplemented(); 359} 360 361void FrameLoaderClientWinCE::dispatchDidFinishDocumentLoad() 362{ 363 notImplemented(); 364} 365 366void FrameLoaderClientWinCE::dispatchDidLayout(LayoutMilestones) 367{ 368 notImplemented(); 369} 370 371void FrameLoaderClientWinCE::dispatchShow() 372{ 373 notImplemented(); 374} 375 376void FrameLoaderClientWinCE::cancelPolicyCheck() 377{ 378 notImplemented(); 379} 380 381void FrameLoaderClientWinCE::revertToProvisionalState(DocumentLoader*) 382{ 383 notImplemented(); 384} 385 386void FrameLoaderClientWinCE::willChangeTitle(DocumentLoader*) 387{ 388 notImplemented(); 389} 390 391void FrameLoaderClientWinCE::didChangeTitle(DocumentLoader* documentLoader) 392{ 393 setTitle(documentLoader->title(), documentLoader->url()); 394} 395 396bool FrameLoaderClientWinCE::canHandleRequest(const WebCore::ResourceRequest&) const 397{ 398 notImplemented(); 399 return true; 400} 401 402bool FrameLoaderClientWinCE::canShowMIMEType(const String& type) const 403{ 404 return (MIMETypeRegistry::canShowMIMEType(type) 405 || PluginDatabase::installedPlugins()->isMIMETypeRegistered(type)); 406} 407 408bool FrameLoaderClientWinCE::canShowMIMETypeAsHTML(const String&) const 409{ 410 notImplemented(); 411 return false; 412} 413 414bool FrameLoaderClientWinCE::representationExistsForURLScheme(const String&) const 415{ 416 notImplemented(); 417 return false; 418} 419 420String FrameLoaderClientWinCE::generatedMIMETypeForURLScheme(const String&) const 421{ 422 notImplemented(); 423 return String(); 424} 425 426void FrameLoaderClientWinCE::finishedLoading(DocumentLoader*) 427{ 428 if (!m_pluginView) 429 return; 430 431 m_pluginView->didFinishLoading(); 432 m_pluginView = 0; 433 m_hasSentResponseToPlugin = false; 434} 435 436void FrameLoaderClientWinCE::provisionalLoadStarted() 437{ 438 notImplemented(); 439} 440 441void FrameLoaderClientWinCE::didFinishLoad() 442{ 443 notImplemented(); 444} 445 446void FrameLoaderClientWinCE::prepareForDataSourceReplacement() 447{ 448 notImplemented(); 449} 450 451void FrameLoaderClientWinCE::setTitle(const StringWithDirection&, const URL&) 452{ 453 notImplemented(); 454} 455 456void FrameLoaderClientWinCE::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long, int) 457{ 458 notImplemented(); 459} 460 461void FrameLoaderClientWinCE::dispatchDidFinishLoading(DocumentLoader*, unsigned long) 462{ 463 notImplemented(); 464} 465 466void FrameLoaderClientWinCE::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&) 467{ 468 notImplemented(); 469} 470 471bool FrameLoaderClientWinCE::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int) 472{ 473 notImplemented(); 474 return false; 475} 476 477void FrameLoaderClientWinCE::dispatchDidFailProvisionalLoad(const ResourceError& error) 478{ 479 dispatchDidFailLoad(error); 480} 481 482void FrameLoaderClientWinCE::dispatchDidFailLoad(const ResourceError&) 483{ 484 notImplemented(); 485} 486 487void FrameLoaderClientWinCE::convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) 488{ 489 notImplemented(); 490} 491 492ResourceError FrameLoaderClientWinCE::cancelledError(const WebCore::ResourceRequest&) 493{ 494 return ResourceError(); 495} 496 497ResourceError FrameLoaderClientWinCE::blockedError(const WebCore::ResourceRequest&) 498{ 499 return ResourceError(); 500} 501 502ResourceError FrameLoaderClientWinCE::cannotShowURLError(const WebCore::ResourceRequest&) 503{ 504 return ResourceError(); 505} 506 507ResourceError FrameLoaderClientWinCE::interruptedForPolicyChangeError(const WebCore::ResourceRequest&) 508{ 509 return ResourceError(); 510} 511 512ResourceError FrameLoaderClientWinCE::cannotShowMIMETypeError(const WebCore::ResourceResponse&) 513{ 514 return ResourceError(); 515} 516 517ResourceError FrameLoaderClientWinCE::fileDoesNotExistError(const WebCore::ResourceResponse&) 518{ 519 return ResourceError(); 520} 521 522ResourceError FrameLoaderClientWinCE::pluginWillHandleLoadError(const WebCore::ResourceResponse&) 523{ 524 return ResourceError(); 525} 526 527bool FrameLoaderClientWinCE::shouldFallBack(const ResourceError& error) 528{ 529 return !(error.isCancellation()); 530} 531 532bool FrameLoaderClientWinCE::canCachePage() const 533{ 534 return true; 535} 536 537Frame* FrameLoaderClientWinCE::dispatchCreatePage(const NavigationAction&) 538{ 539 notImplemented(); 540 return 0; 541} 542 543void FrameLoaderClientWinCE::dispatchUnableToImplementPolicy(const ResourceError&) 544{ 545 notImplemented(); 546} 547 548void FrameLoaderClientWinCE::setMainDocumentError(DocumentLoader*, const ResourceError& error) 549{ 550 if (!m_pluginView) 551 return; 552 553 m_pluginView->didFail(error); 554 m_pluginView = 0; 555 m_hasSentResponseToPlugin = false; 556} 557 558void FrameLoaderClientWinCE::startDownload(const WebCore::ResourceRequest&, const String& /* suggestedName */) 559{ 560 notImplemented(); 561} 562 563void FrameLoaderClientWinCE::updateGlobalHistory() 564{ 565 notImplemented(); 566} 567 568void FrameLoaderClientWinCE::updateGlobalHistoryRedirectLinks() 569{ 570 notImplemented(); 571} 572 573void FrameLoaderClientWinCE::savePlatformDataToCachedFrame(CachedFrame*) 574{ 575 notImplemented(); 576} 577 578void FrameLoaderClientWinCE::transitionToCommittedFromCachedFrame(CachedFrame*) 579{ 580 notImplemented(); 581} 582 583void FrameLoaderClientWinCE::transitionToCommittedForNewPage() 584{ 585 Page* page = m_frame->page(); 586 ASSERT(page); 587 588 bool isMainFrame = m_frame == page->mainFrame(); 589 590 m_frame->setView(0); 591 592 RefPtr<FrameView> frameView; 593 if (isMainFrame) { 594 RECT rect; 595 m_webView->frameRect(&rect); 596 frameView = FrameView::create(*m_frame, IntRect(rect).size()); 597 } else 598 frameView = FrameView::create(*m_frame); 599 600 m_frame->setView(frameView); 601 602 if (m_frame->ownerRenderer()) 603 m_frame->ownerRenderer()->setWidget(frameView); 604} 605 606void FrameLoaderClientWinCE::didSaveToPageCache() 607{ 608} 609 610void FrameLoaderClientWinCE::didRestoreFromPageCache() 611{ 612} 613 614void FrameLoaderClientWinCE::dispatchDidBecomeFrameset(bool) 615{ 616} 617 618PassRefPtr<WebCore::FrameNetworkingContext> FrameLoaderClientWinCE::createNetworkingContext() 619{ 620 return FrameNetworkingContextWinCE::create(m_frame, userAgent(URL())); 621} 622 623} // namespace WebKit 624