Upstream WebKit Nightly’s WebKitLauncher
authordfarler@apple.com <dfarler@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2013 20:38:55 +0000 (20:38 +0000)
committerdfarler@apple.com <dfarler@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2013 20:38:55 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117418

Reviewed by Mark Rowe.

Literal patch from Nightly's OpenSource repo.

* WebKitLauncher/Configurations/Base.xcconfig:
* WebKitLauncher/Configurations/WebKitLauncher.xcconfig:
* WebKitLauncher/Info.plist:
* WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
* WebKitLauncher/WebKitLauncherURLProtocol.m:
(+[WebKitLauncherURLProtocol load]):
(+[WebKitLauncherURLProtocol canInitWithRequest:]):
(-[WebKitLauncherURLProtocol startLoading]):
(-[WebKitLauncherURLProtocol handleWebKitVersionInformation]):
(-[WebKitLauncherURLProtocol resourceNotFound]):
* WebKitLauncher/WebKitNightlyEnablerSparkle.m:
(initializeSparkle):
* WebKitLauncher/main.m:
(determineExecutablePath):
(currentMacOSXVersion):
(main):
* WebKitLauncher/start.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152186 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitLauncher/Configurations/Base.xcconfig
Tools/WebKitLauncher/Configurations/WebKitLauncher.xcconfig
Tools/WebKitLauncher/Info.plist
Tools/WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj
Tools/WebKitLauncher/WebKitLauncherURLProtocol.m
Tools/WebKitLauncher/WebKitNightlyEnablerSparkle.m
Tools/WebKitLauncher/main.m
Tools/WebKitLauncher/start.html

index d03fd21f46e44a82ab3732ee7673bc0fa421ba4d..fd85702bcab0cd410c9d81778a1480dcc101073a 100644 (file)
@@ -1,3 +1,30 @@
+2013-06-28  David Farler  <dfarler@apple.com>
+
+        Upstream WebKit Nightly’s WebKitLauncher
+        https://bugs.webkit.org/show_bug.cgi?id=117418
+
+        Reviewed by Mark Rowe.
+
+        Literal patch from Nightly's OpenSource repo.
+
+        * WebKitLauncher/Configurations/Base.xcconfig:
+        * WebKitLauncher/Configurations/WebKitLauncher.xcconfig:
+        * WebKitLauncher/Info.plist:
+        * WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
+        * WebKitLauncher/WebKitLauncherURLProtocol.m:
+        (+[WebKitLauncherURLProtocol load]):
+        (+[WebKitLauncherURLProtocol canInitWithRequest:]):
+        (-[WebKitLauncherURLProtocol startLoading]):
+        (-[WebKitLauncherURLProtocol handleWebKitVersionInformation]):
+        (-[WebKitLauncherURLProtocol resourceNotFound]):
+        * WebKitLauncher/WebKitNightlyEnablerSparkle.m:
+        (initializeSparkle):
+        * WebKitLauncher/main.m:
+        (determineExecutablePath):
+        (currentMacOSXVersion):
+        (main):
+        * WebKitLauncher/start.html:
+
 2013-06-28  Balazs Kelemen  <b.kelemen@samsung.com>
 
         [EFL] back/forward keyboard shortcuts are non-intuitive
index 149eb82050e02f3b504b31cc3d4a614e60337506..5aceb3bd028d0478c43c08fd6dabe165c013154f 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
-ARCHS = $(ARCHS_STANDARD_32_64_BIT);
+ARCHS = i386 x86_64;
 DEAD_CODE_STRIPPING = YES;
 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
 GCC_DEBUGGING_SYMBOLS = full;
 GCC_MODEL_TUNING = G5;
 GCC_PREPROCESSOR_DEFINITIONS = ENABLE_SPARKLE=$(ENABLE_SPARKLE);
 GCC_TREAT_WARNINGS_AS_ERRORS = YES;
-GCC_VERSION = 4.0;
-GCC_VERSION[arch=x86_64] = 4.2;
-MACOSX_DEPLOYMENT_TARGET = 10.4;
-MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.5;
+GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+MACOSX_DEPLOYMENT_TARGET = 10.6;
 PREBINDING = NO;
-SDKROOT = macosx10.5;
+SDKROOT = macosx;
 WARNING_CFLAGS = -Wall;
 
 ENABLE_SPARKLE = 0;
