<!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>[160280] 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/160280">160280</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2013-12-07 22:17:18 -0800 (Sat, 07 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Cocoa] Make WKWebProcessPlugInController work with WKObject wrapping
https://bugs.webkit.org/show_bug.cgi?id=125404
Reviewed by Dan Bernstein.
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Shared/mac/ObjCObjectGraphCoders.mm:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
(-[WKWebProcessPlugInController dealloc]):
(didCreatePage):
(willDestroyPage):
(-[WKWebProcessPlugInController _setPrincipalClassInstance:]):
(-[WKWebProcessPlugInController API::]):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h:
(WebKit::wrapper):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h:
* WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
(WebKit::InjectedBundle::load):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaAPIObjectmm">trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedmacObjCObjectGraphCodersmm">trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInmm">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInInternalh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInPrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundlemacInjectedBundleMacmm">trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2013-12-07 Sam Weinig <sam@webkit.org>
+
+ [Cocoa] Make WKWebProcessPlugInController work with WKObject wrapping
+ https://bugs.webkit.org/show_bug.cgi?id=125404
+
+ Reviewed by Dan Bernstein.
+
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+ * Shared/mac/ObjCObjectGraphCoders.mm:
+ * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
+ (-[WKWebProcessPlugInController dealloc]):
+ (didCreatePage):
+ (willDestroyPage):
+ (-[WKWebProcessPlugInController _setPrincipalClassInstance:]):
+ (-[WKWebProcessPlugInController API::]):
+ * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h:
+ (WebKit::wrapper):
+ * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h:
+ * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
+ (WebKit::InjectedBundle::load):
+
</ins><span class="cx"> 2013-12-07 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> [Cocoa] WebData has a generic wrapper
</span><span class="lines">@@ -5,7 +27,7 @@
</span><span class="cx">
</span><span class="cx"> Reviewed by Sam Weinig.
</span><span class="cx">
</span><del>- Added WKNSData, an NSData subclass that confroms to WKObject and wraps a WebData.
</del><ins>+ Added WKNSData, an NSData subclass that conforms to WKObject and wraps a WebData.
</ins><span class="cx">
</span><span class="cx"> * Shared/Cocoa/APIObject.mm:
</span><span class="cx"> (API::Object::newObject): Allocate a WKNSData if the API::Object is data.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaAPIObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #import "WKNavigationDataInternal.h"
</span><span class="cx"> #import "WKProcessGroupInternal.h"
</span><span class="cx"> #import "WKWebProcessPlugInBrowserContextControllerInternal.h"
</span><ins>+#import "WKWebProcessPlugInInternal.h"
</ins><span class="cx">
</span><span class="cx"> namespace API {
</span><span class="cx">
</span><span class="lines">@@ -82,6 +83,10 @@
</span><span class="cx"> wrapper = [WKBackForwardListItem alloc];
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case Type::Bundle:
+ wrapper = [WKWebProcessPlugInController alloc];
+ break;
+
</ins><span class="cx"> case Type::BundlePage:
</span><span class="cx"> wrapper = [WKWebProcessPlugInBrowserContextController alloc];
</span><span class="cx"> break;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacObjCObjectGraphCodersmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -40,7 +40,6 @@
</span><span class="cx"> #import "InjectedBundleUserMessageCoders.h"
</span><span class="cx"> #import "WKBundleAPICast.h"
</span><span class="cx"> #import "WKWebProcessPlugInBrowserContextControllerInternal.h"
</span><del>-#import "WKWebProcessPlugInBrowserContextControllerPrivate.h"
</del><span class="cx"> #import "WKWebProcessPlugInInternal.h"
</span><span class="cx"> #import "WebPage.h"
</span><span class="cx"> #import "WebProcess.h"
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><del>-#import "InjectedBundle.h"
</del><span class="cx"> #import "WKConnectionInternal.h"
</span><span class="cx"> #import "WKBundle.h"
</span><span class="cx"> #import "WKBundleAPICast.h"
</span><span class="lines">@@ -39,18 +38,24 @@
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><span class="cx"> @interface WKWebProcessPlugInController () {
</span><ins>+ API::ObjectStorage<InjectedBundle> _bundle;
</ins><span class="cx"> RetainPtr<id <WKWebProcessPlugIn>> _principalClassInstance;
</span><del>- RefPtr<InjectedBundle> _bundle;
- RetainPtr<WKConnection *> _connectionWrapper;
</del><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WKWebProcessPlugInController
</span><span class="cx">
</span><ins>+- (void)dealloc
+{
+ _bundle->~InjectedBundle();
+
+ [super dealloc];
+}
+
</ins><span class="cx"> static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
</span><span class="cx"> {
</span><span class="cx"> WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo;
</span><del>- id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
</del><ins>+ id <WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
</ins><span class="cx">
</span><span class="cx"> if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:didCreateBrowserContextController:)])
</span><span class="cx"> [principalClassInstance webProcessPlugIn:plugInController didCreateBrowserContextController:wrapper(*toImpl(page))];
</span><span class="lines">@@ -59,7 +64,7 @@
</span><span class="cx"> static void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
</span><span class="cx"> {
</span><span class="cx"> WKWebProcessPlugInController *plugInController = (WKWebProcessPlugInController *)clientInfo;
</span><del>- id<WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
</del><ins>+ id <WKWebProcessPlugIn> principalClassInstance = plugInController->_principalClassInstance.get();
</ins><span class="cx">
</span><span class="cx"> if ([principalClassInstance respondsToSelector:@selector(webProcessPlugIn:willDestroyBrowserContextController:)])
</span><span class="cx"> [principalClassInstance webProcessPlugIn:plugInController willDestroyBrowserContextController:wrapper(*toImpl(page))];
</span><span class="lines">@@ -78,29 +83,12 @@
</span><span class="cx"> bundle.initializeClient(&bundleClient.base);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static WKWebProcessPlugInController *sharedInstance;
-
-+ (WKWebProcessPlugInController *)_shared
</del><ins>+- (void)_setPrincipalClassInstance:(id <WKWebProcessPlugIn>)principalClassInstance
</ins><span class="cx"> {
</span><del>- ASSERT_WITH_MESSAGE(sharedInstance, "+[WKWebProcessPlugIn _shared] called without first initializing it.");
- return sharedInstance;
-}
-
-- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundle:(InjectedBundle&)bundle
-{
- self = [super init];
- if (!self)
- return nil;
-
</del><ins>+ ASSERT(!_principalClassInstance);
</ins><span class="cx"> _principalClassInstance = principalClassInstance;
</span><del>- _bundle = &bundle;
</del><span class="cx">
</span><del>- ASSERT_WITH_MESSAGE(!sharedInstance, "WKWebProcessPlugInController initialized multiple times.");
- sharedInstance = self;
-
</del><span class="cx"> setUpBundleClient(self, *_bundle);
</span><del>-
- return self;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (WKConnection *)connection
</span><span class="lines">@@ -108,6 +96,13 @@
</span><span class="cx"> return wrapper(*_bundle->webConnectionToUIProcess());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+ return *_bundle;
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WKWebProcessPlugInController (Private)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -23,17 +23,25 @@
</span><span class="cx"> * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#import "WKWebProcessPlugIn.h"
</del><ins>+#import "WKWebProcessPlugInPrivate.h"
</ins><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> #import "InjectedBundle.h"
</span><ins>+#import "WKObject.h"
</ins><span class="cx">
</span><del>-@interface WKWebProcessPlugInController ()
</del><ins>+namespace WebKit {
</ins><span class="cx">
</span><del>-+ (WKWebProcessPlugInController *)_shared;
-- (id)_initWithPrincipalClassInstance:(id<WKWebProcessPlugIn>)principalClassInstance bundle:(WebKit::InjectedBundle&)bundle;
</del><ins>+inline WKWebProcessPlugInController *wrapper(InjectedBundle& bundle)
+{
+ ASSERT([bundle.wrapper() isKindOfClass:[WKWebProcessPlugInController class]]);
+ return (WKWebProcessPlugInController *)bundle.wrapper();
+}
</ins><span class="cx">
</span><ins>+}
+
+@interface WKWebProcessPlugInController () <WKObject>
+- (void)_setPrincipalClassInstance:(id <WKWebProcessPlugIn>)principalClassInstance;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPImacWKWebProcessPlugInPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInPrivate.h        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx">
</span><span class="cx"> @interface WKWebProcessPlugInController (Private)
</span><span class="cx">
</span><del>-@property(readonly) WKBundleRef _bundleRef;
</del><ins>+@property (readonly) WKBundleRef _bundleRef;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundlemacInjectedBundleMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm (160279 => 160280)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm        2013-12-08 05:53:33 UTC (rev 160279)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm        2013-12-08 06:17:18 UTC (rev 160280)
</span><span class="lines">@@ -98,24 +98,24 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- id<WKWebProcessPlugIn> instance = (id<WKWebProcessPlugIn>)[[principalClass alloc] init];
</del><ins>+ id <WKWebProcessPlugIn> instance = (id <WKWebProcessPlugIn>)[[principalClass alloc] init];
</ins><span class="cx"> if (!instance) {
</span><span class="cx"> WTFLogAlways("InjectedBundle::load failed - Could not initialize an instance of the principal class.\n");
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Create the shared WKWebProcessPlugInController.
- [[WKWebProcessPlugInController alloc] _initWithPrincipalClassInstance:instance bundle:*this];
</del><ins>+ WKWebProcessPlugInController* plugInController = WebKit::wrapper(*this);
+ [plugInController _setPrincipalClassInstance:instance];
</ins><span class="cx">
</span><span class="cx"> if ([instance respondsToSelector:@selector(webProcessPlugIn:initializeWithObject:)]) {
</span><span class="cx"> RetainPtr<id> objCInitializationUserData;
</span><span class="cx"> if (initializationUserData && initializationUserData->type() == API::Object::Type::ObjCObjectGraph)
</span><span class="cx"> objCInitializationUserData = static_cast<ObjCObjectGraph*>(initializationUserData)->rootObject();
</span><del>- [instance webProcessPlugIn:[WKWebProcessPlugInController _shared] initializeWithObject:objCInitializationUserData.get()];
</del><ins>+ [instance webProcessPlugIn:plugInController initializeWithObject:objCInitializationUserData.get()];
</ins><span class="cx"> } else if ([instance respondsToSelector:@selector(webProcessPlugInInitialize:)]) {
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored "-Wdeprecated-declarations"
</span><del>- [instance webProcessPlugInInitialize:[WKWebProcessPlugInController _shared]];
</del><ins>+ [instance webProcessPlugInInitialize:plugInController];
</ins><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>