<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160662] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160662">160662</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2013-12-16 14:17:24 -0800 (Mon, 16 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllermm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllerPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageLoadStatecpp">trunk/Source/WebKit2/UIProcess/PageLoadState.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageLoadStateh">trunk/Source/WebKit2/UIProcess/PageLoadState.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2013-12-16  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2013-12-16  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] The NetworkProcess tries to load SecItemShim.dylib on iOS
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -94,6 +94,16 @@
</span><span class="cx">         [m_controller didChangeValueForKey:@&quot;activeURL&quot;];
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    virtual void willChangeHasOnlySecureContent() OVERRIDE
+    {
+        [m_controller willChangeValueForKey:@&quot;hasOnlySecureContent&quot;];
+    }
+
+    virtual void didChangeHasOnlySecureContent() OVERRIDE
+    {
+        [m_controller didChangeValueForKey:@&quot;hasOnlySecureContent&quot;];
+    }
+
</ins><span class="cx">     virtual void willChangeEstimatedProgress() OVERRIDE
</span><span class="cx">     {
</span><span class="cx">         [m_controller willChangeValueForKey:@&quot;estimatedProgress&quot;];
</span><span class="lines">@@ -329,6 +339,11 @@
</span><span class="cx">     return [NSURL _web_URLWithWTFString:_page-&gt;pageLoadState().unreachableURL()];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)hasOnlySecureContent
+{
+    return _page-&gt;pageLoadState().hasOnlySecureContent();
+}
+
</ins><span class="cx"> - (double)estimatedProgress
</span><span class="cx"> {
</span><span class="cx">     return _page-&gt;estimatedProgress();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKBrowsingContextControllerPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextControllerPrivate.h (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> 
</span><span class="cx"> @property (readonly) WKPageRef _pageRef;
</span><span class="cx"> 
</span><ins>+@property (readonly) BOOL hasOnlySecureContent;
+
</ins><span class="cx"> @property WKBrowsingContextPaginationMode paginationMode;
</span><span class="cx"> 
</span><span class="cx"> // Whether the column-break-{before,after} properties are respected instead of the
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageLoadStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.cpp (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">     bool titleChanged = m_committedState.title != m_uncommittedState.title;
</span><span class="cx">     bool isLoadingChanged = isLoadingState(m_committedState.state) != isLoadingState(m_uncommittedState.state);
</span><span class="cx">     bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
</span><ins>+    bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
</ins><span class="cx">     bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
</span><span class="cx"> 
</span><span class="cx">     if (titleChanged)
</span><span class="lines">@@ -83,6 +84,8 @@
</span><span class="cx">         callObserverCallback(&amp;Observer::willChangeIsLoading);
</span><span class="cx">     if (activeURLChanged)
</span><span class="cx">         callObserverCallback(&amp;Observer::willChangeActiveURL);
</span><ins>+    if (hasOnlySecureContentChanged)
+        callObserverCallback(&amp;Observer::willChangeHasOnlySecureContent);
</ins><span class="cx">     if (estimatedProgressChanged)
</span><span class="cx">         callObserverCallback(&amp;Observer::willChangeEstimatedProgress);
</span><span class="cx"> 
</span><span class="lines">@@ -91,6 +94,8 @@
</span><span class="cx">     // The &quot;did&quot; ordering is the reverse of the &quot;will&quot;. This is a requirement of Cocoa Key-Value Observing.
</span><span class="cx">     if (estimatedProgressChanged)
</span><span class="cx">         callObserverCallback(&amp;Observer::didChangeEstimatedProgress);
</span><ins>+    if (hasOnlySecureContentChanged)
+        callObserverCallback(&amp;Observer::didChangeHasOnlySecureContent);
</ins><span class="cx">     if (activeURLChanged)
</span><span class="cx">         callObserverCallback(&amp;Observer::didChangeActiveURL);
</span><span class="cx">     if (isLoadingChanged)
</span><span class="lines">@@ -104,6 +109,7 @@
</span><span class="cx">     ASSERT_UNUSED(token, &amp;token.m_pageLoadState == this);
</span><span class="cx"> 
</span><span class="cx">     m_uncommittedState.state = State::Finished;
</span><ins>+    m_uncommittedState.hasInsecureContent = false;
</ins><span class="cx"> 
</span><span class="cx">     m_uncommittedState.pendingAPIRequestURL = String();
</span><span class="cx">     m_uncommittedState.provisionalURL = String();
</span><span class="lines">@@ -150,6 +156,19 @@
</span><span class="cx">     return activeURL(m_committedState);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PageLoadState::hasOnlySecureContent(const Data&amp; data)
+{
+    if (data.hasInsecureContent)
+        return false;
+
+    return data.url.startsWith(&quot;https:&quot;, false);
+}
+
+bool PageLoadState::hasOnlySecureContent() const
+{
+    return hasOnlySecureContent(m_committedState);
+}
+
</ins><span class="cx"> double PageLoadState::estimatedProgress(const Data&amp; data)
</span><span class="cx"> {
</span><span class="cx">     if (!data.pendingAPIRequestURL.isNull())
</span><span class="lines">@@ -217,6 +236,7 @@
</span><span class="cx">     ASSERT(m_uncommittedState.state == State::Provisional);
</span><span class="cx"> 
</span><span class="cx">     m_uncommittedState.state = State::Committed;
</span><ins>+    m_uncommittedState.hasInsecureContent = false;
</ins><span class="cx"> 
</span><span class="cx">     m_uncommittedState.url = m_uncommittedState.provisionalURL;
</span><span class="cx">     m_uncommittedState.provisionalURL = String();
</span><span class="lines">@@ -249,6 +269,14 @@
</span><span class="cx">     m_uncommittedState.url = url;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageLoadState::didDisplayOrRunInsecureContent(const Transaction::Token&amp; token)
+{
+    ASSERT_UNUSED(token, &amp;token.m_pageLoadState == this);
+    ASSERT(m_uncommittedState.url.startsWith(&quot;https:&quot;, false));
+
+    m_uncommittedState.hasInsecureContent = true;
+}
+
</ins><span class="cx"> void PageLoadState::setUnreachableURL(const Transaction::Token&amp; token, const String&amp; unreachableURL)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(token, &amp;token.m_pageLoadState == this);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageLoadStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.h (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -54,6 +54,9 @@
</span><span class="cx">         virtual void willChangeActiveURL() = 0;
</span><span class="cx">         virtual void didChangeActiveURL() = 0;
</span><span class="cx"> 
</span><ins>+        virtual void willChangeHasOnlySecureContent() = 0;
+        virtual void didChangeHasOnlySecureContent() = 0;
+
</ins><span class="cx">         virtual void willChangeEstimatedProgress() = 0;
</span><span class="cx">         virtual void didChangeEstimatedProgress() = 0;
</span><span class="cx">     };
</span><span class="lines">@@ -116,6 +119,8 @@
</span><span class="cx"> 
</span><span class="cx">     String activeURL() const;
</span><span class="cx"> 
</span><ins>+    bool hasOnlySecureContent() const;
+
</ins><span class="cx">     double estimatedProgress() const;
</span><span class="cx"> 
</span><span class="cx">     const String&amp; pendingAPIRequestURL() const;
</span><span class="lines">@@ -132,6 +137,8 @@
</span><span class="cx"> 
</span><span class="cx">     void didSameDocumentNavigation(const Transaction::Token&amp;, const String&amp; url);
</span><span class="cx"> 
</span><ins>+    void didDisplayOrRunInsecureContent(const Transaction::Token&amp;);
+
</ins><span class="cx">     void setUnreachableURL(const Transaction::Token&amp;, const String&amp;);
</span><span class="cx"> 
</span><span class="cx">     const String&amp; title() const;
</span><span class="lines">@@ -154,11 +161,13 @@
</span><span class="cx">     struct Data {
</span><span class="cx">         Data()
</span><span class="cx">             : state(State::Finished)
</span><ins>+            , hasInsecureContent(false)
</ins><span class="cx">             , estimatedProgress(0)
</span><span class="cx">         {
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         State state;
</span><ins>+        bool hasInsecureContent;
</ins><span class="cx"> 
</span><span class="cx">         String pendingAPIRequestURL;
</span><span class="cx"> 
</span><span class="lines">@@ -173,6 +182,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     static String activeURL(const Data&amp;);
</span><ins>+    static bool hasOnlySecureContent(const Data&amp;);
</ins><span class="cx">     static double estimatedProgress(const Data&amp;);
</span><span class="cx"> 
</span><span class="cx">     Data m_committedState;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (160661 => 160662)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2383,6 +2383,10 @@
</span><span class="cx">     WebFrameProxy* frame = m_process-&gt;webFrame(frameID);
</span><span class="cx">     MESSAGE_CHECK(frame);
</span><span class="cx"> 
</span><ins>+    auto transaction = m_pageLoadState.transaction();
+    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
+
+    m_pageLoadState.commitChanges();
</ins><span class="cx">     m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2396,6 +2400,10 @@
</span><span class="cx">     WebFrameProxy* frame = m_process-&gt;webFrame(frameID);
</span><span class="cx">     MESSAGE_CHECK(frame);
</span><span class="cx"> 
</span><ins>+    auto transaction = m_pageLoadState.transaction();
+    m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
+
+    m_pageLoadState.commitChanges();
</ins><span class="cx">     m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>