index c4dde36fefcf0b0902a8c851262cd00571378f82..fd0124e98e93fad4be95362aa1a7e9c95c5c06f3 100644 (file)
@@ -24,4 +24,3 @@
 INFOPLIST_FILE = Info.plist;
 PRODUCT_NAME = WebKit;
 WRAPPER_EXTENSION = app;
-MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.2;
index 83564a7f92d538ad65cdcf3fe310a313aa59161b..7141ec8e5b139409a794f012bacb9992a6390f55 100644 (file)
        <array>
                <string>x86_64</string>
                <string>i386</string>
-               <string>ppc</string>
        </array>
-       <key>LSMinimumSystemVersionByArchitecture</key>
-       <dict>
-               <key>x86_64</key>
-               <string>10.6</string>
-       </dict>
+       <key>LSMinimumSystemVersion</key>
+       <string>10.6</string>
        <key>SUFeedURL</key>
        <string>http://nightly.webkit.org/builds/trunk/mac/rss</string>
        <key>SUShowReleaseNotes</key>
index 4cf2f12e809cbf8050ff1b38c9273c0784561b9a..71fc11125af8e3ac886e0dff908d0a8b5270f006 100644 (file)
@@ -33,6 +33,7 @@
                5DA88F6E0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DA88F6C0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m */; };
                5DA88F7A0FC813EB00AB2F62 /* WebKitNightlyEnabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DA88F790FC813EB00AB2F62 /* WebKitNightlyEnabler.h */; };
                5DB70525097B94CD009875EC /* webkit.icns in Resources */ = {isa = PBXBuildFile; fileRef = 5DB70524097B94CD009875EC /* webkit.icns */; };
+               5DE0853815AE0AA0000A27B4 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DE0853715AE0AA0000A27B4 /* Security.framework */; };
                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
 /* End PBXBuildFile section */
