Changeset 160662 in webkit


Ignore:
Timestamp:
Dec 16, 2013 2:17:24 PM (10 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Expose whether the page contains only secure content
https://bugs.webkit.org/show_bug.cgi?id=125758

Reviewed by Anders Carlsson.

  • UIProcess/API/Cocoa/WKBrowsingContextController.mm:

(-[WKBrowsingContextController hasOnlySecureContent]): Added a getter that calls
PageLoadState::hasOnlySecureContent.

  • UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h: Declared new property.
  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::commitChanges): Notify observers of hasOnlySecureContent() changes.
(WebKit::PageLoadState::reset): Reset hasInsecureContent in the uncommitted state.
(WebKit::PageLoadState::hasOnlySecureContent): Added. Returns true if there is no insecure
content and the URL is an HTTPS URL.
(WebKit::PageLoadState::didCommitLoad): Set hasInsecureContent to false in the uncommitted
state.
(WebKit::PageLoadState::didDisplayOrRunInsecureContent): Set hasInsecureContent to true in
the uncommitted state.

  • UIProcess/PageLoadState.h:

(WebKit::PageLoadState::Data::Data): Added hasInsecureContent member.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didDisplayInsecureContentForFrame): Call
PageLoadState::didDisplayOrRunInsecureContent and commit the change before calling out to
the client.
(WebKit::WebPageProxy::didRunInsecureContentForFrame): Ditto.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160661 r160662  
     12013-12-16  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Expose whether the page contains only secure content
     4        https://bugs.webkit.org/show_bug.cgi?id=125758
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
     9        (-[WKBrowsingContextController hasOnlySecureContent]): Added a getter that calls
     10        PageLoadState::hasOnlySecureContent.
     11        * UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h: Declared new property.
     12
     13        * UIProcess/PageLoadState.cpp:
     14        (WebKit::PageLoadState::commitChanges): Notify observers of hasOnlySecureContent() changes.
     15        (WebKit::PageLoadState::reset): Reset hasInsecureContent in the uncommitted state.
     16        (WebKit::PageLoadState::hasOnlySecureContent): Added. Returns true if there is no insecure
     17        content and the URL is an HTTPS URL.
     18        (WebKit::PageLoadState::didCommitLoad): Set hasInsecureContent to false in the uncommitted
     19        state.
     20        (WebKit::PageLoadState::didDisplayOrRunInsecureContent): Set hasInsecureContent to true in
     21        the uncommitted state.
     22        * UIProcess/PageLoadState.h:
     23        (WebKit::PageLoadState::Data::Data): Added hasInsecureContent member.
     24
     25        * UIProcess/WebPageProxy.cpp:
     26        (WebKit::WebPageProxy::didDisplayInsecureContentForFrame): Call
     27        PageLoadState::didDisplayOrRunInsecureContent and commit the change before calling out to
     28        the client.
     29        (WebKit::WebPageProxy::didRunInsecureContentForFrame): Ditto.
     30
    1312013-12-16  Benjamin Poulain  <bpoulain@apple.com>
    232
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm

    r160653 r160662  
    9595    }
    9696
     97    virtual void willChangeHasOnlySecureContent() OVERRIDE
     98    {
     99        [m_controller willChangeValueForKey:@"hasOnlySecureContent"];
     100    }
     101
     102    virtual void didChangeHasOnlySecureContent() OVERRIDE
     103    {
     104        [m_controller didChangeValueForKey:@"hasOnlySecureContent"];
     105    }
     106
    97107    virtual void willChangeEstimatedProgress() OVERRIDE
    98108    {
     
    328338{
    329339    return [NSURL _web_URLWithWTFString:_page->pageLoadState().unreachableURL()];
     340}
     341
     342- (BOOL)hasOnlySecureContent
     343{
     344    return _page->pageLoadState().hasOnlySecureContent();
    330345}
    331346
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h

    r159874 r160662  
    4444@property (readonly) WKPageRef _pageRef;
    4545
     46@property (readonly) BOOL hasOnlySecureContent;
     47
    4648@property WKBrowsingContextPaginationMode paginationMode;
    4749
  • trunk/Source/WebKit2/UIProcess/PageLoadState.cpp

    r160405 r160662  
    7676    bool isLoadingChanged = isLoadingState(m_committedState.state) != isLoadingState(m_uncommittedState.state);
    7777    bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
     78    bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
    7879    bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
    7980
     
    8485    if (activeURLChanged)
    8586        callObserverCallback(&Observer::willChangeActiveURL);
     87    if (hasOnlySecureContentChanged)
     88        callObserverCallback(&Observer::willChangeHasOnlySecureContent);
    8689    if (estimatedProgressChanged)
    8790        callObserverCallback(&Observer::willChangeEstimatedProgress);
     
    9295    if (estimatedProgressChanged)
    9396        callObserverCallback(&Observer::didChangeEstimatedProgress);
     97    if (hasOnlySecureContentChanged)
     98        callObserverCallback(&Observer::didChangeHasOnlySecureContent);
    9499    if (activeURLChanged)
    95100        callObserverCallback(&Observer::didChangeActiveURL);
     
    105110
    106111    m_uncommittedState.state = State::Finished;
     112    m_uncommittedState.hasInsecureContent = false;
    107113
    108114    m_uncommittedState.pendingAPIRequestURL = String();
     
    151157}
    152158
     159bool PageLoadState::hasOnlySecureContent(const Data& data)
     160{
     161    if (data.hasInsecureContent)
     162        return false;
     163
     164    return data.url.startsWith("https:", false);
     165}
     166
     167bool PageLoadState::hasOnlySecureContent() const
     168{
     169    return hasOnlySecureContent(m_committedState);
     170}
     171
    153172double PageLoadState::estimatedProgress(const Data& data)
    154173{
     
    218237
    219238    m_uncommittedState.state = State::Committed;
     239    m_uncommittedState.hasInsecureContent = false;
    220240
    221241    m_uncommittedState.url = m_uncommittedState.provisionalURL;
     
    248268
    249269    m_uncommittedState.url = url;
     270}
     271
     272void PageLoadState::didDisplayOrRunInsecureContent(const Transaction::Token& token)
     273{
     274    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
     275    ASSERT(m_uncommittedState.url.startsWith("https:", false));
     276
     277    m_uncommittedState.hasInsecureContent = true;
    250278}
    251279
  • trunk/Source/WebKit2/UIProcess/PageLoadState.h

    r160405 r160662  
    5454        virtual void willChangeActiveURL() = 0;
    5555        virtual void didChangeActiveURL() = 0;
     56
     57        virtual void willChangeHasOnlySecureContent() = 0;
     58        virtual void didChangeHasOnlySecureContent() = 0;
    5659
    5760        virtual void willChangeEstimatedProgress() = 0;
     
    117120    String activeURL() const;
    118121
     122    bool hasOnlySecureContent() const;
     123
    119124    double estimatedProgress() const;
    120125
     
    132137
    133138    void didSameDocumentNavigation(const Transaction::Token&, const String& url);
     139
     140    void didDisplayOrRunInsecureContent(const Transaction::Token&);
    134141
    135142    void setUnreachableURL(const Transaction::Token&, const String&);
     
    155162        Data()
    156163            : state(State::Finished)
     164            , hasInsecureContent(false)
    157165            , estimatedProgress(0)
    158166        {
     
    160168
    161169        State state;
     170        bool hasInsecureContent;
    162171
    163172        String pendingAPIRequestURL;
     
    174183
    175184    static String activeURL(const Data&);
     185    static bool hasOnlySecureContent(const Data&);
    176186    static double estimatedProgress(const Data&);
    177187
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r160653 r160662  
    23842384    MESSAGE_CHECK(frame);
    23852385
     2386    auto transaction = m_pageLoadState.transaction();
     2387    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
     2388
     2389    m_pageLoadState.commitChanges();
    23862390    m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
    23872391}
     
    23972401    MESSAGE_CHECK(frame);
    23982402
     2403    auto transaction = m_pageLoadState.transaction();
     2404    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
     2405
     2406    m_pageLoadState.commitChanges();
    23992407    m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
    24002408}
Note: See TracChangeset for help on using the changeset viewer.