Title: [160662] trunk/Source/WebKit2
Revision
160662
Author
[email protected]
Date
2013-12-16 14:17:24 -0800 (Mon, 16 Dec 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160661 => 160662)


--- trunk/Source/WebKit2/ChangeLog	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-16 22:17:24 UTC (rev 160662)
@@ -1,3 +1,33 @@
+2013-12-16  Dan Bernstein  <[email protected]>
+
+        [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.
+
 2013-12-16  Benjamin Poulain  <[email protected]>
 
         [WK2] The NetworkProcess tries to load SecItemShim.dylib on iOS

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (160661 => 160662)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-16 22:17:24 UTC (rev 160662)
@@ -94,6 +94,16 @@
         [m_controller didChangeValueForKey:@"activeURL"];
     }
 
+    virtual void willChangeHasOnlySecureContent() OVERRIDE
+    {
+        [m_controller willChangeValueForKey:@"hasOnlySecureContent"];
+    }
+
+    virtual void didChangeHasOnlySecureContent() OVERRIDE
+    {
+        [m_controller didChangeValueForKey:@"hasOnlySecureContent"];
+    }
+
     virtual void willChangeEstimatedProgress() OVERRIDE
     {
         [m_controller willChangeValueForKey:@"estimatedProgress"];
@@ -329,6 +339,11 @@
     return [NSURL _web_URLWithWTFString:_page->pageLoadState().unreachableURL()];
 }
 
+- (BOOL)hasOnlySecureContent
+{
+    return _page->pageLoadState().hasOnlySecureContent();
+}
+
 - (double)estimatedProgress
 {
     return _page->estimatedProgress();

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h (160661 => 160662)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h	2013-12-16 22:17:24 UTC (rev 160662)
@@ -43,6 +43,8 @@
 
 @property (readonly) WKPageRef _pageRef;
 
+@property (readonly) BOOL hasOnlySecureContent;
+
 @property WKBrowsingContextPaginationMode paginationMode;
 
 // Whether the column-break-{before,after} properties are respected instead of the

Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.cpp (160661 => 160662)


--- trunk/Source/WebKit2/UIProcess/PageLoadState.cpp	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/UIProcess/PageLoadState.cpp	2013-12-16 22:17:24 UTC (rev 160662)
@@ -75,6 +75,7 @@
     bool titleChanged = m_committedState.title != m_uncommittedState.title;
     bool isLoadingChanged = isLoadingState(m_committedState.state) != isLoadingState(m_uncommittedState.state);
     bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
+    bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
     bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
 
     if (titleChanged)
@@ -83,6 +84,8 @@
         callObserverCallback(&Observer::willChangeIsLoading);
     if (activeURLChanged)
         callObserverCallback(&Observer::willChangeActiveURL);
+    if (hasOnlySecureContentChanged)
+        callObserverCallback(&Observer::willChangeHasOnlySecureContent);
     if (estimatedProgressChanged)
         callObserverCallback(&Observer::willChangeEstimatedProgress);
 
@@ -91,6 +94,8 @@
     // The "did" ordering is the reverse of the "will". This is a requirement of Cocoa Key-Value Observing.
     if (estimatedProgressChanged)
         callObserverCallback(&Observer::didChangeEstimatedProgress);
+    if (hasOnlySecureContentChanged)
+        callObserverCallback(&Observer::didChangeHasOnlySecureContent);
     if (activeURLChanged)
         callObserverCallback(&Observer::didChangeActiveURL);
     if (isLoadingChanged)
@@ -104,6 +109,7 @@
     ASSERT_UNUSED(token, &token.m_pageLoadState == this);
 
     m_uncommittedState.state = State::Finished;
+    m_uncommittedState.hasInsecureContent = false;
 
     m_uncommittedState.pendingAPIRequestURL = String();
     m_uncommittedState.provisionalURL = String();
@@ -150,6 +156,19 @@
     return activeURL(m_committedState);
 }
 
+bool PageLoadState::hasOnlySecureContent(const Data& data)
+{
+    if (data.hasInsecureContent)
+        return false;
+
+    return data.url.startsWith("https:", false);
+}
+
+bool PageLoadState::hasOnlySecureContent() const
+{
+    return hasOnlySecureContent(m_committedState);
+}
+
 double PageLoadState::estimatedProgress(const Data& data)
 {
     if (!data.pendingAPIRequestURL.isNull())
@@ -217,6 +236,7 @@
     ASSERT(m_uncommittedState.state == State::Provisional);
 
     m_uncommittedState.state = State::Committed;
+    m_uncommittedState.hasInsecureContent = false;
 
     m_uncommittedState.url = ""
     m_uncommittedState.provisionalURL = String();
@@ -249,6 +269,14 @@
     m_uncommittedState.url = ""
 }
 
+void PageLoadState::didDisplayOrRunInsecureContent(const Transaction::Token& token)
+{
+    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+    ASSERT(m_uncommittedState.url.startsWith("https:", false));
+
+    m_uncommittedState.hasInsecureContent = true;
+}
+
 void PageLoadState::setUnreachableURL(const Transaction::Token& token, const String& unreachableURL)
 {
     ASSERT_UNUSED(token, &token.m_pageLoadState == this);

Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.h (160661 => 160662)


--- trunk/Source/WebKit2/UIProcess/PageLoadState.h	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/UIProcess/PageLoadState.h	2013-12-16 22:17:24 UTC (rev 160662)
@@ -54,6 +54,9 @@
         virtual void willChangeActiveURL() = 0;
         virtual void didChangeActiveURL() = 0;
 
+        virtual void willChangeHasOnlySecureContent() = 0;
+        virtual void didChangeHasOnlySecureContent() = 0;
+
         virtual void willChangeEstimatedProgress() = 0;
         virtual void didChangeEstimatedProgress() = 0;
     };
@@ -116,6 +119,8 @@
 
     String activeURL() const;
 
+    bool hasOnlySecureContent() const;
+
     double estimatedProgress() const;
 
     const String& pendingAPIRequestURL() const;
@@ -132,6 +137,8 @@
 
     void didSameDocumentNavigation(const Transaction::Token&, const String& url);
 
+    void didDisplayOrRunInsecureContent(const Transaction::Token&);
+
     void setUnreachableURL(const Transaction::Token&, const String&);
 
     const String& title() const;
@@ -154,11 +161,13 @@
     struct Data {
         Data()
             : state(State::Finished)
+            , hasInsecureContent(false)
             , estimatedProgress(0)
         {
         }
 
         State state;
+        bool hasInsecureContent;
 
         String pendingAPIRequestURL;
 
@@ -173,6 +182,7 @@
     };
 
     static String activeURL(const Data&);
+    static bool hasOnlySecureContent(const Data&);
     static double estimatedProgress(const Data&);
 
     Data m_committedState;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (160661 => 160662)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2013-12-16 22:07:18 UTC (rev 160661)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2013-12-16 22:17:24 UTC (rev 160662)
@@ -2383,6 +2383,10 @@
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
+    auto transaction = m_pageLoadState.transaction();
+    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
+
+    m_pageLoadState.commitChanges();
     m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
 }
 
@@ -2396,6 +2400,10 @@
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
+    auto transaction = m_pageLoadState.transaction();
+    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
+
+    m_pageLoadState.commitChanges();
     m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to