@@ -78,6 +79,7 @@
                5DA88F7F0FC8176100AB2F62 /* WebKitLauncher.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKitLauncher.xcconfig; sourceTree = "<group>"; };
                5DA88F800FC8176100AB2F62 /* WebKitNightlyEnabler.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKitNightlyEnabler.xcconfig; sourceTree = "<group>"; };
                5DB70524097B94CD009875EC /* webkit.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = webkit.icns; sourceTree = "<group>"; };
+               5DE0853715AE0AA0000A27B4 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
                5DE79BEB0F1C63CC0067BE08 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
                8D1107320486CEB800E47090 /* WebKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WebKit.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -96,6 +98,7 @@
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               5DE0853815AE0AA0000A27B4 /* Security.framework in Frameworks */,
                                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                29B97314FDCFA39411CA2CEA /* WebKit */ = {
                        isa = PBXGroup;
                        children = (
+                               5DE0853715AE0AA0000A27B4 /* Security.framework */,
                                29B97315FDCFA39411CA2CEA /* Source */,
                                5DA88F7D0FC8174E00AB2F62 /* Configurations */,
                                29B97317FDCFA39411CA2CEA /* Resources */,
 /* Begin PBXProject section */
                29B97313FDCFA39411CA2CEA /* Project object */ = {
                        isa = PBXProject;
+                       attributes = {
+                               LastUpgradeCheck = 0420;
+                       };
                        buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "WebKitLauncher" */;
                        compatibilityVersion = "Xcode 3.1";
                        developmentRegion = English;
index 9e568577456ecf96f54c645315fc1c7b75be54e4..f1a945fd107a4175241c360e25d1098c42df0363 100644 (file)
 #import <Sparkle/Sparkle.h>
 #endif
 
+@interface NSObject (WKBrowsingContextControllerMethods)
++ (void)registerSchemeForCustomProtocol:(NSString *)scheme;
+@end
+
 @interface WebKitLauncherURLProtocol (ImplementationDetails)
 -(void)handleIsWebKitLauncherAvailableJS;
 -(void)handleCheckForUpdates;
@@ -41,6 +45,7 @@
 
 +(void)load
 {
+    [NSClassFromString(@"WKBrowsingContextController") registerSchemeForCustomProtocol:@"x-webkit-launcher"];
     [NSURLProtocol registerClass:self];
 }
 
@@ -53,6 +58,9 @@
     if (!mainDocumentURL)
         return NO;
 
+    if ([[mainDocumentURL scheme] isEqualToString:@"file"])
+        return YES;
+
     NSString *mainDocumentHost = [mainDocumentURL host];
     if (![mainDocumentHost isEqualToString:@"webkit.org"] && ![mainDocumentHost hasSuffix:@".webkit.org"])
         return NO;
         [self handleIsWebKitLauncherAvailableJS];
         return;
     }
+    if ([resourceSpecifier isEqualToString:@"webkit-version-information.js"]) {
+        [self handleWebKitVersionInformation];
+        return;
+    }
 #if ENABLE_SPARKLE
     if ([resourceSpecifier isEqualToString:@"check-for-updates"]) {
         [self handleCheckForUpdates];
     [client URLProtocolDidFinishLoading:self];
 }
 
+-(void)handleWebKitVersionInformation
+{
+    id client = [self client];
+    NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL] MIMEType:@"text/javascript" expectedContentLength:0 textEncodingName:@"utf-8"];
+    [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageAllowed];
+    [response release];
+
+    NSBundle *bundle = webKitLauncherBundle();
+    int revision = [[[bundle infoDictionary] valueForKey:(NSString *)kCFBundleVersionKey] intValue];
+    NSString *branch = [NSString stringWithContentsOfURL:[bundle URLForResource:@"BRANCH" withExtension:nil] encoding:NSUTF8StringEncoding error:0];
+    branch = [branch stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+    if (!branch)
+        branch = @"trunk";
+
+    NSString *script = [NSString stringWithFormat:@"var webKitRevision = %d; var webKitBranch = \"%@\";", revision, branch];
+    NSData *data = [script dataUsingEncoding:NSUTF8StringEncoding];
+    [client URLProtocol:self didLoadData:data];
+    [client URLProtocolDidFinishLoading:self];
+}
+
 #if ENABLE_SPARKLE
 -(void)handleCheckForUpdates
 {
 -(void)resourceNotFound
 {
     id client = [self client];
-    NSDictionary *infoDictionary = [NSDictionary dictionaryWithObject:NSErrorFailingURLStringKey forKey:[[self request] URL]];
+    NSDictionary *infoDictionary = [NSDictionary dictionaryWithObject:NSURLErrorFailingURLStringErrorKey forKey:[[self request] URL]];
     NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:infoDictionary];
     [client URLProtocol:self didFailWithError:error];
 }
index 8b13ab8ba6c0d91bbd6ca75e8b495632ffa07546..d60407255f713c9cac50bc40da6423ebb136d7fd 100644 (file)
@@ -102,19 +102,6 @@ static id updateAlertInitForAlertPanel(id self, SEL _cmd, id updateItem, id host
 
 @end
 
-#if __LP64__
-
-#define setMethodImplementation method_setImplementation
-
-#else
-
-static void setMethodImplementation(Method m, IMP imp)
-{
-    m->method_imp = imp;
-}
-
-#endif
-
 static NSString *userAgentStringForSparkle()
 {
     NSBundle *safariBundle = [NSBundle mainBundle];
@@ -130,10 +117,10 @@ void initializeSparkle()
 {
     // Override some Sparkle behaviour
     Method methodToPatch = class_getInstanceMethod(objc_getRequiredClass("SUUpdatePermissionPrompt"), @selector(promptDescription));
-    setMethodImplementation(methodToPatch, (IMP)updatePermissionPromptDescription);
+    method_setImplementation(methodToPatch, (IMP)updatePermissionPromptDescription);
 
     methodToPatch = class_getInstanceMethod(objc_getRequiredClass("SUUpdateAlert"), @selector(initWithAppcastItem:host:));
-    setMethodImplementation(methodToPatch, (IMP)updateAlertInitForAlertPanel);
+    method_setImplementation(methodToPatch, (IMP)updateAlertInitForAlertPanel);
 
     SUUpdater *updater = [SUUpdater updaterForBundle:webKitLauncherBundle()];
     [updater setUserAgentString:userAgentStringForSparkle()];
index 4fee68a277263a100bc96d8d588f8ffbf5ac3a3e..45e4a0d745317fe2feb0bd24400958a269e4a4b1 100644 (file)
@@ -157,13 +157,39 @@ static NSBundle *locateSafariBundle()
     return safariBundle;
 }
 
+static NSString *determineExecutablePath(NSBundle *bundle)
+{
+    NSString *safariExecutablePath = [bundle executablePath];
+
+    NSString *safariForWebKitDevelopmentExecutablePath = [bundle pathForAuxiliaryExecutable:@"SafariForWebKitDevelopment"];
+    if (![[NSFileManager defaultManager] fileExistsAtPath:safariForWebKitDevelopmentExecutablePath])
+        return safariExecutablePath;
+
+    SecStaticCodeRef staticCode;
+    if (SecStaticCodeCreateWithPath((CFURLRef)[bundle executableURL], kSecCSDefaultFlags, &staticCode) != noErr)
+        return [bundle executablePath];
+
+    NSDictionary *codeInformation;
+    if (SecCodeCopySigningInformation(staticCode, kSecCSRequirementInformation, (CFDictionaryRef*)&codeInformation) != noErr) {
+        CFRelease(staticCode);
+        return safariExecutablePath;
+    }
+    CFRelease(staticCode);
+    [codeInformation autorelease];
+
+    if ([codeInformation objectForKey:(id)kSecCodeInfoEntitlements])
+        return safariForWebKitDevelopmentExecutablePath;
+
+    return safariExecutablePath;
+}
+
 static NSString *currentMacOSXVersion()
 {
     SInt32 version;
     if (Gestalt(gestaltSystemVersion, &version) != noErr)
         return @"10.4";
 
-    return [NSString stringWithFormat:@"%x.%x", (version & 0xFF00) >> 8, (version & 0x00F0) >> 4];
+    return [NSString stringWithFormat:@"%lx.%lx", (long)(version & 0xFF00) >> 8, (long)(version & 0x00F0) >> 4l];
 }
 
 static NSString *fallbackMacOSXVersion(NSString *systemVersion)
@@ -209,13 +235,13 @@ int main(int argc, char *argv[])
     }
 
     if (!frameworkPathIsUsable)
-        displayErrorAndQuit([NSString stringWithFormat:@"Mac OS X %@ is not supported", systemVersion],
-                            [NSString stringWithFormat:@"Nightly builds of WebKit are not supported on Mac OS X %@ at this time.", systemVersion]);
+        displayErrorAndQuit([NSString stringWithFormat:@"OS X %@ is not supported", systemVersion],
+                            [NSString stringWithFormat:@"Nightly builds of WebKit are not supported on OS X %@ at this time.", systemVersion]);
 
     NSString *pathToEnablerLib = [[NSBundle mainBundle] pathForResource:@"WebKitNightlyEnabler" ofType:@"dylib"];
 
     NSBundle *safariBundle = locateSafariBundle();
-    NSString *executablePath = [safariBundle executablePath];
+    NSString *executablePath = determineExecutablePath(safariBundle);
 
     if (!checkSafariVersion(safariBundle)) {
         NSString *safariVersion = [[safariBundle localizedInfoDictionary] objectForKey:@"CFBundleShortVersionString"];
index 2c94e7976c43cd2ad273887c9d37728e83f8d553..bdb593e743a9cbb32420e46743c513f2320e6563 100644 (file)
@@ -1,31 +1,15 @@
 <html>
     <head>
         <title>Loading WebKit...</title>
-        <meta http-equiv="refresh" content="1;URL=http://nightly.webkit.org/start/" />
+        <meta http-equiv="refresh" content="1;URL=http://nightly.webkit.org/start/">
         <script type="text/javascript">
-            function getWebKitRevision()
-            {
-                var request = new XMLHttpRequest();
-                request.open("GET", "VERSION", false);
-                request.send();
-                var revision = parseInt(request.responseText);
-                if (isNaN(revision))
-                    return "";
-
-                return revision;
+            var script = document.createElement('script');
+            script.src = "x-webkit-launcher:webkit-version-information.js";
+            script.onload = function() {
+                if (webKitBranch && webKitRevision)
+                    document.location = "http://nightly.webkit.org/start/" + webKitBranch + "/" + webKitRevision;
             }
-
-            function getWebKitBranch()
-            {
-                var request = new XMLHttpRequest();
-                request.open("GET", "BRANCH", false);
-                request.send();
-                return (request.responseText || "trunk").replace(/\s/g, '')
-            }
-
-            var revision = getWebKitRevision();
-            var branch = getWebKitBranch();
-            document.location = "http://nightly.webkit.org/start/" + branch + "/" + revision;
+            document.documentElement.appendChild(script);
         </script>
     </head>
     <body>