Home | History | Annotate | Download | only in WebCoreSupport
      1 /*
      2  * Copyright (C) 2010 Patrick Gansterer <paroga (at) 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 "NotImplemented.h"
     36 #include "Page.h"
     37 #include "PluginDatabase.h"
     38 #include "RenderPart.h"
     39 #include "SystemInfo.h"
     40 #include "WebKitVersion.h"
     41 #include "WebView.h"
     42 #include <wtf/text/StringConcatenate.h>
     43 
     44 using namespace WebCore;
     45 
     46 namespace WebKit {
     47 
     48 FrameLoaderClientWinCE::FrameLoaderClientWinCE(WebView* view)
     49     : m_webView(view)
     50     , m_pluginView(0)
     51 {
     52     ASSERT(m_webView);
     53 }
     54 
     55 FrameLoaderClientWinCE::~FrameLoaderClientWinCE()
     56 {
     57 }
     58 
     59 String FrameLoaderClientWinCE::userAgent(const KURL&)
     60 {
     61     DEFINE_STATIC_LOCAL(String, userAgentString, ());
     62 
     63     if (userAgentString.isNull()) {
     64         String webKitVersion = String::format("%d.%d", WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION);
     65         userAgentString = makeString("Mozilla/5.0 (", windowsVersionForUAString(), ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) Mobile Safari/", webKitVersion);
     66     }
     67 
     68     return userAgentString;
     69 }
     70 
     71 PassRefPtr<DocumentLoader> FrameLoaderClientWinCE::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData)
     72 {
     73     return DocumentLoader::create(request, substituteData);
     74 }
     75 
     76 void FrameLoaderClientWinCE::committedLoad(DocumentLoader* loader, const char* data, int length)
     77 {
     78     if (m_pluginView) {
     79         if (!m_hasSentResponseToPlugin) {
     80             m_pluginView->didReceiveResponse(loader->response());
     81             m_hasSentResponseToPlugin = true;
     82         }
     83         m_pluginView->didReceiveData(data, length);
     84     } else
     85         loader->commitData(data, length);
     86 }
     87 
     88 bool FrameLoaderClientWinCE::shouldUseCredentialStorage(DocumentLoader*, unsigned long)
     89 {
     90     notImplemented();
     91     return false;
     92 }
     93 
     94 void FrameLoaderClientWinCE::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
     95 {
     96     notImplemented();
     97 }
     98 
     99 void FrameLoaderClientWinCE::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
    100 {
    101     notImplemented();
    102 }
    103 
    104 void FrameLoaderClientWinCE::dispatchWillSendRequest(DocumentLoader*, unsigned long, WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
    105 {
    106     notImplemented();
    107 }
    108 
    109 void FrameLoaderClientWinCE::assignIdentifierToInitialRequest(unsigned long, DocumentLoader*, const WebCore::ResourceRequest&)
    110 {
    111     notImplemented();
    112 }
    113 
    114 void FrameLoaderClientWinCE::postProgressStartedNotification()
    115 {
    116     notImplemented();
    117 }
    118 
    119 void FrameLoaderClientWinCE::postProgressEstimateChangedNotification()
    120 {
    121     notImplemented();
    122 }
    123 
    124 void FrameLoaderClientWinCE::postProgressFinishedNotification()
    125 {
    126     notImplemented();
    127 }
    128 
    129 void FrameLoaderClientWinCE::frameLoaderDestroyed()
    130 {
    131     m_webView = 0;
    132     m_frame = 0;
    133     delete this;
    134 }
    135 
    136 void FrameLoaderClientWinCE::dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse& response)
    137 {
    138     m_response = response;
    139 }
    140 
    141 void FrameLoaderClientWinCE::dispatchDecidePolicyForResponse(FramePolicyFunction policyFunction, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest&)
    142 {
    143     if (canShowMIMEType(response.mimeType()))
    144         (m_frame->loader()->policyChecker()->*policyFunction)(PolicyUse);
    145     else
    146         (m_frame->loader()->policyChecker()->*policyFunction)(PolicyDownload);
    147 }
    148 
    149 void FrameLoaderClientWinCE::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const String&)
    150 {
    151     (m_frame->loader()->policyChecker()->*policyFunction)(PolicyUse);
    152 }
    153 
    154 void FrameLoaderClientWinCE::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>)
    155 {
    156     (m_frame->loader()->policyChecker()->*policyFunction)(PolicyUse);
    157 }
    158 
    159 void FrameLoaderClientWinCE::dispatchWillSubmitForm(FramePolicyFunction policyFunction, PassRefPtr<FormState>)
    160 {
    161     (m_frame->loader()->policyChecker()->*policyFunction)(PolicyUse);
    162 }
    163 
    164 PassRefPtr<Widget> FrameLoaderClientWinCE::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool)
    165 {
    166     return 0;
    167 }
    168 
    169 PassRefPtr<Frame> FrameLoaderClientWinCE::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
    170                                                  const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
    171 {
    172     return m_webView->createFrame(url, name, ownerElement, referrer, allowsScrolling, marginWidth, marginHeight);
    173 }
    174 
    175 void FrameLoaderClientWinCE::didTransferChildFrameToNewDocument(Page*)
    176 {
    177 }
    178 
    179 void FrameLoaderClientWinCE::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const WebCore::ResourceRequest&, Page*)
    180 {
    181 }
    182 
    183 void FrameLoaderClientWinCE::redirectDataToPlugin(Widget* pluginWidget)
    184 {
    185     ASSERT(!m_pluginView);
    186     m_pluginView = static_cast<PluginView*>(pluginWidget);
    187     m_hasSentResponseToPlugin = false;
    188 }
    189 
    190 PassRefPtr<Widget> FrameLoaderClientWinCE::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&)
    191 {
    192     notImplemented();
    193     return 0;
    194 }
    195 
    196 ObjectContentType FrameLoaderClientWinCE::objectContentType(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages)
    197 {
    198     return FrameLoader::defaultObjectContentType(url, mimeType, shouldPreferPlugInsForImages);
    199 }
    200 
    201 String FrameLoaderClientWinCE::overrideMediaType() const
    202 {
    203     notImplemented();
    204     return String();
    205 }
    206 
    207 void FrameLoaderClientWinCE::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*)
    208 {
    209     notImplemented();
    210 }
    211 
    212 void FrameLoaderClientWinCE::documentElementAvailable()
    213 {
    214     notImplemented();
    215 }
    216 
    217 void FrameLoaderClientWinCE::didPerformFirstNavigation() const
    218 {
    219     notImplemented();
    220 }
    221 
    222 void FrameLoaderClientWinCE::registerForIconNotification(bool)
    223 {
    224     notImplemented();
    225 }
    226 
    227 void FrameLoaderClientWinCE::setMainFrameDocumentReady(bool)
    228 {
    229     notImplemented();
    230 }
    231 
    232 bool FrameLoaderClientWinCE::hasWebView() const
    233 {
    234     return true;
    235 }
    236 
    237 void FrameLoaderClientWinCE::dispatchDidFinishLoad()
    238 {
    239     notImplemented();
    240 }
    241 
    242 void FrameLoaderClientWinCE::frameLoadCompleted()
    243 {
    244     notImplemented();
    245 }
    246 
    247 void FrameLoaderClientWinCE::saveViewStateToItem(HistoryItem*)
    248 {
    249     notImplemented();
    250 }
    251 
    252 void FrameLoaderClientWinCE::restoreViewState()
    253 {
    254     notImplemented();
    255 }
    256 
    257 bool FrameLoaderClientWinCE::shouldGoToHistoryItem(HistoryItem* item) const
    258 {
    259     return item;
    260 }
    261 
    262 bool FrameLoaderClientWinCE::shouldStopLoadingForHistoryItem(HistoryItem* item) const
    263 {
    264     return true;
    265 }
    266 
    267 void FrameLoaderClientWinCE::dispatchDidAddBackForwardItem(HistoryItem*) const
    268 {
    269 }
    270 
    271 void FrameLoaderClientWinCE::dispatchDidRemoveBackForwardItem(HistoryItem*) const
    272 {
    273 }
    274 
    275 void FrameLoaderClientWinCE::dispatchDidChangeBackForwardIndex() const
    276 {
    277 }
    278 
    279 void FrameLoaderClientWinCE::didDisplayInsecureContent()
    280 {
    281     notImplemented();
    282 }
    283 
    284 void FrameLoaderClientWinCE::didRunInsecureContent(SecurityOrigin*, const KURL&)
    285 {
    286     notImplemented();
    287 }
    288 
    289 void FrameLoaderClientWinCE::makeRepresentation(DocumentLoader*)
    290 {
    291     notImplemented();
    292 }
    293 
    294 void FrameLoaderClientWinCE::forceLayout()
    295 {
    296     notImplemented();
    297 }
    298 
    299 void FrameLoaderClientWinCE::forceLayoutForNonHTML()
    300 {
    301     notImplemented();
    302 }
    303 
    304 void FrameLoaderClientWinCE::setCopiesOnScroll()
    305 {
    306     notImplemented();
    307 }
    308 
    309 void FrameLoaderClientWinCE::detachedFromParent2()
    310 {
    311     notImplemented();
    312 }
    313 
    314 void FrameLoaderClientWinCE::detachedFromParent3()
    315 {
    316     notImplemented();
    317 }
    318 
    319 void FrameLoaderClientWinCE::dispatchDidHandleOnloadEvents()
    320 {
    321     notImplemented();
    322 }
    323 
    324 void FrameLoaderClientWinCE::dispatchDidReceiveServerRedirectForProvisionalLoad()
    325 {
    326     notImplemented();
    327 }
    328 
    329 void FrameLoaderClientWinCE::dispatchDidCancelClientRedirect()
    330 {
    331     notImplemented();
    332 }
    333 
    334 void FrameLoaderClientWinCE::dispatchWillPerformClientRedirect(const KURL&, double, double)
    335 {
    336     notImplemented();
    337 }
    338 
    339 void FrameLoaderClientWinCE::dispatchDidChangeLocationWithinPage()
    340 {
    341     notImplemented();
    342 }
    343 
    344 void FrameLoaderClientWinCE::dispatchDidPushStateWithinPage()
    345 {
    346     notImplemented();
    347 }
    348 
    349 void FrameLoaderClientWinCE::dispatchDidReplaceStateWithinPage()
    350 {
    351     notImplemented();
    352 }
    353 
    354 void FrameLoaderClientWinCE::dispatchDidPopStateWithinPage()
    355 {
    356     notImplemented();
    357 }
    358 
    359 void FrameLoaderClientWinCE::dispatchWillClose()
    360 {
    361     notImplemented();
    362 }
    363 
    364 void FrameLoaderClientWinCE::dispatchDidReceiveIcon()
    365 {
    366     notImplemented();
    367 }
    368 
    369 void FrameLoaderClientWinCE::dispatchDidStartProvisionalLoad()
    370 {
    371     notImplemented();
    372 }
    373 
    374 void FrameLoaderClientWinCE::dispatchDidReceiveTitle(const StringWithDirection&)
    375 {
    376     notImplemented();
    377 }
    378 
    379 void FrameLoaderClientWinCE::dispatchDidChangeIcons()
    380 {
    381     notImplemented();
    382 }
    383 
    384 void FrameLoaderClientWinCE::dispatchDidCommitLoad()
    385 {
    386     notImplemented();
    387 }
    388 
    389 void FrameLoaderClientWinCE::dispatchDidFinishDocumentLoad()
    390 {
    391     notImplemented();
    392 }
    393 
    394 void FrameLoaderClientWinCE::dispatchDidFirstLayout()
    395 {
    396     notImplemented();
    397 }
    398 
    399 void FrameLoaderClientWinCE::dispatchDidFirstVisuallyNonEmptyLayout()
    400 {
    401     notImplemented();
    402 }
    403 
    404 void FrameLoaderClientWinCE::dispatchShow()
    405 {
    406     notImplemented();
    407 }
    408 
    409 void FrameLoaderClientWinCE::cancelPolicyCheck()
    410 {
    411     notImplemented();
    412 }
    413 
    414 void FrameLoaderClientWinCE::dispatchDidLoadMainResource(DocumentLoader*)
    415 {
    416     notImplemented();
    417 }
    418 
    419 void FrameLoaderClientWinCE::revertToProvisionalState(DocumentLoader*)
    420 {
    421     notImplemented();
    422 }
    423 
    424 void FrameLoaderClientWinCE::willChangeTitle(DocumentLoader*)
    425 {
    426     notImplemented();
    427 }
    428 
    429 void FrameLoaderClientWinCE::didChangeTitle(DocumentLoader* documentLoader)
    430 {
    431     setTitle(documentLoader->title(), documentLoader->url());
    432 }
    433 
    434 bool FrameLoaderClientWinCE::canHandleRequest(const WebCore::ResourceRequest&) const
    435 {
    436     notImplemented();
    437     return true;
    438 }
    439 
    440 bool FrameLoaderClientWinCE::canShowMIMEType(const String& type) const
    441 {
    442     return (MIMETypeRegistry::isSupportedImageMIMEType(type)
    443             || MIMETypeRegistry::isSupportedNonImageMIMEType(type)
    444             || MIMETypeRegistry::isSupportedMediaMIMEType(type)
    445             || PluginDatabase::installedPlugins()->isMIMETypeRegistered(type));
    446 }
    447 
    448 bool FrameLoaderClientWinCE::canShowMIMETypeAsHTML(const String&) const
    449 {
    450     notImplemented();
    451     return false;
    452 }
    453 
    454 bool FrameLoaderClientWinCE::representationExistsForURLScheme(const String&) const
    455 {
    456     notImplemented();
    457     return false;
    458 }
    459 
    460 String FrameLoaderClientWinCE::generatedMIMETypeForURLScheme(const String&) const
    461 {
    462     notImplemented();
    463     return String();
    464 }
    465 
    466 void FrameLoaderClientWinCE::finishedLoading(DocumentLoader* documentLoader)
    467 {
    468     if (!m_pluginView) {
    469         documentLoader->writer()->setEncoding(m_response.textEncodingName(), false);
    470         return;
    471     }
    472 
    473     m_pluginView->didFinishLoading();
    474     m_pluginView = 0;
    475     m_hasSentResponseToPlugin = false;
    476 }
    477 
    478 void FrameLoaderClientWinCE::provisionalLoadStarted()
    479 {
    480     notImplemented();
    481 }
    482 
    483 void FrameLoaderClientWinCE::didFinishLoad()
    484 {
    485     notImplemented();
    486 }
    487 
    488 void FrameLoaderClientWinCE::prepareForDataSourceReplacement()
    489 {
    490     notImplemented();
    491 }
    492 
    493 void FrameLoaderClientWinCE::setTitle(const StringWithDirection&, const KURL&)
    494 {
    495     notImplemented();
    496 }
    497 
    498 void FrameLoaderClientWinCE::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long, int)
    499 {
    500     notImplemented();
    501 }
    502 
    503 void FrameLoaderClientWinCE::dispatchDidFinishLoading(DocumentLoader*, unsigned long)
    504 {
    505     notImplemented();
    506 }
    507 
    508 void FrameLoaderClientWinCE::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&)
    509 {
    510     notImplemented();
    511 }
    512 
    513 bool FrameLoaderClientWinCE::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int)
    514 {
    515     notImplemented();
    516     return false;
    517 }
    518 
    519 void FrameLoaderClientWinCE::dispatchDidFailProvisionalLoad(const ResourceError& error)
    520 {
    521     dispatchDidFailLoad(error);
    522 }
    523 
    524 void FrameLoaderClientWinCE::dispatchDidFailLoad(const ResourceError&)
    525 {
    526     notImplemented();
    527 }
    528 
    529 void FrameLoaderClientWinCE::download(ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
    530 {
    531     notImplemented();
    532 }
    533 
    534 ResourceError FrameLoaderClientWinCE::cancelledError(const WebCore::ResourceRequest&)
    535 {
    536     return ResourceError();
    537 }
    538 
    539 ResourceError FrameLoaderClientWinCE::blockedError(const WebCore::ResourceRequest&)
    540 {
    541     return ResourceError();
    542 }
    543 
    544 ResourceError FrameLoaderClientWinCE::cannotShowURLError(const WebCore::ResourceRequest&)
    545 {
    546     return ResourceError();
    547 }
    548 
    549 ResourceError FrameLoaderClientWinCE::interruptForPolicyChangeError(const WebCore::ResourceRequest&)
    550 {
    551     return ResourceError();
    552 }
    553 
    554 ResourceError FrameLoaderClientWinCE::cannotShowMIMETypeError(const WebCore::ResourceResponse&)
    555 {
    556     return ResourceError();
    557 }
    558 
    559 ResourceError FrameLoaderClientWinCE::fileDoesNotExistError(const WebCore::ResourceResponse&)
    560 {
    561     return ResourceError();
    562 }
    563 
    564 ResourceError FrameLoaderClientWinCE::pluginWillHandleLoadError(const WebCore::ResourceResponse&)
    565 {
    566     return ResourceError();
    567 }
    568 
    569 bool FrameLoaderClientWinCE::shouldFallBack(const ResourceError& error)
    570 {
    571     return !(error.isCancellation());
    572 }
    573 
    574 bool FrameLoaderClientWinCE::canCachePage() const
    575 {
    576     return true;
    577 }
    578 
    579 Frame* FrameLoaderClientWinCE::dispatchCreatePage(const NavigationAction&)
    580 {
    581     notImplemented();
    582     return 0;
    583 }
    584 
    585 void FrameLoaderClientWinCE::dispatchUnableToImplementPolicy(const ResourceError&)
    586 {
    587     notImplemented();
    588 }
    589 
    590 void FrameLoaderClientWinCE::setMainDocumentError(DocumentLoader*, const ResourceError& error)
    591 {
    592     if (!m_pluginView)
    593         return;
    594 
    595     m_pluginView->didFail(error);
    596     m_pluginView = 0;
    597     m_hasSentResponseToPlugin = false;
    598 }
    599 
    600 void FrameLoaderClientWinCE::startDownload(const WebCore::ResourceRequest&)
    601 {
    602     notImplemented();
    603 }
    604 
    605 void FrameLoaderClientWinCE::updateGlobalHistory()
    606 {
    607     notImplemented();
    608 }
    609 
    610 void FrameLoaderClientWinCE::updateGlobalHistoryRedirectLinks()
    611 {
    612     notImplemented();
    613 }
    614 
    615 void FrameLoaderClientWinCE::savePlatformDataToCachedFrame(CachedFrame*)
    616 {
    617     notImplemented();
    618 }
    619 
    620 void FrameLoaderClientWinCE::transitionToCommittedFromCachedFrame(CachedFrame*)
    621 {
    622     notImplemented();
    623 }
    624 
    625 void FrameLoaderClientWinCE::transitionToCommittedForNewPage()
    626 {
    627     Page* page = m_frame->page();
    628     ASSERT(page);
    629 
    630     bool isMainFrame = m_frame == page->mainFrame();
    631 
    632     m_frame->setView(0);
    633 
    634     RefPtr<FrameView> frameView;
    635     if (isMainFrame) {
    636         RECT rect;
    637         m_webView->frameRect(&rect);
    638         frameView = FrameView::create(m_frame, IntRect(rect).size());
    639     } else
    640         frameView = FrameView::create(m_frame);
    641 
    642     m_frame->setView(frameView);
    643 
    644     if (m_frame->ownerRenderer())
    645         m_frame->ownerRenderer()->setWidget(frameView);
    646 }
    647 
    648 void FrameLoaderClientWinCE::didSaveToPageCache()
    649 {
    650 }
    651 
    652 void FrameLoaderClientWinCE::didRestoreFromPageCache()
    653 {
    654 }
    655 
    656 void FrameLoaderClientWinCE::dispatchDidBecomeFrameset(bool)
    657 {
    658 }
    659 
    660 PassRefPtr<WebCore::FrameNetworkingContext> FrameLoaderClientWinCE::createNetworkingContext()
    661 {
    662     return FrameNetworkingContextWinCE::create(m_frame, userAgent(KURL()));
    663 }
    664 
    665 } // namespace WebKit
    666