Changeset 77085 in webkit


Ignore:
Timestamp:
Jan 30, 2011 12:30:27 AM (13 years ago)
Author:
mjs@apple.com
Message:

2011-01-29 Maciej Stachowiak <mjs@apple.com>

Reviewed by Geoffrey Garen.

Add WKPageCopyPendingAPIRequestURL API
https://bugs.webkit.org/show_bug.cgi?id=53383

This API returns the last URL requested for load via API, if neither that load nor any
other load subsequently reaches the provisional state.


This is useful to be able to track loads initiated via the API


  • UIProcess/API/C/WKPage.cpp: (WKPageCopyPendingAPIRequestURL): Retrieve the pending URL.
  • UIProcess/API/C/WKPage.h:
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::loadURL): Set pending URL. (WebKit::WebPageProxy::loadURLRequest): ditto (WebKit::WebPageProxy::reload): ditto (WebKit::WebPageProxy::goForward): ditto (WebKit::WebPageProxy::goBack): ditto (WebKit::WebPageProxy::estimatedProgress): Assume the initial progress value when there is a pending URL. (WebKit::WebPageProxy::didStartProvisionalLoadForFrame): Clear pending URL; clients should look at the provisional URL now. (WebKit::WebPageProxy::decidePolicyForNavigationAction): Clear pending URL if it doesn't match the policy URL; this means we were interrupted by another load.
  • UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::pendingAPIRequestURL): Helper function. (WebKit::WebPageProxy::clearPendingAPIRequestURL): ditto (WebKit::WebPageProxy::setPendingAPIRequestURL): ditto
Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r77055 r77085  
     12011-01-29  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Add WKPageCopyPendingAPIRequestURL API
     6        https://bugs.webkit.org/show_bug.cgi?id=53383
     7
     8        This API returns the last URL requested for load via API, if neither that load nor any
     9        other load subsequently reaches the provisional state.
     10       
     11        This is useful to be able to track loads initiated via the API
     12       
     13        * UIProcess/API/C/WKPage.cpp:
     14        (WKPageCopyPendingAPIRequestURL): Retrieve the pending URL.
     15        * UIProcess/API/C/WKPage.h:
     16        * UIProcess/WebPageProxy.cpp:
     17        (WebKit::WebPageProxy::loadURL): Set pending URL.
     18        (WebKit::WebPageProxy::loadURLRequest): ditto
     19        (WebKit::WebPageProxy::reload): ditto
     20        (WebKit::WebPageProxy::goForward): ditto
     21        (WebKit::WebPageProxy::goBack): ditto
     22        (WebKit::WebPageProxy::estimatedProgress): Assume the initial
     23        progress value when there is a pending URL.
     24        (WebKit::WebPageProxy::didStartProvisionalLoadForFrame): Clear
     25        pending URL; clients should look at the provisional URL now.
     26        (WebKit::WebPageProxy::decidePolicyForNavigationAction): Clear
     27        pending URL if it doesn't match the policy URL; this means we
     28        were interrupted by another load.
     29        * UIProcess/WebPageProxy.h:
     30        (WebKit::WebPageProxy::pendingAPIRequestURL): Helper function.
     31        (WebKit::WebPageProxy::clearPendingAPIRequestURL): ditto
     32        (WebKit::WebPageProxy::setPendingAPIRequestURL): ditto
     33
    1342011-01-28  Jon Honeycutt  <jhoneycutt@apple.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r76916 r77085  
    436436    toImpl(pageRef)->forceRepaint(VoidCallback::create(context, callback));
    437437}
     438
     439WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)
     440{
     441    if (toImpl(pageRef)->pendingAPIRequestURL().isNull())
     442        return 0;
     443    return toCopiedURLAPI(toImpl(pageRef)->pendingAPIRequestURL());
     444}
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.h

    r76452 r77085  
    345345WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
    346346
     347WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
     348
    347349#ifdef __cplusplus
    348350}
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r77054 r77085  
    321321void WebPageProxy::loadURL(const String& url)
    322322{
     323    setPendingAPIRequestURL(url);
     324
    323325    if (!isValid())
    324326        reattachToWebProcess();
     
    331333void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
    332334{
     335    setPendingAPIRequestURL(urlRequest->resourceRequest().url());
     336
    333337    if (!isValid())
    334338        reattachToWebProcess();
     
    374378void WebPageProxy::reload(bool reloadFromOrigin)
    375379{
     380    setPendingAPIRequestURL(m_backForwardList->currentItem()->url());
     381
    376382    if (!isValid()) {
    377383        reattachToWebProcessWithItem(m_backForwardList->currentItem());
     
    384390void WebPageProxy::goForward()
    385391{
     392    if (isValid() && !canGoForward())
     393        return;
     394
     395    setPendingAPIRequestURL(m_backForwardList->forwardItem()->url());
     396
    386397    if (!isValid()) {
    387398        reattachToWebProcessWithItem(m_backForwardList->forwardItem());
     
    389400    }
    390401
    391     if (!canGoForward())
    392         return;
    393 
    394402    process()->send(Messages::WebPage::GoForward(m_backForwardList->forwardItem()->itemID()), m_pageID);
    395403}
     
    402410void WebPageProxy::goBack()
    403411{
     412    if (isValid() && !canGoBack())
     413        return;
     414
     415    setPendingAPIRequestURL(m_backForwardList->backItem()->url());
     416
    404417    if (!isValid()) {
    405418        reattachToWebProcessWithItem(m_backForwardList->backItem());
    406419        return;
    407420    }
    408 
    409     if (!canGoBack())
    410         return;
    411421
    412422    process()->send(Messages::WebPage::GoBack(m_backForwardList->backItem()->itemID()), m_pageID);
     
    11811191static const double initialProgressValue = 0.1;
    11821192
     1193double WebPageProxy::estimatedProgress() const
     1194{
     1195    if (!pendingAPIRequestURL().isNull())
     1196        return initialProgressValue;
     1197    return m_estimatedProgress;
     1198}
     1199
    11831200void WebPageProxy::didStartProgress()
    11841201{
     
    12041221void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, bool loadingSubstituteDataForUnreachableURL, CoreIPC::ArgumentDecoder* arguments)
    12051222{
     1223    clearPendingAPIRequestURL();
     1224
    12061225    RefPtr<APIObject> userData;
    12071226    WebContextUserMessageDecoder messageDecoder(userData, context());
     
    14301449void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID)
    14311450{
     1451    if (url != pendingAPIRequestURL())
     1452        clearPendingAPIRequestURL();
     1453
    14321454    WebFrameProxy* frame = process()->webFrame(frameID);
    14331455    MESSAGE_CHECK(frame);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r77054 r77085  
    241241    String customTextEncodingName() const { return m_customTextEncodingName; }
    242242
    243     double estimatedProgress() const { return m_estimatedProgress; }
     243    double estimatedProgress() const;
    244244
    245245    void terminateProcess();
     
    372372    void drawPagesToPDF(WebFrameProxy*, uint32_t first, uint32_t count, PassRefPtr<DataCallback>);
    373373#endif
     374
     375    const String& pendingAPIRequestURL() const { return m_pendingAPIRequestURL; }
    374376
    375377private:
     
    545547    static String standardUserAgent(const String& applicationName = String());
    546548
     549    void clearPendingAPIRequestURL() { m_pendingAPIRequestURL = String(); }
     550    void setPendingAPIRequestURL(const String& pendingAPIRequestURL) { m_pendingAPIRequestURL = pendingAPIRequestURL; }
     551
    547552    PageClient* m_pageClient;
    548553    WebLoaderClient m_loaderClient;
     
    644649    bool m_mainFrameHasCustomRepresentation;
    645650    WebCore::DragOperation m_currentDragOperation;
     651
     652    String m_pendingAPIRequestURL;
    646653};
    647654
Note: See TracChangeset for help on using the changeset viewer.