Changeset 18635 in webkit


Ignore:
Timestamp:
Jan 5, 2007 4:55:49 PM (17 years ago)
Author:
andersca
Message:

Rubber stamped by Adam.


Move even more code to .cpp files.

  • WebCore.xcodeproj/project.pbxproj:
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::createWindow): (WebCore::FrameLoader::load): (WebCore::FrameLoader::canLoad): (WebCore::FrameLoader::initialRequest): (WebCore::FrameLoader::receivedData): (WebCore::FrameLoader::setRequest): (WebCore::FrameLoader::setResponse): (WebCore::FrameLoader::willUseArchive): (WebCore::FrameLoader::handleUnimplementablePolicy): (WebCore::FrameLoader::cannotShowMIMEType): (WebCore::FrameLoader::interruptionForPolicyChangeError): (WebCore::FrameLoader::checkNavigationPolicy): (WebCore::FrameLoader::checkContentPolicy): (WebCore::FrameLoader::shouldReloadToHandleUnreachableURL): (WebCore::FrameLoader::reloadAllowingStaleData): (WebCore::FrameLoader::reload): (WebCore::FrameLoader::finishedLoading): (WebCore::FrameLoader::continueAfterWillSubmitForm): (WebCore::FrameLoader::submitForm): (WebCore::FrameLoader::post): (WebCore::FrameLoader::isReloading): (WebCore::FrameLoader::loadEmptyDocumentSynchronously): (WebCore::FrameLoader::loadResourceSynchronously): (WebCore::FrameLoader::startLoadingMainResource): (WebCore::FrameLoader::startLoading): (WebCore::FrameLoader::cancelMainResourceLoad): (WebCore::FrameLoader::identifierForInitialRequest): (WebCore::FrameLoader::willSendRequest): (WebCore::FrameLoader::didReceiveResponse): (WebCore::FrameLoader::didReceiveData): (WebCore::FrameLoader::didFailToLoad): (WebCore::FrameLoader::originalRequest): (WebCore::FrameLoader::receivedMainResourceError): (WebCore::FrameLoader::callContinueFragmentScrollAfterNavigationPolicy): (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy): (WebCore::FrameLoader::opened): (WebCore::FrameLoader::dataURLBaseFromRequest): (WebCore::FrameLoader::checkNewWindowPolicy): (WebCore::FrameLoader::continueAfterNewWindowPolicy): (WebCore::FrameLoader::continueAfterNavigationPolicy): (WebCore::FrameLoader::callContinueLoadAfterNavigationPolicy): (WebCore::FrameLoader::continueLoadAfterNavigationPolicy): (WebCore::FrameLoader::callContinueLoadAfterNewWindowPolicy): (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): (WebCore::FrameLoader::sendRemainingDelegateMessages): (WebCore::FrameLoader::requestFromDelegate): (WebCore::FrameLoader::loadedResourceFromMemoryCache): (WebCore::FrameLoader::applyUserAgent): (WebCore::PolicyCheck::PolicyCheck): (WebCore::PolicyCheck::clear): (WebCore::PolicyCheck::set): (WebCore::PolicyCheck::call): (WebCore::PolicyCheck::clearRequest):
  • loader/FrameLoader.h:
  • loader/FrameLoaderClient.h:
  • loader/MainResourceLoader.h:
  • loader/ResourceLoader.h: (WebCore::ResourceLoader::setIdentifier): (WebCore::ResourceLoader::identifier):
  • loader/mac/FrameLoaderMac.mm: (WebCore::FrameLoader::checkLoadCompleteForThisFrame): (WebCore::FrameLoader::referrer): (WebCore::FrameLoader::didReceiveAuthenticationChallenge): (WebCore::FrameLoader::didCancelAuthenticationChallenge): (WebCore::FrameLoader::didChangeTitle):
  • platform/graphics/svg/SVGImageEmptyClients.h: (WebCore::SVGEmptyFrameLoaderClient::dispatchCreatePage):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r18634 r18635  
     12007-01-05  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Rubber stamped by Adam.
     4       
     5        Move even more code to .cpp files.
     6
     7        * WebCore.xcodeproj/project.pbxproj:
     8        * loader/FrameLoader.cpp:
     9        (WebCore::FrameLoader::createWindow):
     10        (WebCore::FrameLoader::load):
     11        (WebCore::FrameLoader::canLoad):
     12        (WebCore::FrameLoader::initialRequest):
     13        (WebCore::FrameLoader::receivedData):
     14        (WebCore::FrameLoader::setRequest):
     15        (WebCore::FrameLoader::setResponse):
     16        (WebCore::FrameLoader::willUseArchive):
     17        (WebCore::FrameLoader::handleUnimplementablePolicy):
     18        (WebCore::FrameLoader::cannotShowMIMEType):
     19        (WebCore::FrameLoader::interruptionForPolicyChangeError):
     20        (WebCore::FrameLoader::checkNavigationPolicy):
     21        (WebCore::FrameLoader::checkContentPolicy):
     22        (WebCore::FrameLoader::shouldReloadToHandleUnreachableURL):
     23        (WebCore::FrameLoader::reloadAllowingStaleData):
     24        (WebCore::FrameLoader::reload):
     25        (WebCore::FrameLoader::finishedLoading):
     26        (WebCore::FrameLoader::continueAfterWillSubmitForm):
     27        (WebCore::FrameLoader::submitForm):
     28        (WebCore::FrameLoader::post):
     29        (WebCore::FrameLoader::isReloading):
     30        (WebCore::FrameLoader::loadEmptyDocumentSynchronously):
     31        (WebCore::FrameLoader::loadResourceSynchronously):
     32        (WebCore::FrameLoader::startLoadingMainResource):
     33        (WebCore::FrameLoader::startLoading):
     34        (WebCore::FrameLoader::cancelMainResourceLoad):
     35        (WebCore::FrameLoader::identifierForInitialRequest):
     36        (WebCore::FrameLoader::willSendRequest):
     37        (WebCore::FrameLoader::didReceiveResponse):
     38        (WebCore::FrameLoader::didReceiveData):
     39        (WebCore::FrameLoader::didFailToLoad):
     40        (WebCore::FrameLoader::originalRequest):
     41        (WebCore::FrameLoader::receivedMainResourceError):
     42        (WebCore::FrameLoader::callContinueFragmentScrollAfterNavigationPolicy):
     43        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
     44        (WebCore::FrameLoader::opened):
     45        (WebCore::FrameLoader::dataURLBaseFromRequest):
     46        (WebCore::FrameLoader::checkNewWindowPolicy):
     47        (WebCore::FrameLoader::continueAfterNewWindowPolicy):
     48        (WebCore::FrameLoader::continueAfterNavigationPolicy):
     49        (WebCore::FrameLoader::callContinueLoadAfterNavigationPolicy):
     50        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
     51        (WebCore::FrameLoader::callContinueLoadAfterNewWindowPolicy):
     52        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
     53        (WebCore::FrameLoader::sendRemainingDelegateMessages):
     54        (WebCore::FrameLoader::requestFromDelegate):
     55        (WebCore::FrameLoader::loadedResourceFromMemoryCache):
     56        (WebCore::FrameLoader::applyUserAgent):
     57        (WebCore::PolicyCheck::PolicyCheck):
     58        (WebCore::PolicyCheck::clear):
     59        (WebCore::PolicyCheck::set):
     60        (WebCore::PolicyCheck::call):
     61        (WebCore::PolicyCheck::clearRequest):
     62        * loader/FrameLoader.h:
     63        * loader/FrameLoaderClient.h:
     64        * loader/MainResourceLoader.h:
     65        * loader/ResourceLoader.h:
     66        (WebCore::ResourceLoader::setIdentifier):
     67        (WebCore::ResourceLoader::identifier):
     68        * loader/mac/FrameLoaderMac.mm:
     69        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
     70        (WebCore::FrameLoader::referrer):
     71        (WebCore::FrameLoader::didReceiveAuthenticationChallenge):
     72        (WebCore::FrameLoader::didCancelAuthenticationChallenge):
     73        (WebCore::FrameLoader::didChangeTitle):
     74        * platform/graphics/svg/SVGImageEmptyClients.h:
     75        (WebCore::SVGEmptyFrameLoaderClient::dispatchCreatePage):
     76
    1772007-01-05  Mitz Pettel  <mitz@webkit.org>
    278
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r18631 r18635  
    43764376                932CA83A0AAA667F00AD1FAD /* TextCodecUTF16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF16.h; sourceTree = "<group>"; };
    43774377                932CA8470AAA66CB00AD1FAD /* TextCodecUTF16.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecUTF16.cpp; sourceTree = "<group>"; };
    4378                 932E16080AF578340025F408 /* FrameLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameLoader.cpp; sourceTree = "<group>"; };
     4378                932E16080AF578340025F408 /* FrameLoader.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = FrameLoader.cpp; sourceTree = "<group>"; };
    43794379                93309D87099E64910056E581 /* AppendNodeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppendNodeCommand.cpp; sourceTree = "<group>"; };
    43804380                93309D88099E64910056E581 /* AppendNodeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppendNodeCommand.h; sourceTree = "<group>"; };
  • trunk/WebCore/loader/FrameLoader.cpp

    r18631 r18635  
    8282#if PLATFORM(MAC)
    8383#include "FrameMac.h"
     84#import "WebDataProtocol.h"
     85#else
     86// FIXME: get rid of this once we don't use nil in the loader
     87#define nil 0
    8488#endif
    8589
     
    269273    if (!request.frameName().isEmpty())
    270274        if (Frame* frame = m_frame->tree()->find(request.frameName())) {
    271 #if PLATFORM(MAC)
    272275            if (!request.resourceRequest().url().isEmpty())
    273276                frame->loader()->load(request, true, 0, 0, HashMap<String, String>());
    274 #endif
    275277            frame->page()->chrome()->focus();
    276278            return frame;
     
    16831685}
    16841686
     1687void FrameLoader::load(const FrameLoadRequest& request, bool userGesture, Event* event,
     1688    HTMLFormElement* submitForm, const HashMap<String, String>& formValues)
     1689{
     1690    String referrer;
     1691    String argsReferrer = request.resourceRequest().httpReferrer();
     1692    if (!argsReferrer.isEmpty())
     1693        referrer = argsReferrer;
     1694    else
     1695        referrer = m_outgoingReferrer;
     1696 
     1697    bool hideReferrer;
     1698    if (!canLoad(request.resourceRequest().url(), referrer, hideReferrer))
     1699        return;
     1700    if (hideReferrer)
     1701        referrer = String();
     1702   
     1703    Frame* targetFrame = m_frame->tree()->find(request.frameName());
     1704    if (!canTarget(targetFrame))
     1705        return;
     1706       
     1707    if (request.resourceRequest().httpMethod() != "POST") {
     1708        FrameLoadType loadType;
     1709        if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
     1710            loadType = FrameLoadTypeReload;
     1711        else if (!userGesture)
     1712            loadType = FrameLoadTypeInternal;
     1713        else
     1714            loadType = FrameLoadTypeStandard;   
     1715   
     1716        load(request.resourceRequest().url(), referrer, loadType,
     1717            request.frameName(), event, submitForm, formValues);
     1718    } else
     1719        post(request.resourceRequest().url(), referrer, request.frameName(),
     1720            request.resourceRequest().httpBody(), request.resourceRequest().httpContentType(), event, submitForm, formValues);
     1721
     1722    if (targetFrame && targetFrame != m_frame)
     1723        targetFrame->page()->chrome()->focus();
     1724}
     1725
     1726void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType newLoadType,
     1727    const String& frameName, Event* event, HTMLFormElement* form, const HashMap<String, String>& values)
     1728{
     1729    bool isFormSubmission = !values.isEmpty();
     1730   
     1731    ResourceRequest request(URL);
     1732    if (!referrer.isEmpty())
     1733        request.setHTTPReferrer(referrer);
     1734    addExtraFieldsToRequest(request, true, event || isFormSubmission);
     1735    if (newLoadType == FrameLoadTypeReload)
     1736        request.setCachePolicy(ReloadIgnoringCacheData);
     1737
     1738    ASSERT(newLoadType != FrameLoadTypeSame);
     1739
     1740    NavigationAction action(URL, newLoadType, isFormSubmission, event);
     1741
     1742    RefPtr<FormState> formState;
     1743    if (form && !values.isEmpty())
     1744        formState = FormState::create(form, values, m_frame);
     1745   
     1746    if (!frameName.isEmpty()) {
     1747        if (Frame* targetFrame = m_frame->tree()->find(frameName))
     1748            targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, form, values);
     1749        else
     1750            checkNewWindowPolicy(action, request, formState.release(), frameName);
     1751        return;
     1752    }
     1753
     1754    RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
     1755
     1756    bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
     1757   
     1758    // Make sure to do scroll to anchor processing even if the URL is
     1759    // exactly the same so pages with '#' links and DHTML side effects
     1760    // work properly.
     1761    if (!isFormSubmission
     1762        && newLoadType != FrameLoadTypeReload
     1763        && newLoadType != FrameLoadTypeSame
     1764        && !shouldReload(URL, url())
     1765        // We don't want to just scroll if a link from within a
     1766        // frameset is trying to reload the frameset into _top.
     1767        && !m_frame->isFrameSet()) {
     1768
     1769        // Just do anchor navigation within the existing content.
     1770       
     1771        // We don't do this if we are submitting a form, explicitly reloading,
     1772        // currently displaying a frameset, or if the new URL does not have a fragment.
     1773        // These rules are based on what KHTML was doing in KHTMLPart::openURL.
     1774       
     1775        // FIXME: What about load types other than Standard and Reload?
     1776       
     1777        oldDocumentLoader->setTriggeringAction(action);
     1778        stopPolicyCheck();
     1779        checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(),
     1780            callContinueFragmentScrollAfterNavigationPolicy, this);
     1781    } else {
     1782        // must grab this now, since this load may stop the previous load and clear this flag
     1783        bool isRedirect = m_quickRedirectComing;
     1784        load(request, action, newLoadType, formState.release());
     1785        if (isRedirect) {
     1786            m_quickRedirectComing = false;
     1787            if (m_provisionalDocumentLoader)
     1788                m_provisionalDocumentLoader->setIsClientRedirect(true);
     1789        } else if (sameURL)
     1790            // Example of this case are sites that reload the same URL with a different cookie
     1791            // driving the generated content, or a master frame with links that drive a target
     1792            // frame, where the user has clicked on the same link repeatedly.
     1793            m_loadType = FrameLoadTypeSame;
     1794    }
     1795}
     1796
     1797void FrameLoader::load(const ResourceRequest& request)
     1798{
     1799    // FIXME: is this the right place to reset loadType? Perhaps this should be done after loading is finished or aborted.
     1800    m_loadType = FrameLoadTypeStandard;
     1801    load(m_client->createDocumentLoader(request).get());
     1802}
     1803
     1804void FrameLoader::load(const ResourceRequest& request, const String& frameName)
     1805{
     1806    if (frameName.isEmpty()) {
     1807        load(request);
     1808        return;
     1809    }
     1810
     1811    Frame* frame = m_frame->tree()->find(frameName);
     1812    if (frame) {
     1813        frame->loader()->load(request);
     1814        return;
     1815    }
     1816
     1817    checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), request, 0, frameName);
     1818}
     1819
     1820void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
     1821{
     1822    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
     1823    setPolicyDocumentLoader(loader.get());
     1824
     1825    loader->setTriggeringAction(action);
     1826    if (m_documentLoader)
     1827        loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
     1828
     1829    load(loader.get(), type, formState);
     1830}
     1831
     1832void FrameLoader::load(DocumentLoader* newDocumentLoader)
     1833{
     1834    stopPolicyCheck();
     1835    setPolicyDocumentLoader(newDocumentLoader);
     1836
     1837    ResourceRequest& r = newDocumentLoader->request();
     1838    addExtraFieldsToRequest(r, true, false);
     1839    FrameLoadType type;
     1840
     1841    if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {
     1842        r.setCachePolicy(ReloadIgnoringCacheData);
     1843        type = FrameLoadTypeSame;
     1844    } else
     1845        type = FrameLoadTypeStandard;
     1846
     1847    if (m_documentLoader)
     1848        newDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEncoding());
     1849   
     1850    // When we loading alternate content for an unreachable URL that we're
     1851    // visiting in the b/f list, we treat it as a reload so the b/f list
     1852    // is appropriately maintained.
     1853    if (shouldReloadToHandleUnreachableURL(newDocumentLoader->originalRequest())) {
     1854        ASSERT(type == FrameLoadTypeStandard);
     1855        type = FrameLoadTypeReload;
     1856    }
     1857
     1858    load(newDocumentLoader, type, 0);
     1859}
     1860
     1861void FrameLoader::load(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> formState)
     1862{
     1863    ASSERT(m_client->hasWebView());
     1864
     1865    // Unfortunately the view must be non-nil, this is ultimately due
     1866    // to parser requiring a FrameView.  We should fix this dependency.
     1867
     1868    ASSERT(m_client->hasFrameView());
     1869
     1870    m_policyLoadType = type;
     1871
     1872    if (Frame* parent = m_frame->tree()->parent())
     1873        loader->setOverrideEncoding(parent->loader()->documentLoader()->overrideEncoding());
     1874
     1875    stopPolicyCheck();
     1876    setPolicyDocumentLoader(loader);
     1877
     1878    checkNavigationPolicy(loader->request(), loader, formState,
     1879        callContinueLoadAfterNavigationPolicy, this);
     1880}
     1881
     1882bool FrameLoader::canLoad(const KURL& url, const String& referrer, bool& hideReferrer)
     1883{
     1884    bool referrerIsWebURL = referrer.startsWith("http:", false) || referrer.startsWith("https:", false);
     1885    bool referrerIsLocalURL = referrer.startsWith("file:", false) || referrer.startsWith("applewebdata:");
     1886    bool URLIsFileURL = url.protocol().startsWith("file", false);
     1887    bool referrerIsSecureURL = referrer.startsWith("https:", false);
     1888    bool URLIsSecureURL = url.protocol().startsWith("https", false);
     1889   
     1890    hideReferrer = !referrerIsWebURL || (referrerIsSecureURL && !URLIsSecureURL);
     1891    return !URLIsFileURL || referrerIsLocalURL;
     1892}
     1893
     1894const ResourceRequest& FrameLoader::initialRequest() const
     1895{
     1896    return activeDocumentLoader()->initialRequest();
     1897}
     1898
     1899void FrameLoader::receivedData(const char* data, int length)
     1900{
     1901    activeDocumentLoader()->receivedData(data, length);
     1902}
     1903
     1904void FrameLoader::setRequest(const ResourceRequest& request)
     1905{
     1906    activeDocumentLoader()->setRequest(request);
     1907}
     1908
     1909void FrameLoader::setResponse(const ResourceResponse& response)
     1910{
     1911    activeDocumentLoader()->setResponse(response);
     1912}
     1913
     1914bool FrameLoader::willUseArchive(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL) const
     1915{
     1916    return m_client->willUseArchive(loader, request, originalURL);
     1917}
     1918
     1919void FrameLoader::handleUnimplementablePolicy(const ResourceError& error)
     1920{
     1921    m_delegateIsHandlingUnimplementablePolicy = true;
     1922    m_client->dispatchUnableToImplementPolicy(error);
     1923    m_delegateIsHandlingUnimplementablePolicy = false;
     1924}
     1925
     1926void FrameLoader::cannotShowMIMEType(const ResourceResponse& response)
     1927{
     1928    handleUnimplementablePolicy(m_client->cannotShowMIMETypeError(response));
     1929}
     1930
     1931ResourceError FrameLoader::interruptionForPolicyChangeError(const ResourceRequest& request)
     1932{
     1933    return m_client->interruptForPolicyChangeError(request);
     1934}
     1935
     1936void FrameLoader::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
     1937{
     1938    checkNavigationPolicy(newRequest, activeDocumentLoader(), 0, function, argument);
     1939}
     1940
     1941void FrameLoader::checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction function, void* argument)
     1942{
     1943    m_policyCheck.set(function, argument);
     1944    m_client->dispatchDecidePolicyForMIMEType(&FrameLoader::continueAfterContentPolicy,
     1945        MIMEType, activeDocumentLoader()->request());
     1946}
     1947
     1948bool FrameLoader::shouldReloadToHandleUnreachableURL(const ResourceRequest& request)
     1949{
     1950    KURL unreachableURL;
     1951#if PLATFORM(MAC)
     1952    unreachableURL = [request.nsURLRequest() _webDataRequestUnreachableURL];
     1953#endif
     1954
     1955    if (unreachableURL.isEmpty())
     1956        return false;
     1957
     1958    if (!isBackForwardLoadType(m_policyLoadType))
     1959        return false;
     1960
     1961    // We only treat unreachableURLs specially during the delegate callbacks
     1962    // for provisional load errors and navigation policy decisions. The former
     1963    // case handles well-formed URLs that can't be loaded, and the latter
     1964    // case handles malformed URLs and unknown schemes. Loading alternate content
     1965    // at other times behaves like a standard load.
     1966    DocumentLoader* compareDocumentLoader = 0;
     1967    if (m_delegateIsDecidingNavigationPolicy || m_delegateIsHandlingUnimplementablePolicy)
     1968        compareDocumentLoader = m_policyDocumentLoader.get();
     1969    else if (m_delegateIsHandlingProvisionalLoadError)
     1970        compareDocumentLoader = m_provisionalDocumentLoader.get();
     1971
     1972    return compareDocumentLoader && unreachableURL != compareDocumentLoader->request().url();
     1973}
     1974
     1975void FrameLoader::reloadAllowingStaleData(const String& encoding)
     1976{
     1977    if (!m_documentLoader)
     1978        return;
     1979
     1980    ResourceRequest request = m_documentLoader->request();
     1981    KURL unreachableURL = m_documentLoader->unreachableURL();
     1982    if (!unreachableURL.isEmpty())
     1983        request.setURL(unreachableURL);
     1984
     1985    request.setCachePolicy(ReturnCacheDataElseLoad);
     1986
     1987    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
     1988    setPolicyDocumentLoader(loader.get());
     1989
     1990    loader->setOverrideEncoding(encoding);
     1991
     1992    load(loader.get(), FrameLoadTypeReloadAllowingStaleData, 0);
     1993}
     1994
     1995void FrameLoader::reload()
     1996{
     1997    if (!m_documentLoader)
     1998        return;
     1999
     2000    ResourceRequest& initialRequest = m_documentLoader->request();
     2001   
     2002    // If a window is created by javascript, its main frame can have an empty but non-nil URL.
     2003    // Reloading in this case will lose the current contents (see 4151001).
     2004    if (initialRequest.url().isEmpty())
     2005        return;
     2006
     2007    // Replace error-page URL with the URL we were trying to reach.
     2008    KURL unreachableURL;
     2009#if PLATFORM(MAC)
     2010    unreachableURL = [initialRequest.nsURLRequest() _webDataRequestUnreachableURL];
     2011#endif
     2012    if (!unreachableURL.isEmpty())
     2013        initialRequest = ResourceRequest(unreachableURL);
     2014   
     2015    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest);
     2016    setPolicyDocumentLoader(loader.get());
     2017
     2018    ResourceRequest& request = loader->request();
     2019
     2020    request.setCachePolicy(ReloadIgnoringCacheData);
     2021
     2022    // If we're about to re-post, set up action so the application can warn the user.
     2023    if (request.httpMethod() == "POST")
     2024        loader->setTriggeringAction(NavigationAction(request.url(), NavigationTypeFormResubmitted));
     2025
     2026    loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
     2027   
     2028    load(loader.get(), FrameLoadTypeReload, 0);
     2029}
     2030
    16852031bool FrameLoader::canTarget(Frame* target) const
    16862032{
     
    21622508    RefPtr<Frame> protect(m_frame);
    21632509
    2164 #if PLATFORM(MAC)
    21652510    RefPtr<DocumentLoader> dl = activeDocumentLoader();
    21662511    dl->finishedLoading();
    2167     if (dl->mainDocumentError() || !dl->frameLoader())
     2512    if (!dl->mainDocumentError().isNull() || !dl->frameLoader())
    21682513        return;
    21692514    dl->setPrimaryLoadComplete(true);
    21702515    m_client->dispatchDidLoadMainResource(dl.get());
    2171 #endif
    21722516    checkLoadComplete();
    21732517}
     
    22862630}
    22872631
    2288 #if PLATFORM(MAC)
    22892632void FrameLoader::continueAfterWillSubmitForm(PolicyAction)
    22902633{
    22912634    startLoading();
    22922635}
    2293 #endif
    22942636
    22952637#if PLATFORM(MAC)
     
    23852727    clearRecordedFormValues();
    23862728}
    2387 #endif
    2388 
    2389 #if PLATFORM(MAC)
     2729
    23902730void FrameLoader::urlSelected(const FrameLoadRequest& request, Event* event)
    23912731{
     
    25202860{
    25212861    m_client->committedLoad(loader, data, length);
     2862}
     2863
     2864void FrameLoader::post(const KURL& URL, const String& referrer, const String& frameName, PassRefPtr<FormData> formData,
     2865    const String& contentType, Event* event, HTMLFormElement* form, const HashMap<String, String>& formValues)
     2866{
     2867    // When posting, use the NSURLRequestReloadIgnoringCacheData load flag.
     2868    // This prevents a potential bug which may cause a page with a form that uses itself
     2869    // as an action to be returned from the cache without submitting.
     2870
     2871    // FIXME: Where's the code that implements what the comment above says?
     2872
     2873    ResourceRequest request(URL);
     2874    addExtraFieldsToRequest(request, true, true);
     2875
     2876    if (!referrer.isEmpty())
     2877        request.setHTTPReferrer(referrer);
     2878    request.setHTTPMethod("POST");
     2879    request.setHTTPBody(formData);
     2880    request.setHTTPContentType(contentType);
     2881
     2882    NavigationAction action(URL, FrameLoadTypeStandard, true, event);
     2883
     2884    RefPtr<FormState> formState;
     2885    if (form && !formValues.isEmpty())
     2886        formState = FormState::create(form, formValues, m_frame);
     2887
     2888    if (!frameName.isEmpty()) {
     2889        if (Frame* targetFrame = m_frame->tree()->find(frameName))
     2890            targetFrame->loader()->load(request, action, FrameLoadTypeStandard, formState.release());
     2891        else
     2892            checkNewWindowPolicy(action, request, formState.release(), frameName);
     2893    } else
     2894        load(request, action, FrameLoadTypeStandard, formState.release());
     2895}
     2896
     2897bool FrameLoader::isReloading() const
     2898{
     2899    return documentLoader()->request().cachePolicy() == ReloadIgnoringCacheData;
     2900}
     2901
     2902void FrameLoader::loadEmptyDocumentSynchronously()
     2903{
     2904    ResourceRequest request(KURL(""));
     2905    load(request);
     2906}
     2907
     2908void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, ResourceResponse& response, Vector<char>& data)
     2909{
     2910    // Since this is a subresource, we can load any URL (we ignore the return value).
     2911    // But we still want to know whether we should hide the referrer or not, so we call the canLoad method.
     2912    String referrer = m_outgoingReferrer;
     2913    bool hideReferrer;
     2914    canLoad(request.url(), referrer, hideReferrer);
     2915    if (hideReferrer)
     2916        referrer = String();
     2917   
     2918    ResourceRequest initialRequest = request;
     2919    initialRequest.setTimeoutInterval(10);
     2920   
     2921    if (initialRequest.isConditional())
     2922        initialRequest.setCachePolicy(ReloadIgnoringCacheData);
     2923    else
     2924        initialRequest.setCachePolicy(documentLoader()->request().cachePolicy());
     2925   
     2926    if (!referrer.isEmpty())
     2927        initialRequest.setHTTPReferrer(referrer);
     2928   
     2929    initialRequest.setMainDocumentURL(m_frame->page()->mainFrame()->loader()->documentLoader()->request().url());
     2930    initialRequest.setHTTPUserAgent(client()->userAgent());
     2931   
     2932    ResourceError error;
     2933    id identifier = nil;   
     2934    ResourceRequest newRequest(initialRequest);
     2935    requestFromDelegate(newRequest, identifier, error);
     2936
     2937    if (error.isNull()) {
     2938        ASSERT(!newRequest.isNull());
     2939        ResourceError error;
     2940       
     2941        didTellBridgeAboutLoad(newRequest.url().url());
     2942
     2943        ResourceHandle::loadResourceSynchronously(newRequest, error, response, data);
     2944    }
     2945   
     2946    sendRemainingDelegateMessages(identifier, response, data.size(), error);
     2947}
     2948
     2949bool FrameLoader::startLoadingMainResource(ResourceRequest& request, id identifier)
     2950{
     2951    ASSERT(!m_mainResourceLoader);
     2952    m_mainResourceLoader = MainResourceLoader::create(m_frame);
     2953    m_mainResourceLoader->setIdentifier(identifier);
     2954    // FIXME: is there any way the extra fields could have not been added by now?
     2955    addExtraFieldsToRequest(request, true, false);
     2956    if (!m_mainResourceLoader->load(request)) {
     2957        // FIXME: If this should really be caught, we should just ASSERT this doesn't happen;
     2958        // should it be caught by other parts of WebKit or other parts of the app?
     2959#if PLATFORM(MAC)
     2960        LOG_ERROR("could not create WebResourceHandle for URL %@ -- should be caught by policy handler level", request.url().getNSURL());
     2961#endif
     2962        m_mainResourceLoader = 0;
     2963        return false;
     2964    }
     2965    return true;
     2966}
     2967
     2968// FIXME: Poor method name; also, why is this not part of startProvisionalLoad:?
     2969void FrameLoader::startLoading()
     2970{
     2971    if (!m_provisionalDocumentLoader)
     2972        return;
     2973
     2974    m_provisionalDocumentLoader->prepareForLoadStart();
     2975
     2976    if (m_mainResourceLoader)
     2977        return;
     2978
     2979    m_provisionalDocumentLoader->setLoadingFromPageCache(false);
     2980
     2981#if PLATFORM(MAC)
     2982    id identifier = m_client->dispatchIdentifierForInitialRequest
     2983        (m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
     2984#else
     2985    id identifier = 0;
     2986#endif
     2987
     2988    if (!startLoadingMainResource(m_provisionalDocumentLoader->actualRequest(), identifier))
     2989        m_provisionalDocumentLoader->updateLoading();
     2990}
     2991
     2992void FrameLoader::cancelMainResourceLoad(const ResourceError& error)
     2993{
     2994    m_mainResourceLoader->cancel(error);
     2995}
     2996
     2997id FrameLoader::identifierForInitialRequest(const ResourceRequest& clientRequest)
     2998{
     2999#if PLATFORM(MAC)
     3000    return m_client->dispatchIdentifierForInitialRequest(activeDocumentLoader(), clientRequest);
     3001#else
     3002    return 0;
     3003#endif
     3004}
     3005
     3006void FrameLoader::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
     3007{
     3008    applyUserAgent(clientRequest);
     3009    m_client->dispatchWillSendRequest(activeDocumentLoader(), loader->identifier(), clientRequest, redirectResponse);
     3010}
     3011
     3012void FrameLoader::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
     3013{
     3014    activeDocumentLoader()->addResponse(r);
     3015   
     3016    m_client->incrementProgress(loader->identifier(), r);
     3017    m_client->dispatchDidReceiveResponse(activeDocumentLoader(), loader->identifier(), r);
     3018}
     3019
     3020void FrameLoader::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
     3021{
     3022    m_client->incrementProgress(loader->identifier(), data, length);
     3023    m_client->dispatchDidReceiveContentLength(activeDocumentLoader(), loader->identifier(), lengthReceived);
     3024}
     3025
     3026void FrameLoader::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
     3027{
     3028    m_client->completeProgress(loader->identifier());
     3029    if (!error.isNull())
     3030        m_client->dispatchDidFailLoading(activeDocumentLoader(), loader->identifier(), error);
     3031}
     3032
     3033const ResourceRequest& FrameLoader::originalRequest() const
     3034{
     3035    return activeDocumentLoader()->originalRequestCopy();
     3036}
     3037
     3038void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isComplete)
     3039{
     3040    // Retain because the stop may release the last reference to it.
     3041    RefPtr<Frame> protect(m_frame);
     3042
     3043    RefPtr<DocumentLoader> loader = activeDocumentLoader();
     3044   
     3045    if (isComplete) {
     3046        // FIXME: Don't want to do this if an entirely new load is going, so should check
     3047        // that both data sources on the frame are either this or nil.
     3048        stop();
     3049        if (m_client->shouldFallBack(error))
     3050            handleFallbackContent();
     3051    }
     3052   
     3053    if (m_state == FrameStateProvisional) {
     3054#ifdef MULTIPLE_FORM_SUBMISSION_PROTECTION
     3055        KURL failedURL = m_provisionalDocumentLoader->originalRequestCopy().url();
     3056        didNotOpenURL(failedURL);
     3057#endif
     3058        // We might have made a page cache item, but now we're bailing out due to an error before we ever
     3059        // transitioned to the new page (before WebFrameState == commit).  The goal here is to restore any state
     3060        // so that the existing view (that wenever got far enough to replace) can continue being used.
     3061        Document* document = m_frame->document();
     3062        if (document)
     3063            document->setInPageCache(false);
     3064        invalidateCurrentItemPageCache();
     3065       
     3066        // Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
     3067        // status has changed, if there was a redirect. The frame load delegate may have saved some state about
     3068        // the redirect in its -webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:. Since we are definitely
     3069        // not going to use this provisional resource, as it was cancelled, notify the frame load delegate that the redirect
     3070        // has ended.
     3071        if (m_sentRedirectNotification)
     3072            clientRedirectCancelledOrFinished(false);
     3073    }
     3074   
     3075   
     3076    loader->mainReceivedError(error, isComplete);
     3077}
     3078
     3079void FrameLoader::callContinueFragmentScrollAfterNavigationPolicy(void* argument,
     3080    const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)
     3081{
     3082    FrameLoader* loader = static_cast<FrameLoader*>(argument);
     3083    loader->continueFragmentScrollAfterNavigationPolicy(request, shouldContinue);
     3084}
     3085
     3086void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
     3087{
     3088    KURL URL = request.url();
     3089   
     3090    bool isRedirect = m_quickRedirectComing;
     3091    m_quickRedirectComing = false;
     3092   
     3093    m_documentLoader->replaceRequestURLForAnchorScroll(URL);
     3094    if (!isRedirect && !shouldTreatURLAsSameAsCurrent(URL)) {
     3095        // NB: must happen after _setURL, since we add based on the current request.
     3096        // Must also happen before we openURL and displace the scroll position, since
     3097        // adding the BF item will save away scroll state.
     3098       
     3099        // NB2:  If we were loading a long, slow doc, and the user anchor nav'ed before
     3100        // it was done, currItem is now set the that slow doc, and prevItem is whatever was
     3101        // before it.  Adding the b/f item will bump the slow doc down to prevItem, even
     3102        // though its load is not yet done.  I think this all works out OK, for one because
     3103        // we have already saved away the scroll and doc state for the long slow load,
     3104        // but it's not an obvious case.
     3105
     3106        addHistoryItemForFragmentScroll();
     3107    }
     3108   
     3109    scrollToAnchor(URL);
     3110   
     3111    if (!isRedirect)
     3112        // This will clear previousItem from the rest of the frame tree that didn't
     3113        // doing any loading. We need to make a pass on this now, since for anchor nav
     3114        // we'll not go through a real load and reach Completed state.
     3115        checkLoadComplete();
     3116 
     3117    dispatchDidChangeLocationWithinPage();
     3118    m_client->didFinishLoad();
     3119}
     3120
     3121void FrameLoader::opened()
     3122{
     3123    if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
     3124        updateHistoryForClientRedirect();
     3125
     3126    if (m_documentLoader->isLoadingFromPageCache()) {
     3127        // Force a layout to update view size and thereby update scrollbars.
     3128        m_client->forceLayout();
     3129
     3130        const ResponseVector& responses = m_documentLoader->responses();
     3131        size_t count = responses.size();
     3132        for (size_t i = 0; i < count; i++) {
     3133            const ResourceResponse& response = responses[i];
     3134            // FIXME: If the WebKit client changes or cancels the request, this is not respected.
     3135            ResourceError error;
     3136            id identifier;
     3137            ResourceRequest request(response.url());
     3138            requestFromDelegate(request, identifier, error);
     3139            sendRemainingDelegateMessages(identifier, response, response.expectedContentLength(), error);
     3140        }
     3141       
     3142        m_client->loadedFromPageCache();
     3143
     3144        m_documentLoader->setPrimaryLoadComplete(true);
     3145
     3146        // FIXME: Why only this frame and not parent frames?
     3147        checkLoadCompleteForThisFrame();
     3148    }
     3149}
     3150
     3151KURL FrameLoader::dataURLBaseFromRequest(const ResourceRequest& request) const
     3152{
     3153#if PLATFORM(MAC)
     3154    if (WebDataRequestParameters* params = [request.nsURLRequest() _webDataRequestParametersForReading])
     3155        return params->baseURL;
     3156#endif
     3157    return KURL();
     3158}
     3159
     3160void FrameLoader::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request,
     3161    PassRefPtr<FormState> formState, const String& frameName)
     3162{
     3163    m_policyCheck.set(request, formState, frameName,
     3164        callContinueLoadAfterNewWindowPolicy, this);
     3165    m_client->dispatchDecidePolicyForNewWindowAction(&FrameLoader::continueAfterNewWindowPolicy,
     3166        action, request, frameName);
     3167}
     3168
     3169void FrameLoader::continueAfterNewWindowPolicy(PolicyAction policy)
     3170{
     3171    PolicyCheck check = m_policyCheck;
     3172    m_policyCheck.clear();
     3173
     3174    switch (policy) {
     3175        case PolicyIgnore:
     3176            check.clearRequest();
     3177            break;
     3178        case PolicyDownload:
     3179            m_client->startDownload(check.request());
     3180            check.clearRequest();
     3181            break;
     3182        case PolicyUse:
     3183            break;
     3184    }
     3185
     3186    check.call(policy == PolicyUse);
     3187}
     3188
     3189void FrameLoader::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
     3190    PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
     3191{
     3192    NavigationAction action = loader->triggeringAction();
     3193    if (action.isEmpty()) {
     3194        action = NavigationAction(request.url(), NavigationTypeOther);
     3195        loader->setTriggeringAction(action);
     3196    }
     3197       
     3198    // Don't ask more than once for the same request or if we are loading an empty URL.
     3199    // This avoids confusion on the part of the client.
     3200    if (request == loader->lastCheckedRequest() || request.url().isEmpty()) {
     3201        function(argument, request, 0, true);
     3202        return;
     3203    }
     3204   
     3205    // We are always willing to show alternate content for unreachable URLs;
     3206    // treat it like a reload so it maintains the right state for b/f list.
     3207#if PLATFORM(MAC)
     3208    if ([request.nsURLRequest() _webDataRequestUnreachableURL]) {
     3209        if (isBackForwardLoadType(m_policyLoadType))
     3210            m_policyLoadType = FrameLoadTypeReload;
     3211        function(argument, request, 0, true);
     3212        return;
     3213    }
     3214#endif
     3215   
     3216    loader->setLastCheckedRequest(request);
     3217
     3218    m_policyCheck.set(request, formState, function, argument);
     3219
     3220    m_delegateIsDecidingNavigationPolicy = true;
     3221    m_client->dispatchDecidePolicyForNavigationAction(&FrameLoader::continueAfterNavigationPolicy,
     3222        action, request);
     3223    m_delegateIsDecidingNavigationPolicy = false;
     3224}
     3225
     3226void FrameLoader::continueAfterNavigationPolicy(PolicyAction policy)
     3227{
     3228    PolicyCheck check = m_policyCheck;
     3229    m_policyCheck.clear();
     3230
     3231    switch (policy) {
     3232        case PolicyIgnore:
     3233            check.clearRequest();
     3234            break;
     3235        case PolicyDownload:
     3236            m_client->startDownload(check.request());
     3237            check.clearRequest();
     3238            break;
     3239        case PolicyUse: {
     3240            ResourceRequest request(check.request());
     3241            if (!m_client->canHandleRequest(request)) {
     3242                handleUnimplementablePolicy(m_client->cannotShowURLError(check.request()));
     3243                check.clearRequest();
     3244            }
     3245            break;
     3246        }
     3247    }
     3248
     3249    check.call(policy == PolicyUse);
     3250}
     3251
     3252void FrameLoader::callContinueLoadAfterNavigationPolicy(void* argument,
     3253    const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
     3254{
     3255    FrameLoader* loader = static_cast<FrameLoader*>(argument);
     3256    loader->continueLoadAfterNavigationPolicy(request, formState, shouldContinue);
     3257}
     3258
     3259void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
     3260{
     3261    // If we loaded an alternate page to replace an unreachableURL, we'll get in here with a
     3262    // nil policyDataSource because loading the alternate page will have passed
     3263    // through this method already, nested; otherwise, policyDataSource should still be set.
     3264    ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableURL().isEmpty());
     3265
     3266    bool isTargetItem = m_provisionalHistoryItem ? m_provisionalHistoryItem->isTargetItem() : false;
     3267
     3268    // Two reasons we can't continue:
     3269    //    1) Navigation policy delegate said we can't so request is nil. A primary case of this
     3270    //       is the user responding Cancel to the form repost nag sheet.
     3271    //    2) User responded Cancel to an alert popped up by the before unload event handler.
     3272    // The "before unload" event handler runs only for the main frame.
     3273    bool canContinue = shouldContinue && (!isLoadingMainFrame() || m_frame->shouldClose());
     3274
     3275    if (!canContinue) {
     3276        // If we were waiting for a quick redirect, but the policy delegate decided to ignore it, then we
     3277        // need to report that the client redirect was cancelled.
     3278        if (m_quickRedirectComing)
     3279            clientRedirectCancelledOrFinished(false);
     3280
     3281        setPolicyDocumentLoader(0);
     3282
     3283        // If the navigation request came from the back/forward menu, and we punt on it, we have the
     3284        // problem that we have optimistically moved the b/f cursor already, so move it back.  For sanity,
     3285        // we only do this when punting a navigation for the target frame or top-level frame. 
     3286        if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(m_policyLoadType) && m_frame->page()) {
     3287            Frame* mainFrame = m_frame->page()->mainFrame();
     3288            if (HistoryItem* resetItem = mainFrame->loader()->m_currentHistoryItem.get())
     3289                m_frame->page()->backForwardList()->goToItem(resetItem);
     3290        }
     3291        return;
     3292    }
     3293
     3294    FrameLoadType type = m_policyLoadType;
     3295    stopAllLoaders();
     3296    setProvisionalDocumentLoader(m_policyDocumentLoader.get());
     3297    m_loadType = type;
     3298    setState(FrameStateProvisional);
     3299
     3300    setPolicyDocumentLoader(0);
     3301
     3302    if (isBackForwardLoadType(type) && loadProvisionalItemFromPageCache())
     3303        return;
     3304
     3305    if (formState)
     3306        m_client->dispatchWillSubmitForm(&FrameLoader::continueAfterWillSubmitForm, formState);
     3307    else
     3308        continueAfterWillSubmitForm();
     3309}
     3310
     3311
     3312void FrameLoader::callContinueLoadAfterNewWindowPolicy(void* argument,
     3313    const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
     3314{
     3315    FrameLoader* loader = static_cast<FrameLoader*>(argument);
     3316    loader->continueLoadAfterNewWindowPolicy(request, formState, frameName, shouldContinue);
     3317}
     3318
     3319void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
     3320    PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
     3321{
     3322    if (!shouldContinue)
     3323        return;
     3324
     3325    RefPtr<Frame> frame = m_frame;
     3326    RefPtr<Frame> mainFrame = m_client->dispatchCreatePage();
     3327    if (!mainFrame)
     3328        return;
     3329
     3330    mainFrame->tree()->setName(frameName);
     3331    mainFrame->loader()->m_client->dispatchShow();
     3332    mainFrame->loader()->setOpener(frame.get());
     3333    mainFrame->loader()->load(request, NavigationAction(), FrameLoadTypeStandard, formState);
     3334}
     3335
     3336void FrameLoader::sendRemainingDelegateMessages(id identifier, const ResourceResponse& response, unsigned length, const ResourceError& error)
     3337{   
     3338    if (!response.isNull())
     3339        m_client->dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
     3340   
     3341    if (length > 0)
     3342        m_client->dispatchDidReceiveContentLength(m_documentLoader.get(), identifier, length);
     3343   
     3344    if (error.isNull())
     3345        m_client->dispatchDidFinishLoading(m_documentLoader.get(), identifier);
     3346    else
     3347        m_client->dispatchDidFailLoading(m_documentLoader.get(), identifier, error);
     3348}
     3349
     3350void FrameLoader::requestFromDelegate(ResourceRequest& request, id& identifier, ResourceError& error)
     3351{
     3352    ASSERT(!request.isNull());
     3353
     3354#if PLATFORM(MAC)
     3355    identifier = m_client->dispatchIdentifierForInitialRequest(m_documentLoader.get(), request);
     3356#else
     3357    identifier = 0;
     3358#endif
     3359    ResourceRequest newRequest(request);
     3360    m_client->dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, nil);
     3361
     3362    if (newRequest.isNull())
     3363        error = m_client->cancelledError(request);
     3364    else
     3365        error = ResourceError();
     3366
     3367    request = newRequest;
     3368}
     3369
     3370void FrameLoader::loadedResourceFromMemoryCache(const ResourceRequest& request, const ResourceResponse& response, int length)
     3371{
     3372    if (m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, response, length))
     3373        return;
     3374
     3375    id identifier;
     3376    ResourceError error;
     3377    ResourceRequest r(request);
     3378    requestFromDelegate(r, identifier, error);
     3379    sendRemainingDelegateMessages(identifier, response, length, error);
     3380}
     3381
     3382void FrameLoader::applyUserAgent(ResourceRequest& request)
     3383{
     3384    String userAgent = client()->userAgent();
     3385    ASSERT(!userAgent.isNull());
     3386    request.setHTTPUserAgent(userAgent);
    25223387}
    25233388
     
    31614026}
    31624027
     4028PolicyCheck::PolicyCheck()
     4029    : m_navigationFunction(0)
     4030    , m_newWindowFunction(0)
     4031    , m_contentFunction(0)
     4032{
     4033}
     4034
     4035void PolicyCheck::clear()
     4036{
     4037    clearRequest();
     4038    m_navigationFunction = 0;
     4039    m_newWindowFunction = 0;
     4040    m_contentFunction = 0;
     4041}
     4042
     4043void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
     4044    NavigationPolicyDecisionFunction function, void* argument)
     4045{
     4046    m_request = request;
     4047    m_formState = formState;
     4048    m_frameName = String();
     4049
     4050    m_navigationFunction = function;
     4051    m_newWindowFunction = 0;
     4052    m_contentFunction = 0;
     4053    m_argument = argument;
     4054}
     4055
     4056void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
     4057    const String& frameName, NewWindowPolicyDecisionFunction function, void* argument)
     4058{
     4059    m_request = request;
     4060    m_formState = formState;
     4061    m_frameName = frameName;
     4062
     4063    m_navigationFunction = 0;
     4064    m_newWindowFunction = function;
     4065    m_contentFunction = 0;
     4066    m_argument = argument;
     4067}
     4068
     4069void PolicyCheck::set(ContentPolicyDecisionFunction function, void* argument)
     4070{
     4071    m_request = ResourceRequest();
     4072    m_formState = 0;
     4073    m_frameName = String();
     4074
     4075    m_navigationFunction = 0;
     4076    m_newWindowFunction = 0;
     4077    m_contentFunction = function;
     4078    m_argument = argument;
     4079}
     4080
     4081void PolicyCheck::call(bool shouldContinue)
     4082{
     4083    if (m_navigationFunction)
     4084        m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
     4085    if (m_newWindowFunction)
     4086        m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, shouldContinue);
     4087    ASSERT(!m_contentFunction);
     4088}
     4089
     4090void PolicyCheck::call(PolicyAction action)
     4091{
     4092    ASSERT(!m_navigationFunction);
     4093    ASSERT(!m_newWindowFunction);
     4094    ASSERT(m_contentFunction);
     4095    m_contentFunction(m_argument, action);
     4096}
     4097
     4098void PolicyCheck::clearRequest()
     4099{
     4100    m_request = ResourceRequest();
     4101    m_formState = 0;
     4102    m_frameName = String();
     4103}
     4104
    31634105} // namespace WebCore
  • trunk/WebCore/loader/FrameLoader.h

    r18631 r18635  
    5757#endif // __OBJC__
    5858
     59#else
     60// FIXME: Get rid of this once we don't use id in the loader
     61typedef void* id;
    5962#endif // PLATFORM(MAC)
    6063
     
    181184#if PLATFORM(MAC)
    182185        void closeBridge();
     186#endif
    183187        void cancelMainResourceLoad(const ResourceError&);
    184 #endif
    185188        void stopAllLoaders();
    186189        void cancelMainResourceLoad();
     
    210213        static double timeOfLastCompletedLoad();
    211214
    212 #if PLATFORM(MAC)
    213215        id identifierForInitialRequest(const ResourceRequest&);
    214216        void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
     217#if PLATFORM(MAC)
    215218        void didReceiveAuthenticationChallenge(ResourceLoader*, NSURLAuthenticationChallenge *);
    216219        void didCancelAuthenticationChallenge(ResourceLoader*, NSURLAuthenticationChallenge *);
     220#endif
    217221        void didReceiveResponse(ResourceLoader*, const ResourceResponse&);
    218222        void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived);
    219 #endif
    220223        void didFinishLoad(ResourceLoader*);
    221224        void didFailToLoad(ResourceLoader*, const ResourceError&);
     
    229232        void handleFallbackContent();
    230233        bool isStopping() const;
    231 #if PLATFORM(MAC)
    232234        void setResponse(const ResourceResponse&);
    233 #endif
    234235
    235236        void finishedLoading();
     
    240241        bool willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL&) const;
    241242        bool isArchiveLoadPending(ResourceLoader*) const;
    242 #if PLATFORM(MAC)
    243243        void cannotShowMIMEType(const ResourceResponse&);
    244244        ResourceError interruptionForPolicyChangeError(const ResourceRequest&);
    245 #endif
    246245
    247246        bool isHostedByObjectElement() const;
     
    283282        bool isQuickRedirectComing() const;
    284283
    285 #if PLATFORM(MAC)
    286284        void sendRemainingDelegateMessages(id identifier, const ResourceResponse&, unsigned length, const ResourceError&);
    287285        void requestFromDelegate(ResourceRequest&, id& identifier, ResourceError&);
    288286        void loadedResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&, int length);
    289 #endif
    290287
    291288        void checkLoadComplete();
     
    506503        // Also not cool.
    507504        void startLoading();
    508 #if PLATFORM(MAC)
    509505        bool startLoadingMainResource(ResourceRequest&, id identifier);
    510 #endif
    511506        void stopLoadingSubframes();
    512507
     
    559554
    560555        bool shouldReloadToHandleUnreachableURL(const ResourceRequest&);
    561 #if PLATFORM(MAC)
    562556        void handleUnimplementablePolicy(const ResourceError&);
    563557
    564 #endif
    565558        void applyUserAgent(ResourceRequest& request);
    566559
  • trunk/WebCore/loader/FrameLoaderClient.h

    r18631 r18635  
    4040class NSURLConnection;
    4141#endif
     42#else
     43// FIXME: Get rid of this once we don't use id in the loader
     44typedef void* id;
    4245#endif
    4346
     
    8790        virtual void loadedFromPageCache() = 0;
    8891
     92        virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceResponse&) = 0;
     93
    8994#if PLATFORM(MAC)
    90         virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceResponse&) = 0;
    91 
    9295        virtual id dispatchIdentifierForInitialRequest(DocumentLoader*, const ResourceRequest&) = 0;
     96#endif
    9397        virtual void dispatchWillSendRequest(DocumentLoader*, id identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
     98#if PLATFORM(MAC)
    9499        virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, id identifier, NSURLAuthenticationChallenge *) = 0;
    95100        virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, id identifier, NSURLAuthenticationChallenge *) = 0;
     101#endif
    96102        virtual void dispatchDidReceiveResponse(DocumentLoader*, id identifier, const ResourceResponse&) = 0;
    97103        virtual void dispatchDidReceiveContentLength(DocumentLoader*, id identifier, int lengthReceived) = 0;
     
    99105        virtual void dispatchDidFailLoading(DocumentLoader*, id identifier, const ResourceError&) = 0;
    100106        virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0;
    101 #endif
    102107
    103108        virtual void dispatchDidHandleOnloadEvents() = 0;
     
    111116        virtual void dispatchDidReceiveTitle(const String& title) = 0;
    112117        virtual void dispatchDidCommitLoad() = 0;
    113 #if PLATFORM(MAC)
    114118        virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0;
    115119        virtual void dispatchDidFailLoad(const ResourceError&) = 0;
    116 #endif
    117120        virtual void dispatchDidFinishLoad() = 0;
    118121        virtual void dispatchDidFirstLayout() = 0;
    119122
    120 #if PLATFORM(MAC)
    121         virtual Frame* dispatchCreatePage(NSURLRequest *) = 0;
    122 #endif
     123        virtual Frame* dispatchCreatePage() = 0;
    123124        virtual void dispatchShow() = 0;
    124125
    125 #if PLATFORM(MAC)
    126126        virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) = 0;
    127127        virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, const String& frameName) = 0;
    128128        virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&) = 0;
    129 #endif
    130129        virtual void cancelPolicyCheck() = 0;
    131130
    132 #if PLATFORM(MAC)
    133131        virtual void dispatchUnableToImplementPolicy(const ResourceError&) = 0;
    134 #endif
    135132
    136133        virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) = 0;
     
    144141        virtual void progressCompleted() = 0;
    145142
    146 #if PLATFORM(MAC)
    147143        virtual void incrementProgress(id identifier, const ResourceResponse&) = 0;
    148144        virtual void incrementProgress(id identifier, const char*, int) = 0;
    149145        virtual void completeProgress(id identifier) = 0;
    150 #endif
    151146
    152147        virtual void setMainFrameDocumentReady(bool) = 0;
    153148
    154 #if PLATFORM(MAC)
    155149        virtual void startDownload(const ResourceRequest&) = 0;
    156 #endif
    157150
    158151        virtual void willChangeTitle(DocumentLoader*) = 0;
     
    178171        virtual void setDefersLoading(bool) = 0;
    179172
    180 #if PLATFORM(MAC)
    181173        virtual bool willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL& originalURL) const = 0;
    182 #endif
    183174        virtual bool isArchiveLoadPending(ResourceLoader*) const = 0;
    184175        virtual void cancelPendingArchiveLoad(ResourceLoader*) = 0;
  • trunk/WebCore/loader/MainResourceLoader.h

    r18606 r18635  
    4141        virtual ~MainResourceLoader();
    4242
    43 #if PLATFORM(MAC)
    4443        virtual bool load(const ResourceRequest&);
    4544        virtual void addData(const char*, int, bool allAtOnce);
    46 #endif
    4745
    4846        virtual void setDefersLoading(bool);
  • trunk/WebCore/loader/ResourceLoader.h

    r18625 r18635  
    5353#endif
    5454
     55#else
     56// FIXME: Get rid of this once we don't use id in the loader
     57typedef void* id;
    5558#endif
    5659
     
    6871        void cancel();
    6972
    70 #if PLATFORM(MAC)
    7173        virtual bool load(const ResourceRequest&);
    7274
     
    7577        virtual void cancel(const ResourceError&);
    7678        ResourceError cancelledError();
    77 #endif
    7879
    7980        virtual void setDefersLoading(bool);
     
    8283        void setIdentifier(id);
    8384        id identifier() const { return m_identifier.get(); }
     85#else
     86        void setIdentifier(id) { }
     87        id identifier() const { return 0; }
     88#endif
    8489
    8590        virtual void releaseResources();
     
    8792
    8893        virtual void addData(const char*, int, bool allAtOnce);
    89 #endif
    9094        virtual PassRefPtr<SharedBuffer> resourceData();
    9195        void clearResourceData();
  • trunk/WebCore/loader/mac/FrameLoaderMac.mm

    r18631 r18635  
    7979using namespace HTMLNames;
    8080
    81 void FrameLoader::load(const FrameLoadRequest& request, bool userGesture, Event* event,
    82     HTMLFormElement* submitForm, const HashMap<String, String>& formValues)
    83 {
    84     String referrer;
    85     String argsReferrer = request.resourceRequest().httpReferrer();
    86     if (!argsReferrer.isEmpty())
    87         referrer = argsReferrer;
    88     else
    89         referrer = m_outgoingReferrer;
    90  
    91     bool hideReferrer;
    92     if (!canLoad(request.resourceRequest().url().getNSURL(), referrer, hideReferrer))
    93         return;
    94     if (hideReferrer)
    95         referrer = String();
    96    
    97     Frame* targetFrame = m_frame->tree()->find(request.frameName());
    98     if (!canTarget(targetFrame))
    99         return;
    100        
    101     if (request.resourceRequest().httpMethod() != "POST") {
    102         FrameLoadType loadType;
    103         if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
    104             loadType = FrameLoadTypeReload;
    105         else if (!userGesture)
    106             loadType = FrameLoadTypeInternal;
    107         else
    108             loadType = FrameLoadTypeStandard;   
    109    
    110         load(request.resourceRequest().url(), referrer, loadType,
    111             request.frameName(), event, submitForm, formValues);
    112     } else
    113         post(request.resourceRequest().url(), referrer, request.frameName(),
    114             request.resourceRequest().httpBody(), request.resourceRequest().httpContentType(), event, submitForm, formValues);
    115 
    116     if (targetFrame && targetFrame != m_frame)
    117         targetFrame->page()->chrome()->focus();
    118 }
    119 
    120 void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType newLoadType,
    121     const String& frameName, Event* event, HTMLFormElement* form, const HashMap<String, String>& values)
    122 {
    123     bool isFormSubmission = !values.isEmpty();
    124    
    125     ResourceRequest request(URL);
    126     if (!referrer.isEmpty())
    127         request.setHTTPReferrer(referrer);
    128     addExtraFieldsToRequest(request, true, event || isFormSubmission);
    129     if (newLoadType == FrameLoadTypeReload)
    130         request.setCachePolicy(ReloadIgnoringCacheData);
    131 
    132     ASSERT(newLoadType != FrameLoadTypeSame);
    133 
    134     NavigationAction action(URL, newLoadType, isFormSubmission, event);
    135 
    136     RefPtr<FormState> formState;
    137     if (form && !values.isEmpty())
    138         formState = FormState::create(form, values, m_frame);
    139    
    140     if (!frameName.isEmpty()) {
    141         if (Frame* targetFrame = m_frame->tree()->find(frameName))
    142             targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, form, values);
    143         else
    144             checkNewWindowPolicy(action, request, formState.release(), frameName);
    145         return;
    146     }
    147 
    148     RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
    149 
    150     bool sameURL = shouldTreatURLAsSameAsCurrent(URL);
    151    
    152     // Make sure to do scroll to anchor processing even if the URL is
    153     // exactly the same so pages with '#' links and DHTML side effects
    154     // work properly.
    155     if (!isFormSubmission
    156         && newLoadType != FrameLoadTypeReload
    157         && newLoadType != FrameLoadTypeSame
    158         && !shouldReload(URL, url())
    159         // We don't want to just scroll if a link from within a
    160         // frameset is trying to reload the frameset into _top.
    161         && !m_frame->isFrameSet()) {
    162 
    163         // Just do anchor navigation within the existing content.
    164        
    165         // We don't do this if we are submitting a form, explicitly reloading,
    166         // currently displaying a frameset, or if the new URL does not have a fragment.
    167         // These rules are based on what KHTML was doing in KHTMLPart::openURL.
    168        
    169         // FIXME: What about load types other than Standard and Reload?
    170        
    171         oldDocumentLoader->setTriggeringAction(action);
    172         stopPolicyCheck();
    173         checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(),
    174             callContinueFragmentScrollAfterNavigationPolicy, this);
    175     } else {
    176         // must grab this now, since this load may stop the previous load and clear this flag
    177         bool isRedirect = m_quickRedirectComing;
    178         load(request, action, newLoadType, formState.release());
    179         if (isRedirect) {
    180             m_quickRedirectComing = false;
    181             if (m_provisionalDocumentLoader)
    182                 m_provisionalDocumentLoader->setIsClientRedirect(true);
    183         } else if (sameURL)
    184             // Example of this case are sites that reload the same URL with a different cookie
    185             // driving the generated content, or a master frame with links that drive a target
    186             // frame, where the user has clicked on the same link repeatedly.
    187             m_loadType = FrameLoadTypeSame;
    188     }
    189 }
    190 
    191 void FrameLoader::load(const ResourceRequest& request)
    192 {
    193     // FIXME: is this the right place to reset loadType? Perhaps this should be done after loading is finished or aborted.
    194     m_loadType = FrameLoadTypeStandard;
    195     load(m_client->createDocumentLoader(request).get());
    196 }
    197 
    198 void FrameLoader::load(const ResourceRequest& request, const String& frameName)
    199 {
    200     if (frameName.isEmpty()) {
    201         load(request);
    202         return;
    203     }
    204 
    205     Frame* frame = m_frame->tree()->find(frameName);
    206     if (frame) {
    207         frame->loader()->load(request);
    208         return;
    209     }
    210 
    211     checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), request, 0, frameName);
    212 }
    213 
    214 void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
    215 {
    216     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
    217     setPolicyDocumentLoader(loader.get());
    218 
    219     loader->setTriggeringAction(action);
    220     if (m_documentLoader)
    221         loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
    222 
    223     load(loader.get(), type, formState);
    224 }
    225 
    226 void FrameLoader::load(DocumentLoader* newDocumentLoader)
    227 {
    228     stopPolicyCheck();
    229     setPolicyDocumentLoader(newDocumentLoader);
    230 
    231     ResourceRequest& r = newDocumentLoader->request();
    232     addExtraFieldsToRequest(r, true, false);
    233     FrameLoadType type;
    234 
    235     if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {
    236         r.setCachePolicy(ReloadIgnoringCacheData);
    237         type = FrameLoadTypeSame;
    238     } else
    239         type = FrameLoadTypeStandard;
    240 
    241     if (m_documentLoader)
    242         newDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEncoding());
    243    
    244     // When we loading alternate content for an unreachable URL that we're
    245     // visiting in the b/f list, we treat it as a reload so the b/f list
    246     // is appropriately maintained.
    247     if (shouldReloadToHandleUnreachableURL(newDocumentLoader->originalRequest())) {
    248         ASSERT(type == FrameLoadTypeStandard);
    249         type = FrameLoadTypeReload;
    250     }
    251 
    252     load(newDocumentLoader, type, 0);
    253 }
    254 
    255 void FrameLoader::load(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> formState)
    256 {
    257     ASSERT(m_client->hasWebView());
    258 
    259     // Unfortunately the view must be non-nil, this is ultimately due
    260     // to parser requiring a FrameView.  We should fix this dependency.
    261 
    262     ASSERT(m_client->hasFrameView());
    263 
    264     m_policyLoadType = type;
    265 
    266     if (Frame* parent = m_frame->tree()->parent())
    267         loader->setOverrideEncoding(parent->loader()->documentLoader()->overrideEncoding());
    268 
    269     stopPolicyCheck();
    270     setPolicyDocumentLoader(loader);
    271 
    272     checkNavigationPolicy(loader->request(), loader, formState,
    273         callContinueLoadAfterNavigationPolicy, this);
    274 }
    275 
    276 bool FrameLoader::canLoad(const KURL& url, const String& referrer, bool& hideReferrer)
    277 {
    278     bool referrerIsWebURL = referrer.startsWith("http:", false) || referrer.startsWith("https:", false);
    279     bool referrerIsLocalURL = referrer.startsWith("file:", false) || referrer.startsWith("applewebdata:");
    280     bool URLIsFileURL = url.protocol().startsWith("file", false);
    281     bool referrerIsSecureURL = referrer.startsWith("https:", false);
    282     bool URLIsSecureURL = url.protocol().startsWith("https", false);
    283    
    284     hideReferrer = !referrerIsWebURL || (referrerIsSecureURL && !URLIsSecureURL);
    285     return !URLIsFileURL || referrerIsLocalURL;
    286 }
    287 
    288 bool FrameLoader::startLoadingMainResource(ResourceRequest& request, id identifier)
    289 {
    290     ASSERT(!m_mainResourceLoader);
    291     m_mainResourceLoader = MainResourceLoader::create(m_frame);
    292     m_mainResourceLoader->setIdentifier(identifier);
    293     // FIXME: is there any way the extra fields could have not been added by now?
    294     addExtraFieldsToRequest(request, true, false);
    295     if (!m_mainResourceLoader->load(request)) {
    296         // FIXME: If this should really be caught, we should just ASSERT this doesn't happen;
    297         // should it be caught by other parts of WebKit or other parts of the app?
    298         LOG_ERROR("could not create WebResourceHandle for URL %@ -- should be caught by policy handler level", request.url().getNSURL());
    299         m_mainResourceLoader = 0;
    300         return false;
    301     }
    302     return true;
    303 }
    304 
    305 // FIXME: Poor method name; also, why is this not part of startProvisionalLoad:?
    306 void FrameLoader::startLoading()
    307 {
    308     if (!m_provisionalDocumentLoader)
    309         return;
    310 
    311     m_provisionalDocumentLoader->prepareForLoadStart();
    312 
    313     if (m_mainResourceLoader)
    314         return;
    315 
    316     m_provisionalDocumentLoader->setLoadingFromPageCache(false);
    317 
    318     id identifier = m_client->dispatchIdentifierForInitialRequest
    319         (m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
    320        
    321     if (!startLoadingMainResource(m_provisionalDocumentLoader->actualRequest(), identifier))
    322         m_provisionalDocumentLoader->updateLoading();
    323 }
    324 
    325 void FrameLoader::cancelMainResourceLoad(const ResourceError& error)
    326 {
    327     m_mainResourceLoader->cancel(error);
    328 }
    329 
    330 id FrameLoader::identifierForInitialRequest(const ResourceRequest& clientRequest)
    331 {
    332     return m_client->dispatchIdentifierForInitialRequest(activeDocumentLoader(), clientRequest);
    333 }
    334 
    335 void FrameLoader::applyUserAgent(ResourceRequest& request)
    336 {
    337     String userAgent = client()->userAgent();
    338     ASSERT(!userAgent.isNull());
    339     request.setHTTPUserAgent(userAgent);
    340 }
    341 
    342 void FrameLoader::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
    343 {
    344     applyUserAgent(clientRequest);
    345     m_client->dispatchWillSendRequest(activeDocumentLoader(), loader->identifier(), clientRequest, redirectResponse);
    346 }
    347 
    348 void FrameLoader::didReceiveAuthenticationChallenge(ResourceLoader* loader, NSURLAuthenticationChallenge *currentWebChallenge)
    349 {
    350     m_client->dispatchDidReceiveAuthenticationChallenge(activeDocumentLoader(), loader->identifier(), currentWebChallenge);
    351 }
    352 
    353 void FrameLoader::didCancelAuthenticationChallenge(ResourceLoader* loader, NSURLAuthenticationChallenge *currentWebChallenge)
    354 {
    355     m_client->dispatchDidCancelAuthenticationChallenge(activeDocumentLoader(), loader->identifier(), currentWebChallenge);
    356 }
    357 
    358 void FrameLoader::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
    359 {
    360     activeDocumentLoader()->addResponse(r);
    361    
    362     m_client->incrementProgress(loader->identifier(), r);
    363     m_client->dispatchDidReceiveResponse(activeDocumentLoader(), loader->identifier(), r);
    364 }
    365 
    366 void FrameLoader::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
    367 {
    368     m_client->incrementProgress(loader->identifier(), data, length);
    369     m_client->dispatchDidReceiveContentLength(activeDocumentLoader(), loader->identifier(), lengthReceived);
    370 }
    371 
    372 void FrameLoader::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
    373 {
    374     m_client->completeProgress(loader->identifier());
    375     if (error)
    376         m_client->dispatchDidFailLoading(activeDocumentLoader(), loader->identifier(), error);
    377 }
    378 
    379 const ResourceRequest& FrameLoader::originalRequest() const
    380 {
    381     return activeDocumentLoader()->originalRequestCopy();
    382 }
    383 
    384 void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isComplete)
    385 {
    386     // Retain because the stop may release the last reference to it.
    387     RefPtr<Frame> protect(m_frame);
    388 
    389     RefPtr<DocumentLoader> loader = activeDocumentLoader();
    390    
    391     if (isComplete) {
    392         // FIXME: Don't want to do this if an entirely new load is going, so should check
    393         // that both data sources on the frame are either this or nil.
    394         stop();
    395         if (m_client->shouldFallBack(error))
    396             handleFallbackContent();
    397     }
    398    
    399     if (m_state == FrameStateProvisional) {
    400 #ifdef MULTIPLE_FORM_SUBMISSION_PROTECTION
    401         KURL failedURL = m_provisionalDocumentLoader->originalRequestCopy().url();
    402         didNotOpenURL(failedURL);
    403 #endif
    404         // We might have made a page cache item, but now we're bailing out due to an error before we ever
    405         // transitioned to the new page (before WebFrameState == commit).  The goal here is to restore any state
    406         // so that the existing view (that wenever got far enough to replace) can continue being used.
    407         Document* document = m_frame->document();
    408         if (document)
    409             document->setInPageCache(false);
    410         invalidateCurrentItemPageCache();
    411        
    412         // Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
    413         // status has changed, if there was a redirect. The frame load delegate may have saved some state about
    414         // the redirect in its -webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:. Since we are definitely
    415         // not going to use this provisional resource, as it was cancelled, notify the frame load delegate that the redirect
    416         // has ended.
    417         if (m_sentRedirectNotification)
    418             clientRedirectCancelledOrFinished(false);
    419     }
    420    
    421    
    422     loader->mainReceivedError(error, isComplete);
    423 }
    424 
    425 void FrameLoader::callContinueFragmentScrollAfterNavigationPolicy(void* argument,
    426     const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)
    427 {
    428     FrameLoader* loader = static_cast<FrameLoader*>(argument);
    429     loader->continueFragmentScrollAfterNavigationPolicy(request, shouldContinue);
    430 }
    431 
    432 void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
    433 {
    434     KURL URL = request.url();
    435    
    436     bool isRedirect = m_quickRedirectComing;
    437     m_quickRedirectComing = false;
    438    
    439     m_documentLoader->replaceRequestURLForAnchorScroll(URL);
    440     if (!isRedirect && !shouldTreatURLAsSameAsCurrent(URL)) {
    441         // NB: must happen after _setURL, since we add based on the current request.
    442         // Must also happen before we openURL and displace the scroll position, since
    443         // adding the BF item will save away scroll state.
    444        
    445         // NB2:  If we were loading a long, slow doc, and the user anchor nav'ed before
    446         // it was done, currItem is now set the that slow doc, and prevItem is whatever was
    447         // before it.  Adding the b/f item will bump the slow doc down to prevItem, even
    448         // though its load is not yet done.  I think this all works out OK, for one because
    449         // we have already saved away the scroll and doc state for the long slow load,
    450         // but it's not an obvious case.
    451 
    452         addHistoryItemForFragmentScroll();
    453     }
    454    
    455     scrollToAnchor(URL);
    456    
    457     if (!isRedirect)
    458         // This will clear previousItem from the rest of the frame tree that didn't
    459         // doing any loading. We need to make a pass on this now, since for anchor nav
    460         // we'll not go through a real load and reach Completed state.
    461         checkLoadComplete();
    462  
    463     dispatchDidChangeLocationWithinPage();
    464     m_client->didFinishLoad();
    465 }
    466 
    467 void FrameLoader::opened()
    468 {
    469     if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
    470         updateHistoryForClientRedirect();
    471 
    472     if (m_documentLoader->isLoadingFromPageCache()) {
    473         // Force a layout to update view size and thereby update scrollbars.
    474         m_client->forceLayout();
    475 
    476         const ResponseVector& responses = m_documentLoader->responses();
    477         size_t count = responses.size();
    478         for (size_t i = 0; i < count; i++) {
    479             const ResourceResponse& response = responses[i];
    480             // FIXME: If the WebKit client changes or cancels the request, this is not respected.
    481             ResourceError error;
    482             id identifier;
    483             ResourceRequest request(response.url());
    484             requestFromDelegate(request, identifier, error);
    485             sendRemainingDelegateMessages(identifier, response, response.expectedContentLength(), error);
    486         }
    487        
    488         m_client->loadedFromPageCache();
    489 
    490         m_documentLoader->setPrimaryLoadComplete(true);
    491 
    492         // FIXME: Why only this frame and not parent frames?
    493         checkLoadCompleteForThisFrame();
    494     }
    495 }
    496 
    497 KURL FrameLoader::dataURLBaseFromRequest(const ResourceRequest& request) const
    498 {
    499     if (WebDataRequestParameters* params = [request.nsURLRequest() _webDataRequestParametersForReading])
    500         return params->baseURL;
    501     return KURL();
    502 }
    503 
    504 const ResourceRequest& FrameLoader::initialRequest() const
    505 {
    506     return activeDocumentLoader()->initialRequest();
    507 }
    508 
    509 void FrameLoader::receivedData(const char* data, int length)
    510 {
    511     activeDocumentLoader()->receivedData(data, length);
    512 }
    513 
    514 void FrameLoader::setRequest(const ResourceRequest& request)
    515 {
    516     activeDocumentLoader()->setRequest(request);
    517 }
    518 
    519 void FrameLoader::setResponse(const ResourceResponse& response)
    520 {
    521     activeDocumentLoader()->setResponse(response);
    522 }
    523 
    524 bool FrameLoader::willUseArchive(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL) const
    525 {
    526     return m_client->willUseArchive(loader, request, originalURL);
    527 }
    528 
    529 void FrameLoader::handleUnimplementablePolicy(const ResourceError& error)
    530 {
    531     m_delegateIsHandlingUnimplementablePolicy = true;
    532     m_client->dispatchUnableToImplementPolicy(error);
    533     m_delegateIsHandlingUnimplementablePolicy = false;
    534 }
    535 
    536 void FrameLoader::cannotShowMIMEType(const ResourceResponse& response)
    537 {
    538     handleUnimplementablePolicy(m_client->cannotShowMIMETypeError(response));
    539 }
    540 
    541 ResourceError FrameLoader::interruptionForPolicyChangeError(const ResourceRequest& request)
    542 {
    543     return m_client->interruptForPolicyChangeError(request);
    544 }
    545 
    546 void FrameLoader::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
    547 {
    548     checkNavigationPolicy(newRequest, activeDocumentLoader(), 0, function, argument);
    549 }
    550 
    551 void FrameLoader::checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction function, void* argument)
    552 {
    553     m_policyCheck.set(function, argument);
    554     m_client->dispatchDecidePolicyForMIMEType(&FrameLoader::continueAfterContentPolicy,
    555         MIMEType, activeDocumentLoader()->request());
    556 }
    557 
    558 bool FrameLoader::shouldReloadToHandleUnreachableURL(const ResourceRequest& request)
    559 {
    560     KURL unreachableURL;
    561 #if PLATFORM(MAC)
    562     unreachableURL = [request.nsURLRequest() _webDataRequestUnreachableURL];
    563 #endif
    564 
    565     if (unreachableURL.isEmpty())
    566         return false;
    567 
    568     if (!isBackForwardLoadType(m_policyLoadType))
    569         return false;
    570 
    571     // We only treat unreachableURLs specially during the delegate callbacks
    572     // for provisional load errors and navigation policy decisions. The former
    573     // case handles well-formed URLs that can't be loaded, and the latter
    574     // case handles malformed URLs and unknown schemes. Loading alternate content
    575     // at other times behaves like a standard load.
    576     DocumentLoader* compareDocumentLoader = 0;
    577     if (m_delegateIsDecidingNavigationPolicy || m_delegateIsHandlingUnimplementablePolicy)
    578         compareDocumentLoader = m_policyDocumentLoader.get();
    579     else if (m_delegateIsHandlingProvisionalLoadError)
    580         compareDocumentLoader = m_provisionalDocumentLoader.get();
    581 
    582     return compareDocumentLoader && unreachableURL != compareDocumentLoader->request().url();
    583 }
    584 
    585 void FrameLoader::reloadAllowingStaleData(const String& encoding)
    586 {
    587     if (!m_documentLoader)
    588         return;
    589 
    590     ResourceRequest request = m_documentLoader->request();
    591     KURL unreachableURL = m_documentLoader->unreachableURL();
    592     if (!unreachableURL.isEmpty())
    593         request.setURL(unreachableURL);
    594 
    595     request.setCachePolicy(ReturnCacheDataElseLoad);
    596 
    597     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
    598     setPolicyDocumentLoader(loader.get());
    599 
    600     loader->setOverrideEncoding(encoding);
    601 
    602     load(loader.get(), FrameLoadTypeReloadAllowingStaleData, 0);
    603 }
    604 
    605 void FrameLoader::reload()
    606 {
    607     if (!m_documentLoader)
    608         return;
    609 
    610     ResourceRequest& initialRequest = m_documentLoader->request();
    611    
    612     // If a window is created by javascript, its main frame can have an empty but non-nil URL.
    613     // Reloading in this case will lose the current contents (see 4151001).
    614     if (initialRequest.url().isEmpty())
    615         return;
    616 
    617     // Replace error-page URL with the URL we were trying to reach.
    618     KURL unreachableURL;
    619 #if PLATFORM(MAC)
    620     unreachableURL = [initialRequest.nsURLRequest() _webDataRequestUnreachableURL];
    621 #endif
    622     if (!unreachableURL.isEmpty())
    623         initialRequest = ResourceRequest(unreachableURL);
    624    
    625     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest);
    626     setPolicyDocumentLoader(loader.get());
    627 
    628     ResourceRequest& request = loader->request();
    629 
    630     request.setCachePolicy(ReloadIgnoringCacheData);
    631 
    632     // If we're about to re-post, set up action so the application can warn the user.
    633     if (request.httpMethod() == "POST")
    634         loader->setTriggeringAction(NavigationAction(request.url(), NavigationTypeFormResubmitted));
    635 
    636     loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
    637    
    638     load(loader.get(), FrameLoadTypeReload, 0);
    639 }
    640 
    641 void FrameLoader::didChangeTitle(DocumentLoader* loader)
    642 {
    643     m_client->didChangeTitle(loader);
    644 
    645     // The title doesn't get communicated to the WebView until we are committed.
    646     if (loader->isCommitted())
    647         if (NSURL *urlForHistory = canonicalURL(loader->urlForHistory().getNSURL())) {
    648             // Must update the entries in the back-forward list too.
    649             // This must go through the WebFrame because it has the right notion of the current b/f item.
    650             m_client->setTitle(loader->title(), urlForHistory);
    651             m_client->setMainFrameDocumentReady(true); // update observers with new DOMDocument
    652             m_client->dispatchDidReceiveTitle(loader->title());
    653         }
    654 }
    655 
    656 void FrameLoader::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request,
    657     PassRefPtr<FormState> formState, const String& frameName)
    658 {
    659     m_policyCheck.set(request, formState, frameName,
    660         callContinueLoadAfterNewWindowPolicy, this);
    661     m_client->dispatchDecidePolicyForNewWindowAction(&FrameLoader::continueAfterNewWindowPolicy,
    662         action, request, frameName);
    663 }
    664 
    665 void FrameLoader::continueAfterNewWindowPolicy(PolicyAction policy)
    666 {
    667     PolicyCheck check = m_policyCheck;
    668     m_policyCheck.clear();
    669 
    670     switch (policy) {
    671         case PolicyIgnore:
    672             check.clearRequest();
    673             break;
    674         case PolicyDownload:
    675             m_client->startDownload(check.request());
    676             check.clearRequest();
    677             break;
    678         case PolicyUse:
    679             break;
    680     }
    681 
    682     check.call(policy == PolicyUse);
    683 }
    684 
    685 void FrameLoader::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
    686     PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
    687 {
    688     NavigationAction action = loader->triggeringAction();
    689     if (action.isEmpty()) {
    690         action = NavigationAction(request.url(), NavigationTypeOther);
    691         loader->setTriggeringAction(action);
    692     }
    693        
    694     // Don't ask more than once for the same request or if we are loading an empty URL.
    695     // This avoids confusion on the part of the client.
    696     if (request == loader->lastCheckedRequest() || request.url().isEmpty()) {
    697         function(argument, request, 0, true);
    698         return;
    699     }
    700    
    701     // We are always willing to show alternate content for unreachable URLs;
    702     // treat it like a reload so it maintains the right state for b/f list.
    703 #if PLATFORM(MAC)
    704     if ([request.nsURLRequest() _webDataRequestUnreachableURL]) {
    705         if (isBackForwardLoadType(m_policyLoadType))
    706             m_policyLoadType = FrameLoadTypeReload;
    707         function(argument, request, 0, true);
    708         return;
    709     }
    710 #endif
    711    
    712     loader->setLastCheckedRequest(request);
    713 
    714     m_policyCheck.set(request, formState, function, argument);
    715 
    716     m_delegateIsDecidingNavigationPolicy = true;
    717     m_client->dispatchDecidePolicyForNavigationAction(&FrameLoader::continueAfterNavigationPolicy,
    718         action, request);
    719     m_delegateIsDecidingNavigationPolicy = false;
    720 }
    721 
    722 void FrameLoader::continueAfterNavigationPolicy(PolicyAction policy)
    723 {
    724     PolicyCheck check = m_policyCheck;
    725     m_policyCheck.clear();
    726 
    727     switch (policy) {
    728         case PolicyIgnore:
    729             check.clearRequest();
    730             break;
    731         case PolicyDownload:
    732             m_client->startDownload(check.request());
    733             check.clearRequest();
    734             break;
    735         case PolicyUse: {
    736             ResourceRequest request(check.request());
    737             if (!m_client->canHandleRequest(request)) {
    738                 handleUnimplementablePolicy(m_client->cannotShowURLError(check.request()));
    739                 check.clearRequest();
    740             }
    741             break;
    742         }
    743     }
    744 
    745     check.call(policy == PolicyUse);
    746 }
    747 
    748 void FrameLoader::callContinueLoadAfterNavigationPolicy(void* argument,
    749     const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
    750 {
    751     FrameLoader* loader = static_cast<FrameLoader*>(argument);
    752     loader->continueLoadAfterNavigationPolicy(request, formState, shouldContinue);
    753 }
    754 
    755 void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
    756 {
    757     // If we loaded an alternate page to replace an unreachableURL, we'll get in here with a
    758     // nil policyDataSource because loading the alternate page will have passed
    759     // through this method already, nested; otherwise, policyDataSource should still be set.
    760     ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableURL().isEmpty());
    761 
    762     bool isTargetItem = m_provisionalHistoryItem ? m_provisionalHistoryItem->isTargetItem() : false;
    763 
    764     // Two reasons we can't continue:
    765     //    1) Navigation policy delegate said we can't so request is nil. A primary case of this
    766     //       is the user responding Cancel to the form repost nag sheet.
    767     //    2) User responded Cancel to an alert popped up by the before unload event handler.
    768     // The "before unload" event handler runs only for the main frame.
    769     bool canContinue = shouldContinue && (!isLoadingMainFrame() || Mac(m_frame)->shouldClose());
    770 
    771     if (!canContinue) {
    772         // If we were waiting for a quick redirect, but the policy delegate decided to ignore it, then we
    773         // need to report that the client redirect was cancelled.
    774         if (m_quickRedirectComing)
    775             clientRedirectCancelledOrFinished(false);
    776 
    777         setPolicyDocumentLoader(0);
    778 
    779         // If the navigation request came from the back/forward menu, and we punt on it, we have the
    780         // problem that we have optimistically moved the b/f cursor already, so move it back.  For sanity,
    781         // we only do this when punting a navigation for the target frame or top-level frame. 
    782         if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(m_policyLoadType) && m_frame->page()) {
    783             Frame* mainFrame = m_frame->page()->mainFrame();
    784             if (HistoryItem* resetItem = mainFrame->loader()->m_currentHistoryItem.get())
    785                 m_frame->page()->backForwardList()->goToItem(resetItem);
    786         }
    787         return;
    788     }
    789 
    790     FrameLoadType type = m_policyLoadType;
    791     stopAllLoaders();
    792     setProvisionalDocumentLoader(m_policyDocumentLoader.get());
    793     m_loadType = type;
    794     setState(FrameStateProvisional);
    795 
    796     setPolicyDocumentLoader(0);
    797 
    798     if (isBackForwardLoadType(type) && loadProvisionalItemFromPageCache())
    799         return;
    800 
    801     if (formState)
    802         m_client->dispatchWillSubmitForm(&FrameLoader::continueAfterWillSubmitForm, formState);
    803     else
    804         continueAfterWillSubmitForm();
    805 }
    806 
    80781void FrameLoader::checkLoadCompleteForThisFrame()
    80882{
     
    81993               
    82094            // If we've received any errors we may be stuck in the provisional state and actually complete.
    821             NSError *error = pdl->mainDocumentError();
    822             if (!error)
     95            const ResourceError& error = pdl->mainDocumentError();
     96            if (error.isNull())
    82397                return;
    82498
     
    874148                restoreScrollPositionAndViewState();
    875149
    876             NSError *error = dl->mainDocumentError();
    877             if (error)
     150            const ResourceError& error = dl->mainDocumentError();
     151            if (!error.isNull())
    878152                m_client->dispatchDidFailLoad(error);
    879153            else
     
    894168}
    895169
    896 void FrameLoader::callContinueLoadAfterNewWindowPolicy(void* argument,
    897     const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
    898 {
    899     FrameLoader* loader = static_cast<FrameLoader*>(argument);
    900     loader->continueLoadAfterNewWindowPolicy(request, formState, frameName, shouldContinue);
    901 }
    902 
    903 void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
    904     PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
    905 {
    906     if (!shouldContinue)
    907         return;
    908 
    909     RefPtr<Frame> frame = m_frame;
    910     RefPtr<Frame> mainFrame = m_client->dispatchCreatePage(nil);
    911     if (!mainFrame)
    912         return;
    913 
    914     mainFrame->tree()->setName(frameName);
    915     mainFrame->loader()->m_client->dispatchShow();
    916     mainFrame->loader()->setOpener(frame.get());
    917     mainFrame->loader()->load(request, NavigationAction(), FrameLoadTypeStandard, formState);
    918 }
    919 
    920 void FrameLoader::sendRemainingDelegateMessages(id identifier, const ResourceResponse& response, unsigned length, const ResourceError& error)
    921 {   
    922     if (!response.isNull())
    923         m_client->dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
    924    
    925     if (length > 0)
    926         m_client->dispatchDidReceiveContentLength(m_documentLoader.get(), identifier, length);
    927    
    928     if (!error)
    929         m_client->dispatchDidFinishLoading(m_documentLoader.get(), identifier);
    930     else
    931         m_client->dispatchDidFailLoading(m_documentLoader.get(), identifier, error);
    932 }
    933 
    934 void FrameLoader::requestFromDelegate(ResourceRequest& request, id& identifier, ResourceError& error)
    935 {
    936     ASSERT(!request.isNull());
    937 
    938     identifier = m_client->dispatchIdentifierForInitialRequest(m_documentLoader.get(), request);
    939     ResourceRequest newRequest(request);
    940     m_client->dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, nil);
    941 
    942     if (newRequest.isNull())
    943         error = m_client->cancelledError(request);
    944     else
    945         error = ResourceError();
    946 
    947     request = newRequest;
    948 }
    949 
    950 void FrameLoader::loadedResourceFromMemoryCache(const ResourceRequest& request, const ResourceResponse& response, int length)
    951 {
    952     if (m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, response, length))
    953         return;
    954 
    955     id identifier;
    956     ResourceError error;
    957     ResourceRequest r(request);
    958     requestFromDelegate(r, identifier, error);
    959     sendRemainingDelegateMessages(identifier, response, length, error);
    960 }
    961 
    962 void FrameLoader::post(const KURL& URL, const String& referrer, const String& frameName, PassRefPtr<FormData> formData,
    963     const String& contentType, Event* event, HTMLFormElement* form, const HashMap<String, String>& formValues)
    964 {
    965     // When posting, use the NSURLRequestReloadIgnoringCacheData load flag.
    966     // This prevents a potential bug which may cause a page with a form that uses itself
    967     // as an action to be returned from the cache without submitting.
    968 
    969     // FIXME: Where's the code that implements what the comment above says?
    970 
    971     ResourceRequest request(URL);
    972     addExtraFieldsToRequest(request, true, true);
    973 
    974     if (!referrer.isEmpty())
    975         request.setHTTPReferrer(referrer);
    976     request.setHTTPMethod("POST");
    977     request.setHTTPBody(formData);
    978     request.setHTTPContentType(contentType);
    979 
    980     NavigationAction action(URL, FrameLoadTypeStandard, true, event);
    981 
    982     RefPtr<FormState> formState;
    983     if (form && !formValues.isEmpty())
    984         formState = FormState::create(form, formValues, m_frame);
    985 
    986     if (!frameName.isEmpty()) {
    987         if (Frame* targetFrame = m_frame->tree()->find(frameName))
    988             targetFrame->loader()->load(request, action, FrameLoadTypeStandard, formState.release());
    989         else
    990             checkNewWindowPolicy(action, request, formState.release(), frameName);
    991     } else
    992         load(request, action, FrameLoadTypeStandard, formState.release());
    993 }
    994 
    995 bool FrameLoader::isReloading() const
    996 {
    997     return documentLoader()->request().cachePolicy() == ReloadIgnoringCacheData;
    998 }
    999 
    1000170String FrameLoader::referrer() const
    1001171{
     
    1003173}
    1004174
    1005 void FrameLoader::loadEmptyDocumentSynchronously()
    1006 {
    1007     ResourceRequest request(KURL(""));
    1008     load(request);
    1009 }
    1010 
    1011 void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, ResourceResponse& response, Vector<char>& data)
    1012 {
    1013     // Since this is a subresource, we can load any URL (we ignore the return value).
    1014     // But we still want to know whether we should hide the referrer or not, so we call the canLoad method.
    1015     String referrer = m_outgoingReferrer;
    1016     bool hideReferrer;
    1017     canLoad(request.url(), referrer, hideReferrer);
    1018     if (hideReferrer)
    1019         referrer = String();
    1020    
    1021     ResourceRequest initialRequest = request;
    1022     initialRequest.setTimeoutInterval(10);
    1023    
    1024     if (initialRequest.isConditional())
    1025         initialRequest.setCachePolicy(ReloadIgnoringCacheData);
    1026     else
    1027         initialRequest.setCachePolicy(documentLoader()->request().cachePolicy());
    1028    
    1029     if (!referrer.isEmpty())
    1030         initialRequest.setHTTPReferrer(referrer);
    1031    
    1032     initialRequest.setMainDocumentURL(m_frame->page()->mainFrame()->loader()->documentLoader()->request().url());
    1033     initialRequest.setHTTPUserAgent(client()->userAgent());
    1034    
    1035     ResourceError error;
    1036     id identifier = nil;   
    1037     ResourceRequest newRequest(initialRequest);
    1038     requestFromDelegate(newRequest, identifier, error);
    1039 
    1040     if (error.isNull()) {
    1041         ASSERT(!newRequest.isNull());
    1042         ResourceError error;
    1043        
    1044         didTellBridgeAboutLoad(newRequest.url().url());
    1045 
    1046         ResourceHandle::loadResourceSynchronously(newRequest, error, response, data);
    1047     }
    1048    
    1049     sendRemainingDelegateMessages(identifier, response, data.size(), error);
     175void FrameLoader::didReceiveAuthenticationChallenge(ResourceLoader* loader, NSURLAuthenticationChallenge *currentWebChallenge)
     176{
     177    m_client->dispatchDidReceiveAuthenticationChallenge(activeDocumentLoader(), loader->identifier(), currentWebChallenge);
     178}
     179
     180void FrameLoader::didCancelAuthenticationChallenge(ResourceLoader* loader, NSURLAuthenticationChallenge *currentWebChallenge)
     181{
     182    m_client->dispatchDidCancelAuthenticationChallenge(activeDocumentLoader(), loader->identifier(), currentWebChallenge);
     183}
     184
     185void FrameLoader::didChangeTitle(DocumentLoader* loader)
     186{
     187    m_client->didChangeTitle(loader);
     188
     189    // The title doesn't get communicated to the WebView until we are committed.
     190    if (loader->isCommitted())
     191        if (NSURL *urlForHistory = canonicalURL(loader->urlForHistory().getNSURL())) {
     192            // Must update the entries in the back-forward list too.
     193            // This must go through the WebFrame because it has the right notion of the current b/f item.
     194            m_client->setTitle(loader->title(), urlForHistory);
     195            m_client->setMainFrameDocumentReady(true); // update observers with new DOMDocument
     196            m_client->dispatchDidReceiveTitle(loader->title());
     197        }
    1050198}
    1051199
     
    1203351}
    1204352
    1205 PolicyCheck::PolicyCheck()
    1206     : m_navigationFunction(0)
    1207     , m_newWindowFunction(0)
    1208     , m_contentFunction(0)
    1209 {
    1210 }
    1211 
    1212 void PolicyCheck::clear()
    1213 {
    1214     clearRequest();
    1215     m_navigationFunction = 0;
    1216     m_newWindowFunction = 0;
    1217     m_contentFunction = 0;
    1218 }
    1219 
    1220 void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
    1221     NavigationPolicyDecisionFunction function, void* argument)
    1222 {
    1223     m_request = request;
    1224     m_formState = formState;
    1225     m_frameName = String();
    1226 
    1227     m_navigationFunction = function;
    1228     m_newWindowFunction = 0;
    1229     m_contentFunction = 0;
    1230     m_argument = argument;
    1231 }
    1232 
    1233 void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
    1234     const String& frameName, NewWindowPolicyDecisionFunction function, void* argument)
    1235 {
    1236     m_request = request;
    1237     m_formState = formState;
    1238     m_frameName = frameName;
    1239 
    1240     m_navigationFunction = 0;
    1241     m_newWindowFunction = function;
    1242     m_contentFunction = 0;
    1243     m_argument = argument;
    1244 }
    1245 
    1246 void PolicyCheck::set(ContentPolicyDecisionFunction function, void* argument)
    1247 {
    1248     m_request = ResourceRequest();
    1249     m_formState = 0;
    1250     m_frameName = String();
    1251 
    1252     m_navigationFunction = 0;
    1253     m_newWindowFunction = 0;
    1254     m_contentFunction = function;
    1255     m_argument = argument;
    1256 }
    1257 
    1258 void PolicyCheck::call(bool shouldContinue)
    1259 {
    1260     if (m_navigationFunction)
    1261         m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
    1262     if (m_newWindowFunction)
    1263         m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, shouldContinue);
    1264     ASSERT(!m_contentFunction);
    1265 }
    1266 
    1267 void PolicyCheck::call(PolicyAction action)
    1268 {
    1269     ASSERT(!m_navigationFunction);
    1270     ASSERT(!m_newWindowFunction);
    1271     ASSERT(m_contentFunction);
    1272     m_contentFunction(m_argument, action);
    1273 }
    1274 
    1275 void PolicyCheck::clearRequest()
    1276 {
    1277     m_request = ResourceRequest();
    1278     m_formState = 0;
    1279     m_frameName = String();
    1280 }
    1281 
    1282 }
     353
     354}
  • trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h

    r18610 r18635  
    171171   
    172172#if PLATFORM(MAC)
    173     virtual Frame* dispatchCreatePage(NSURLRequest *) { return 0; }
     173    virtual Frame* dispatchCreatePage() { return 0; }
    174174#endif
    175175    virtual void dispatchShow() { }
Note: See TracChangeset for help on using the changeset viewer.