Title: [149646] trunk/Source/WebKit2
Revision
149646
Author
[email protected]
Date
2013-05-06 15:49:17 -0700 (Mon, 06 May 2013)

Log Message

        <rdar://problem/13479806> [Mac] Pass information about open pages to LaunchServices
        https://bugs.webkit.org/show_bug.cgi?id=115665

        Reviewed by Darin Adler.

        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::didCommitLoad): Moved repeated
        check for frame->isMainFrame() to the top, matching oter similar functions.
        Call updateActivePages().

        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::networkProcessConnectionClosed): Removed an obsolete FIXME.
        (WebKit::WebProcess::updateActivePages): Empty implementation for platforms
        that don't need to do anything here.

        * WebProcess/WebProcess.h: Added updateActivePages().

        * WebProcess/mac/WebProcessMac.mm: (WebKit::WebProcess::updateActivePages):
        Collect user visible origins of pages in the process and pass them to LS.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (149645 => 149646)


--- trunk/Source/WebKit2/ChangeLog	2013-05-06 22:47:26 UTC (rev 149645)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-06 22:49:17 UTC (rev 149646)
@@ -1,3 +1,24 @@
+2013-05-06  Alexey Proskuryakov  <[email protected]>
+
+        <rdar://problem/13479806> [Mac] Pass information about open pages to LaunchServices
+        https://bugs.webkit.org/show_bug.cgi?id=115665
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::didCommitLoad): Moved repeated
+        check for frame->isMainFrame() to the top, matching oter similar functions.
+        Call updateActivePages().
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::networkProcessConnectionClosed): Removed an obsolete FIXME.
+        (WebKit::WebProcess::updateActivePages): Empty implementation for platforms
+        that don't need to do anything here.
+
+        * WebProcess/WebProcess.h: Added updateActivePages().
+
+        * WebProcess/mac/WebProcessMac.mm: (WebKit::WebProcess::updateActivePages):
+        Collect user visible origins of pages in the process and pass them to LS.
+
 2013-05-06  Mark Rowe  <[email protected]>
 
         <rdar://problem/13775921> Switch off a deprecated API.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (149645 => 149646)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-05-06 22:47:26 UTC (rev 149645)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-05-06 22:49:17 UTC (rev 149646)
@@ -3952,22 +3952,26 @@
 
 void WebPage::didCommitLoad(WebFrame* frame)
 {
+    if (!frame->isMainFrame())
+        return;
+
     // If previous URL is invalid, then it's not a real page that's being navigated away from.
     // Most likely, this is actually the first load to be committed in this page.
-    if (frame->isMainFrame() && frame->coreFrame()->loader()->previousURL().isValid())
+    if (frame->coreFrame()->loader()->previousURL().isValid())
         reportUsedFeatures();
 
     // Only restore the scale factor for standard frame loads (of the main frame).
-    if (frame->isMainFrame() && frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) {
+    if (frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) {
         Page* page = frame->coreFrame()->page();
         if (page && page->pageScaleFactor() != 1)
             scalePage(1, IntPoint());
     }
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
-    if (frame->isMainFrame())
-        resetPrimarySnapshottedPlugIn();
+    resetPrimarySnapshottedPlugIn();
 #endif
+
+    WebProcess::shared().updateActivePages();
 }
 
 void WebPage::didFinishLoad(WebFrame* frame)

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (149645 => 149646)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-05-06 22:47:26 UTC (rev 149645)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-05-06 22:49:17 UTC (rev 149646)
@@ -1033,8 +1033,6 @@
 
 void WebProcess::networkProcessConnectionClosed(NetworkProcessConnection* connection)
 {
-    // FIXME (NetworkProcess): How do we handle not having the connection when the WebProcess needs it?
-    // If the NetworkProcess crashed, for example.  Do we respawn it?
     ASSERT(m_networkProcessConnection);
     ASSERT(m_networkProcessConnection == connection);
 
@@ -1123,6 +1121,11 @@
 void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters&)
 {
 }
+
+void WebProcess::updateActivePages()
+{
+}
+
 #endif
     
 void WebProcess::pageDidEnterWindow(WebPage*)

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (149645 => 149646)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2013-05-06 22:47:26 UTC (rev 149645)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2013-05-06 22:49:17 UTC (rev 149646)
@@ -184,9 +184,11 @@
     
     void pageDidEnterWindow(WebPage*);
     void pageWillLeaveWindow(WebPage*);
-    
+
     void nonVisibleProcessCleanupTimerFired(WebCore::Timer<WebProcess>*);
 
+    void updateActivePages();
+
 private:
     WebProcess();
 

Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm (149645 => 149646)


--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2013-05-06 22:47:26 UTC (rev 149645)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2013-05-06 22:49:17 UTC (rev 149646)
@@ -30,6 +30,7 @@
 #import "SandboxExtension.h"
 #import "SandboxInitializationParameters.h"
 #import "WKFullKeyboardAccessWatcher.h"
+#import "WebFrame.h"
 #import "WebInspector.h"
 #import "WebPage.h"
 #import "WebProcessCreationParameters.h"
@@ -39,6 +40,7 @@
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/MemoryCache.h>
 #import <WebCore/PageCache.h>
+#import <WebCore/WebCoreNSURLExtras.h>
 #import <WebKitSystemInterface.h>
 #import <algorithm>
 #import <dispatch/dispatch.h>
@@ -55,6 +57,8 @@
 using namespace WebCore;
 using namespace std;
 
+const CFStringRef kLSActivePageUserVisibleOriginsKey = CFSTR("LSActivePageUserVisibleOriginsKey");
+
 namespace WebKit {
 
 static uint64_t memorySize()
@@ -220,4 +224,25 @@
     ChildProcess::initializeSandbox(parameters, sandboxParameters);
 }
 
+void WebProcess::updateActivePages()
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    RetainPtr<CFMutableArrayRef> activePageURLs = adoptCF(CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
+    for (const auto& iter: m_pageMap) {
+        WebPage* page = iter.value.get();
+        WebFrame* mainFrame = page->mainWebFrame();
+        if (!mainFrame)
+            continue;
+        String mainFrameOriginString;
+        RefPtr<SecurityOrigin> mainFrameOrigin = SecurityOrigin::createFromString(mainFrame->url());
+        if (!mainFrameOrigin->isUnique())
+            mainFrameOriginString = mainFrameOrigin->toRawString();
+        else
+            mainFrameOriginString = KURL(KURL(), mainFrame->url()).protocol() + ':'; // toRawString() is not supposed to work with unique origins, and would just return "://".
+        CFArrayAppendValue(activePageURLs.get(), userVisibleString([NSURL URLWithString:mainFrameOriginString]));
+    }
+    WKSetApplicationInformationItem(kLSActivePageUserVisibleOriginsKey, activePageURLs.get());
+#endif
+}
+
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to