Land the updated version of WebKitLauncher that the nightly builds have been using.
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 May 2009 05:14:44 +0000 (05:14 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 May 2009 05:14:44 +0000 (05:14 +0000)
Reviewed by Oliver Hunt.

Changes include:
1) Support for self-updating via Sparkle.
2) Now respects the "Open using Rosetta" preference.
3) Passes environment variables through to the spawned Safari process.
4) Logs a list of extensions that are detected to the system console.
5) Disables extensions that are known to cause crashes too early in the
   launch process to be detected by the extension-detection code.

* WebKitLauncher/Configurations/Base.xcconfig: Added.
* WebKitLauncher/Configurations/WebKitLauncher.xcconfig: Added.
* WebKitLauncher/Configurations/WebKitNightlyEnabler.xcconfig: Added.
* WebKitLauncher/Info.plist:
* WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
* WebKitLauncher/WebKitNightlyEnabler.h: Added.
* WebKitLauncher/WebKitNightlyEnabler.m:
(myBundleDidLoad):
(myApplicationWillFinishLaunching):
(poseAsWebKitApp):
(webKitLauncherBundle):
(enableWebKitNightlyBehaviour):
* WebKitLauncher/WebKitNightlyEnablerSparkle.h: Added.
* WebKitLauncher/WebKitNightlyEnablerSparkle.m: Added.
(initializeSparkle):
(updatePermissionPromptDescription):
(skipSignatureVerificationInDownloadDidFinish):
(updateAlertPanel):
(updateAlertInitForAlertPanel):
(-[NSAlert webKitHandleButtonPress:]):
(setMethodImplementation):
* WebKitLauncher/main.m:
(displayErrorAndQuit):
(getLastVersionShown):
(saveLastVersionShown):
(getPathForStartPage):
(getCurrentVersion):
(getShowStartPageVersion):
(startPageDisabled):
(addStartPageToArgumentsIfNeeded):
(preferredArchitecture):
(myExecve):
(locateSafariBundle):
(currentMacOSXVersion):
(checkFrameworkPath):
(main):

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

WebKitTools/ChangeLog
WebKitTools/WebKitLauncher/Configurations/Base.xcconfig [new file with mode: 0644]
WebKitTools/WebKitLauncher/Configurations/WebKitLauncher.xcconfig [new file with mode: 0644]
WebKitTools/WebKitLauncher/Configurations/WebKitNightlyEnabler.xcconfig [new file with mode: 0644]
WebKitTools/WebKitLauncher/Info.plist
WebKitTools/WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj
WebKitTools/WebKitLauncher/WebKitNightlyEnabler.h [new file with mode: 0644]
WebKitTools/WebKitLauncher/WebKitNightlyEnabler.m
WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.h [new file with mode: 0644]
WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.m [new file with mode: 0644]
WebKitTools/WebKitLauncher/main.m

index 632fc25..953ebbd 100644 (file)
@@ -1,3 +1,54 @@
+2009-05-23  Mark Rowe  <mrowe@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Land the updated version of WebKitLauncher that the nightly builds have been using.
+
+        Changes include:
+        1) Support for self-updating via Sparkle.
+        2) Now respects the "Open using Rosetta" preference.
+        3) Passes environment variables through to the spawned Safari process.
+        4) Logs a list of extensions that are detected to the system console.
+        5) Disables extensions that are known to cause crashes too early in the
+           launch process to be detected by the extension-detection code.
+
+        * WebKitLauncher/Configurations/Base.xcconfig: Added.
+        * WebKitLauncher/Configurations/WebKitLauncher.xcconfig: Added.
+        * WebKitLauncher/Configurations/WebKitNightlyEnabler.xcconfig: Added.
+        * WebKitLauncher/Info.plist:
+        * WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
+        * WebKitLauncher/WebKitNightlyEnabler.h: Added.
+        * WebKitLauncher/WebKitNightlyEnabler.m:
+        (myBundleDidLoad):
+        (myApplicationWillFinishLaunching):
+        (poseAsWebKitApp):
+        (webKitLauncherBundle):
+        (enableWebKitNightlyBehaviour):
+        * WebKitLauncher/WebKitNightlyEnablerSparkle.h: Added.
+        * WebKitLauncher/WebKitNightlyEnablerSparkle.m: Added.
+        (initializeSparkle):
+        (updatePermissionPromptDescription):
+        (skipSignatureVerificationInDownloadDidFinish):
+        (updateAlertPanel):
+        (updateAlertInitForAlertPanel):
+        (-[NSAlert webKitHandleButtonPress:]):
+        (setMethodImplementation):
+        * WebKitLauncher/main.m:
+        (displayErrorAndQuit):
+        (getLastVersionShown):
+        (saveLastVersionShown):
+        (getPathForStartPage):
+        (getCurrentVersion):
+        (getShowStartPageVersion):
+        (startPageDisabled):
+        (addStartPageToArgumentsIfNeeded):
+        (preferredArchitecture):
+        (myExecve):
+        (locateSafariBundle):
+        (currentMacOSXVersion):
+        (checkFrameworkPath):
+        (main):
+
 2009-05-23  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Reviewed by Gustavo Noronha and Xan Lopez.
diff --git a/WebKitTools/WebKitLauncher/Configurations/Base.xcconfig b/WebKitTools/WebKitLauncher/Configurations/Base.xcconfig
new file mode 100644 (file)
index 0000000..0a4dc2e
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2009 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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);
+DEAD_CODE_STRIPPING = YES;
+DEBUG_INFORMATION_FORMAT = dwarf;
+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;
+PREBINDING = NO;
+SDKROOT = macosx10.5;
+WARNING_CFLAGS = -Wall;
+
+ENABLE_SPARKLE = 0;
diff --git a/WebKitTools/WebKitLauncher/Configurations/WebKitLauncher.xcconfig b/WebKitTools/WebKitLauncher/Configurations/WebKitLauncher.xcconfig
new file mode 100644 (file)
index 0000000..c4dde36
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2009 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+INFOPLIST_FILE = Info.plist;
+PRODUCT_NAME = WebKit;
+WRAPPER_EXTENSION = app;
+MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.2;
diff --git a/WebKitTools/WebKitLauncher/Configurations/WebKitNightlyEnabler.xcconfig b/WebKitTools/WebKitLauncher/Configurations/WebKitNightlyEnabler.xcconfig
new file mode 100644 (file)
index 0000000..ff352e6
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2009 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+
+PRODUCT_NAME = WebKitNightlyEnabler;
+INSTALL_PATH = @executable_path/../Resources;
+
+OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(ENABLE_SPARKLE));
+OTHER_LDFLAGS_0 = ;
+OTHER_LDFLAGS_1 = -framework Sparkle;
index f7038bd..1eba038 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>VERSION</string>
        <key>CFBundleShortVersionString</key>
        <string>rVERSION</string>
+       <key>LSArchitecturePriority</key>
+       <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>SUFeedURL</key>
+       <string>http://nightly.webkit.org/builds/trunk/mac/rss</string>
+       <key>SUShowReleaseNotes</key>
+       <false/>
+       <key>SUAllowsAutomaticUpdates</key>
+       <false/>
        <key>NSPrincipalClass</key>
        <string>BrowserApplication</string>
-       
        <key>CFBundleHelpBookFolder</key>
        <string>SafariHelp</string>
        <key>CFBundleHelpBookName</key>
                        </dict>
                </dict>
        </array>
-
 </dict>
 </plist>
index 2ceb067..ac832c6 100644 (file)
@@ -3,15 +3,32 @@
        archiveVersion = 1;
        classes = {
        };
-       objectVersion = 42;
+       objectVersion = 45;
        objects = {
 
+/* Begin PBXAggregateTarget section */
+               5DE79BC30F1C62450067BE08 /* Extract Sparkle */ = {
+                       isa = PBXAggregateTarget;
+                       buildConfigurationList = 5DE79BD80F1C629B0067BE08 /* Build configuration list for PBXAggregateTarget "Extract Sparkle" */;
+                       buildPhases = (
+                               5DE79BC20F1C62450067BE08 /* ShellScript */,
+                       );
+                       dependencies = (
+                       );
+                       name = "Extract Sparkle";
+                       productName = "Extract Sparkle";
+               };
+/* End PBXAggregateTarget section */
+
 /* Begin PBXBuildFile section */
                5D41141C0A50A9DE00C84CF0 /* VERSION in Resources */ = {isa = PBXBuildFile; fileRef = 5D41141B0A50A9DE00C84CF0 /* VERSION */; };
                5D4DF982097F89FB0083D5E5 /* start.html in Resources */ = {isa = PBXBuildFile; fileRef = 5D4DF981097F89FB0083D5E5 /* start.html */; };
                5D650F3609DB8B370075E9A8 /* WebKitNightlyEnabler.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D650F3509DB8B370075E9A8 /* WebKitNightlyEnabler.m */; };
                5D650F3A09DB8B410075E9A8 /* WebKitNightlyEnabler.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 5D650F3409DB8B280075E9A8 /* WebKitNightlyEnabler.dylib */; };
                5D877FCD0A5795F200D0C67B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+               5DA88F6D0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DA88F6B0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h */; };
+               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 */; };
                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
                        remoteGlobalIDString = 5D650F3309DB8B280075E9A8;
                        remoteInfo = WebKitNightlyEnabler;
                };
+               5DE79BC90F1C62850067BE08 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 5DE79BC30F1C62450067BE08;
+                       remoteInfo = "Extract Sparkle";
+               };
+               5DE79BCB0F1C62890067BE08 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 5DE79BC30F1C62450067BE08;
+                       remoteInfo = "Extract Sparkle";
+               };
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
-               13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
                29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
-               29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
-               29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
                5D41141B0A50A9DE00C84CF0 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
                5D4DF981097F89FB0083D5E5 /* start.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; path = start.html; sourceTree = "<group>"; };
                5D650F3409DB8B280075E9A8 /* WebKitNightlyEnabler.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = WebKitNightlyEnabler.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
-               5D650F3509DB8B370075E9A8 /* WebKitNightlyEnabler.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebKitNightlyEnabler.m; sourceTree = "<group>"; };
-               5D650F7509DB8CB40075E9A8 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+               5D650F3509DB8B370075E9A8 /* WebKitNightlyEnabler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitNightlyEnabler.m; sourceTree = "<group>"; };
+               5DA88F6B0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNightlyEnablerSparkle.h; sourceTree = "<group>"; };
+               5DA88F6C0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitNightlyEnablerSparkle.m; sourceTree = "<group>"; };
+               5DA88F790FC813EB00AB2F62 /* WebKitNightlyEnabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNightlyEnabler.h; sourceTree = "<group>"; };
+               5DA88F7E0FC8176100AB2F62 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
+               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>"; };
+               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; };
 /* End PBXFileReference section */
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
-               080E96DDFE201D6D7F000001 /* Classes */ = {
-                       isa = PBXGroup;
-                       children = (
-                       );
-                       name = Classes;
-                       sourceTree = "<group>";
-               };
                1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
                        isa = PBXGroup;
                        children = (
                        name = "Linked Frameworks";
                        sourceTree = "<group>";
                };
-               1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
-                       isa = PBXGroup;
-                       children = (
-                               29B97324FDCFA39411CA2CEA /* AppKit.framework */,
-                               13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
-                               5D650F7509DB8CB40075E9A8 /* CoreFoundation.framework */,
-                               29B97325FDCFA39411CA2CEA /* Foundation.framework */,
-                       );
-                       name = "Other Frameworks";
-                       sourceTree = "<group>";
-               };
                19C28FACFE9D520D11CA2CBB /* Products */ = {
                        isa = PBXGroup;
                        children = (
+                               5DE79BEB0F1C63CC0067BE08 /* Sparkle.framework */,
                                8D1107320486CEB800E47090 /* WebKit.app */,
                                5D650F3409DB8B280075E9A8 /* WebKitNightlyEnabler.dylib */,
                        );
                29B97314FDCFA39411CA2CEA /* WebKit */ = {
                        isa = PBXGroup;
                        children = (
-                               080E96DDFE201D6D7F000001 /* Classes */,
-                               29B97315FDCFA39411CA2CEA /* Other Sources */,
+                               29B97315FDCFA39411CA2CEA /* Source */,
+                               5DA88F7D0FC8174E00AB2F62 /* Configurations */,
                                29B97317FDCFA39411CA2CEA /* Resources */,
                                29B97323FDCFA39411CA2CEA /* Frameworks */,
                                19C28FACFE9D520D11CA2CBB /* Products */,
                        name = WebKit;
                        sourceTree = "<group>";
                };
-               29B97315FDCFA39411CA2CEA /* Other Sources */ = {
+               29B97315FDCFA39411CA2CEA /* Source */ = {
                        isa = PBXGroup;
                        children = (
+                               5DA88F790FC813EB00AB2F62 /* WebKitNightlyEnabler.h */,
                                5D650F3509DB8B370075E9A8 /* WebKitNightlyEnabler.m */,
+                               5DA88F6B0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h */,
+                               5DA88F6C0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m */,
                                29B97316FDCFA39411CA2CEA /* main.m */,
                        );
-                       name = "Other Sources";
+                       name = Source;
                        sourceTree = "<group>";
                };
                29B97317FDCFA39411CA2CEA /* Resources */ = {
                        isa = PBXGroup;
                        children = (
                                1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
-                               1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
                        );
                        name = Frameworks;
                        sourceTree = "<group>";
                };
+               5DA88F7D0FC8174E00AB2F62 /* Configurations */ = {
+                       isa = PBXGroup;
+                       children = (
+                               5DA88F7E0FC8176100AB2F62 /* Base.xcconfig */,
+                               5DA88F7F0FC8176100AB2F62 /* WebKitLauncher.xcconfig */,
+                               5DA88F800FC8176100AB2F62 /* WebKitNightlyEnabler.xcconfig */,
+                       );
+                       path = Configurations;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               5DA88F6D0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h in Headers */,
+                               5DA88F7A0FC813EB00AB2F62 /* WebKitNightlyEnabler.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        buildRules = (
                        );
                        dependencies = (
+                               5DE79BCC0F1C62890067BE08 /* PBXTargetDependency */,
                        );
                        name = WebKitNightlyEnabler;
                        productName = WebKitNightlyEnabler;
                                8D1107290486CEB800E47090 /* Resources */,
                                8D11072C0486CEB800E47090 /* Sources */,
                                8D11072E0486CEB800E47090 /* Frameworks */,
+                               5DA892AC0FC8E3A100AB2F62 /* Copy Sparkle in to Frameworks */,
                        );
                        buildRules = (
                        );
                        dependencies = (
                                5D650F4509DB8B830075E9A8 /* PBXTargetDependency */,
+                               5DE79BCA0F1C62850067BE08 /* PBXTargetDependency */,
                        );
                        name = WebKit;
                        productInstallPath = "$(HOME)/Applications";
                29B97313FDCFA39411CA2CEA /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "WebKitLauncher" */;
-                       compatibilityVersion = "Xcode 2.4";
+                       compatibilityVersion = "Xcode 3.1";
                        hasScannedForEncodings = 1;
                        mainGroup = 29B97314FDCFA39411CA2CEA /* WebKit */;
                        projectDirPath = "";
                        targets = (
                                8D1107260486CEB800E47090 /* WebKit */,
                                5D650F3309DB8B280075E9A8 /* WebKitNightlyEnabler */,
+                               5DE79BC30F1C62450067BE08 /* Extract Sparkle */,
                        );
                };
 /* End PBXProject section */
                };
 /* End PBXResourcesBuildPhase section */
 
+/* Begin PBXShellScriptBuildPhase section */
+               5DA892AC0FC8E3A100AB2F62 /* Copy Sparkle in to Frameworks */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Copy Sparkle in to Frameworks";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "if [[ \"${ENABLE_SPARKLE}\" == \"1\" ]]\nthen\n    ditto \"${CONFIGURATION_BUILD_DIR}/Sparkle.framework\" \"${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sparkle.framework\"\n    cd \"${CONFIGURATION_BUILD_DIR}/Sparkle.framework/Resources\"\n    find . -name '*lproj' -not -name 'en.lproj' -print0 | xargs -0 rm -rf\nelse\n    rm -rf \"${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sparkle.framework\"\nfi\n";
+               };
+               5DE79BC20F1C62450067BE08 /* ShellScript */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                               "$(SRCROOT)/Sparkle.framework.tar.gz",
+                       );
+                       outputPaths = (
+                               "$(CONFIGURATION_BUILD_DIR)/Sparkle.framework",
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "if [[ \"${ENABLE_SPARKLE}\" == \"1\" ]]\nthen\n    tar -C \"${CONFIGURATION_BUILD_DIR}\" -xvzf \"${SRCROOT}/Sparkle.framework.tar.gz\"\n    cd \"${CONFIGURATION_BUILD_DIR}/Sparkle.framework/Resources\"\n    find . -name '*lproj' -not -name 'en.lproj' -print0 | xargs -0 rm -rf\nelse\n    rm -rf \"${CONFIGURATION_BUILD_DIR}/Sparkle.framework\"\nfi\n";
+               };
+/* End PBXShellScriptBuildPhase section */
+
 /* Begin PBXSourcesBuildPhase section */
                5D650F3109DB8B280075E9A8 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                                5D650F3609DB8B370075E9A8 /* WebKitNightlyEnabler.m in Sources */,
+                               5DA88F6E0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        target = 5D650F3309DB8B280075E9A8 /* WebKitNightlyEnabler */;
                        targetProxy = 5D650F4409DB8B830075E9A8 /* PBXContainerItemProxy */;
                };
+               5DE79BCA0F1C62850067BE08 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 5DE79BC30F1C62450067BE08 /* Extract Sparkle */;
+                       targetProxy = 5DE79BC90F1C62850067BE08 /* PBXContainerItemProxy */;
+               };
+               5DE79BCC0F1C62890067BE08 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 5DE79BC30F1C62450067BE08 /* Extract Sparkle */;
+                       targetProxy = 5DE79BCB0F1C62890067BE08 /* PBXContainerItemProxy */;
+               };
 /* End PBXTargetDependency section */
 
 /* Begin XCBuildConfiguration section */
                5D650F3809DB8B370075E9A8 /* Debug */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F800FC8176100AB2F62 /* WebKitNightlyEnabler.xcconfig */;
                        buildSettings = {
-                               MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
-                               PRODUCT_NAME = WebKitNightlyEnabler;
-                               SDKROOT_ppc = /Developer/SDKs/MacOSX10.4u.sdk;
                        };
                        name = Debug;
                };
                5D650F3909DB8B370075E9A8 /* Release */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F800FC8176100AB2F62 /* WebKitNightlyEnabler.xcconfig */;
                        buildSettings = {
-                               MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
-                               PRODUCT_NAME = WebKitNightlyEnabler;
-                               SDKROOT_ppc = /Developer/SDKs/MacOSX10.4u.sdk;
+                       };
+                       name = Release;
+               };
+               5DE79BC40F1C62450067BE08 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = "Extract Sparkle";
+                       };
+                       name = Debug;
+               };
+               5DE79BC50F1C62450067BE08 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = "Extract Sparkle";
                        };
                        name = Release;
                };
                C01FCF4B08A954540054247B /* Debug */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F7F0FC8176100AB2F62 /* WebKitLauncher.xcconfig */;
                        buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                               GCC_DEBUGGING_SYMBOLS = full;
-                               GCC_DYNAMIC_NO_PIC = NO;
-                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 0;
-                               INFOPLIST_FILE = Info.plist;
-                               INSTALL_PATH = "$(HOME)/Applications";
-                               PRODUCT_NAME = WebKit;
-                               WRAPPER_EXTENSION = app;
                        };
                        name = Debug;
                };
                C01FCF4C08A954540054247B /* Release */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F7F0FC8176100AB2F62 /* WebKitLauncher.xcconfig */;
                        buildSettings = {
-                               DEAD_CODE_STRIPPING = YES;
-                               DEPLOYMENT_POSTPROCESSING = YES;
-                               GCC_DEBUGGING_SYMBOLS = full;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
-                               INFOPLIST_FILE = Info.plist;
-                               PRODUCT_NAME = WebKit;
-                               WRAPPER_EXTENSION = app;
                        };
                        name = Release;
                };
                C01FCF4F08A954540054247B /* Debug */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F7E0FC8176100AB2F62 /* Base.xcconfig */;
                        buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = dwarf;
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               MACOSX_DEPLOYMENT_TARGET = 10.2;
-                               MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
-                               MACOSX_DEPLOYMENT_TARGET_ppc = 10.2;
-                               PREBINDING = NO;
-                               SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               ONLY_ACTIVE_ARCH = YES;
                        };
                        name = Debug;
                };
                C01FCF5008A954540054247B /* Release */ = {
                        isa = XCBuildConfiguration;
+                       baseConfigurationReference = 5DA88F7E0FC8176100AB2F62 /* Base.xcconfig */;
                        buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = dwarf;
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
-                               MACOSX_DEPLOYMENT_TARGET_ppc = 10.2;
-                               PREBINDING = NO;
-                               SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
                        };
                        name = Release;
                };
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               5DE79BD80F1C629B0067BE08 /* Build configuration list for PBXAggregateTarget "Extract Sparkle" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               5DE79BC40F1C62450067BE08 /* Debug */,
+                               5DE79BC50F1C62450067BE08 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "WebKit" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
diff --git a/WebKitTools/WebKitLauncher/WebKitNightlyEnabler.h b/WebKitTools/WebKitLauncher/WebKitNightlyEnabler.h
new file mode 100644 (file)
index 0000000..2fe1444
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef WebKitNightlyEnabler_h
+#define WebKitNightlyEnabler_h
+
+@class NSBundle;
+extern NSBundle *webKitLauncherBundle();
+
+#endif // WebKitNightlyEnabler_h
index 8c6eb84..02a4bb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  * Copyright (C) 2006 Graham Dennis.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -11,7 +11,7 @@
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission. 
  *
@@ -28,6 +28,7 @@
  */
 
 #import <Cocoa/Cocoa.h>
+#import "WebKitNightlyEnablerSparkle.h"
 
 static void enableWebKitNightlyBehaviour() __attribute__ ((constructor));
 
@@ -40,15 +41,12 @@ typedef enum {
     RunStateRunning
 } WKNERunStates;
 
+static char *webKitAppPath;
 static bool extensionBundlesWereLoaded = NO;
 static NSSet *extensionPaths = nil;
 
 static void myBundleDidLoad(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
 {
-    // Break out early if we have already detected an extension
-    if (extensionBundlesWereLoaded)
-        return;
-
     NSBundle *bundle = (NSBundle *)object;
     NSString *bundlePath = [[bundle bundlePath] stringByAbbreviatingWithTildeInPath];
     NSString *bundleFileName = [bundlePath lastPathComponent];
@@ -62,11 +60,12 @@ static void myBundleDidLoad(CFNotificationCenterRef center, void *observer, CFSt
     // If the bundle lives inside a known extension path, flag it as an extension
     NSEnumerator *e = [extensionPaths objectEnumerator];
     NSString *path = nil;
-    while (path = [e nextObject]) {
+    while ((path = [e nextObject])) {
         if ([bundlePath length] < [path length])
             continue;
 
         if ([[bundlePath substringToIndex:[path length]] isEqualToString:path]) {
+            NSLog(@"Extension detected: %@", bundlePath);
             extensionBundlesWereLoaded = YES;
             break;
         }
@@ -88,6 +87,8 @@ static void myApplicationWillFinishLaunching(CFNotificationCenterRef center, voi
         NSRunInformationalAlertPanel(@"Safari extensions detected",
                                      @"Safari extensions were detected on your system.  Extensions are incompatible with nightly builds of WebKit, and may cause crashes or incorrect behavior.  Please disable them if you experience such behavior.", @"Continue",
                                      nil, nil);
+
+    initializeSparkle();
 }
 
 static void myApplicationWillTerminate(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
@@ -101,7 +102,7 @@ extern char **_CFGetProcessPath() __attribute__((weak));
 
 static void poseAsWebKitApp()
 {
-    char *webKitAppPath = getenv("WebKitAppPath");
+    webKitAppPath = strdup(getenv("WebKitAppPath"));
     if (!webKitAppPath || !_CFGetProcessPath)
         return;
 
@@ -119,20 +120,32 @@ static void poseAsWebKitApp()
     unsetenv("WebKitAppPath");
 }
 
+NSBundle *webKitLauncherBundle()
+{
+    NSString *executablePath = [NSString stringWithUTF8String:webKitAppPath];
+    NSRange appLocation = [executablePath rangeOfString:@".app/" options:NSBackwardsSearch];
+    NSString *appPath = [executablePath substringToIndex:appLocation.location + appLocation.length];
+    return [NSBundle bundleWithPath:appPath];
+}
+
 static void enableWebKitNightlyBehaviour()
 {
     unsetenv("DYLD_INSERT_LIBRARIES");
     poseAsWebKitApp();
 
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     extensionPaths = [[NSSet alloc] initWithObjects:@"~/Library/InputManagers/", @"/Library/InputManagers/",
                                                     @"~/Library/Application Support/SIMBL/Plugins/", @"/Library/Application Support/SIMBL/Plugins/",
                                                     @"~/Library/Application Enhancers/", @"/Library/Application Enhancers/",
                                                     nil];
 
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    // As of 2008-11 attempting to load Saft would cause a crash on launch, so prevent it from being loaded.
+    NSArray *disabledInputManagers = [NSArray arrayWithObjects:@"Saft", nil];
+
     NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
     NSDictionary *defaultPrefs = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:RunStateShutDown], WKNERunState,
-                                                                            [NSNumber numberWithBool:YES], WKNEShouldMonitorShutdowns, nil];
+                                                                            [NSNumber numberWithBool:YES], WKNEShouldMonitorShutdowns,
+                                                                            disabledInputManagers, @"NSDisabledInputManagers", nil];
     [userDefaults registerDefaults:defaultPrefs];
     if ([userDefaults boolForKey:WKNEShouldMonitorShutdowns]) {
         WKNERunStates savedState = (WKNERunStates)[userDefaults integerForKey:WKNERunState];
@@ -161,5 +174,8 @@ static void enableWebKitNightlyBehaviour()
     CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myApplicationWillTerminate,
                                     myApplicationWillTerminate, (CFStringRef) NSApplicationWillTerminateNotification,
                                     NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
+
+    NSLog(@"WebKit %@ initialized.", [webKitLauncherBundle() objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
+
     [pool release];
 }
diff --git a/WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.h b/WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.h
new file mode 100644 (file)
index 0000000..7ff4fef
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef WebKitNightlyEnablerSparkle_h
+#define WebKitNightlyEnablerSparkle_h
+
+extern void initializeSparkle();
+
+#endif // WebKitNightlyEnablerSparkle_h
diff --git a/WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.m b/WebKitTools/WebKitLauncher/WebKitNightlyEnablerSparkle.m
new file mode 100644 (file)
index 0000000..e42f498
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#if !ENABLE_SPARKLE
+
+void initializeSparkle()
+{
+    // No-op.
+}
+
+#else // ENABLE_SPARKLE
+
+#import <Cocoa/Cocoa.h>
+#import <Sparkle/SUUpdater.h>
+#import <objc/objc-runtime.h>
+#import "WebKitNightlyEnabler.h"
+
+// We need to tweak the wording of the prompt to make sense in the context of WebKit and Safari.
+static NSString* updatePermissionPromptDescription(id self, SEL _cmd)
+{
+    return @"Should WebKit automatically check for updates? You can always check for updates manually from the Safari menu.";
+}
+
+// -[SUBasicUpdateDriver downloadDidFinish:] requires that the download be served over SSL or signed
+// using a public key.  We're not interested in dealing with that hassle just at the moment.
+static void skipSignatureVerificationInDownloadDidFinish(id self, SEL _cmd, id download)
+{
+    objc_msgSend(self, @selector(extractUpdate));
+}
+
+static NSPanel *updateAlertPanel(id updateItem, id host)
+{
+    NSString *hostName = objc_msgSend(host, @selector(name));
+    NSPanel *panel = NSGetInformationalAlertPanel([NSString stringWithFormat:@"Would you like to download and install %@ %@ now?", hostName, objc_msgSend(updateItem, @selector(displayVersionString))],
+                                                  [NSString stringWithFormat:@"You are currently running %@ %@.", hostName, objc_msgSend(host, @selector(displayVersion))],
+                                                  @"Install Update", @"Skip This Version", @"Remind Me Later");
+    NSArray *subviews = [[panel contentView] subviews];
+    NSEnumerator *e = [subviews objectEnumerator];
+    NSView *view;
+    while ((view = [e nextObject])) {
+        if (![view isKindOfClass:[NSButton class]])
+            continue;
+
+        NSButton *button = (NSButton *)view;
+        [button setAction:@selector(webKitHandleButtonPress:)];
+        if ([button tag] == NSAlertOtherReturn)
+            [button setKeyEquivalent:@"\033"];
+    }
+    [panel center];
+    return panel;
+}
+
+// Sparkle's udpate alert panel looks odd with the release notes hidden, so we
+// swap it out with a standard NSAlert-style panel instead.
+static id updateAlertInitForAlertPanel(id self, SEL _cmd, id updateItem, id host)
+{
+    NSPanel *panel = updateAlertPanel(updateItem, host);
+    [panel setDelegate:self];
+
+    self = [self initWithWindow:panel];
+    if (!self)
+        return nil;
+
+    [updateItem retain];
+    [host retain];
+
+    object_setInstanceVariable(self, "updateItem", (void*)updateItem);
+    object_setInstanceVariable(self, "host", (void*)host);
+
+    [self setShouldCascadeWindows:NO];
+
+    return self;
+}
+
+@implementation NSAlert (WebKitLauncherExtensions)
+
+- (void)webKitHandleButtonPress:(id)sender
+{
+    // We rely on the fact that NSAlertOtherReturn == -1, NSAlertAlternateReturn == 0 and NSAlertDefaultReturn == 1
+    // to map the button tag to the corresponding selector
+    SEL selectors[] = { @selector(remindMeLater:), @selector(skipThisVersion:), @selector(installUpdate:) };
+    SEL selector = selectors[[sender tag] + 1];
+
+    id delegate = [[sender window] delegate];
+    objc_msgSend(delegate, selector, sender);
+}
+
+@end
+
+#if __LP64__
+
+#define setMethodImplementation method_setImplementation
+
+#else
+
+static void setMethodImplementation(Method m, IMP imp)
+{
+    m->method_imp = imp;
+}
+
+#endif
+
+void initializeSparkle()
+{
+    // Override some Sparkle behaviour
+    Method methodToPatch = class_getInstanceMethod(objc_getRequiredClass("SUUpdatePermissionPrompt"), @selector(promptDescription));
+    setMethodImplementation(methodToPatch, (IMP)updatePermissionPromptDescription);
+
+    methodToPatch = class_getInstanceMethod(objc_getRequiredClass("SUBasicUpdateDriver"), @selector(downloadDidFinish:));
+    setMethodImplementation(methodToPatch, (IMP)skipSignatureVerificationInDownloadDidFinish);
+
+    methodToPatch = class_getInstanceMethod(objc_getRequiredClass("SUUpdateAlert"), @selector(initWithAppcastItem:host:));
+    setMethodImplementation(methodToPatch, (IMP)updateAlertInitForAlertPanel);
+
+    SUUpdater *updater = [SUUpdater updaterForBundle:webKitLauncherBundle()];
+
+    // Find the first separator on the Safari menu…
+    NSMenu *applicationSubmenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
+    int i = 0;
+    for (; i < [applicationSubmenu numberOfItems]; i++) {
+        if ([[applicationSubmenu itemAtIndex:i] isSeparatorItem])
+            break;
+    }
+
+    // … and insert a menu item that can be used to manually trigger update checks.
+    NSMenuItem *updateMenuItem = [[NSMenuItem alloc] initWithTitle:@"Check for WebKit Updates…" action:@selector(checkForUpdates:) keyEquivalent:@""];
+    [updateMenuItem setTarget:updater];
+    [applicationSubmenu insertItem:updateMenuItem atIndex:i];
+    [updateMenuItem release];
+}
+
+#endif // ENABLE_SPARKLE
index 7d13994..e828f91 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,7 +10,7 @@
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission. 
  *
 #import <Cocoa/Cocoa.h>
 #import <CoreFoundation/CoreFoundation.h>
 
-void displayErrorAndQuit(NSString *title, NSString *message)
+// We need to weak-import posix_spawn and friends as they're not available on Tiger.
+// The BSD-level system headers do not have availability macros, so we redeclare the
+// functions ourselves with the "weak" attribute.
+
+#define WEAK_IMPORT __attribute__((weak))
+
+#define POSIX_SPAWN_SETEXEC 0x0040
+typedef void *posix_spawnattr_t;
+typedef void *posix_spawn_file_actions_t;
+int posix_spawnattr_init(posix_spawnattr_t *) WEAK_IMPORT;
+int posix_spawn(pid_t * __restrict, const char * __restrict, const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, char *const __argv[ __restrict], char *const __envp[ __restrict]) WEAK_IMPORT;
+int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, size_t, cpu_type_t *__restrict, size_t *__restrict) WEAK_IMPORT;
+int posix_spawnattr_setflags(posix_spawnattr_t *, short) WEAK_IMPORT;
+
+
+static void displayErrorAndQuit(NSString *title, NSString *message)
 {
     NSApplicationLoad();
     NSRunCriticalAlertPanel(title, message, @"Quit", nil, nil);
     exit(0);
 }
 
-void checkMacOSXVersion()
-{
-    long versionNumber = 0;
-    OSErr error = Gestalt(gestaltSystemVersion, &versionNumber);
-    if (error != noErr || versionNumber < 0x1040)
-        displayErrorAndQuit(@"Mac OS X 10.4 is Required", @"Nightly builds of WebKit require Mac OS X 10.4 or newer.");
-}
-
-int getLastVersionShown()
+static int getLastVersionShown()
 {
     [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:@"-1" forKey:@"StartPageShownInVersion"]];
     return [[NSUserDefaults standardUserDefaults] integerForKey:@"StartPageShownInVersion"];
 }
 
-void saveLastVersionShown(int lastVersion)
+static void saveLastVersionShown(int lastVersion)
 {
     [[NSUserDefaults standardUserDefaults] setInteger:lastVersion forKey:@"StartPageShownInVersion"];
     [[NSUserDefaults standardUserDefaults] synchronize];
 }
 
-NSString *getPathForStartPage()
+static NSString *getPathForStartPage()
 {
     return [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"start.html"];
 }
 
-int getShowStartPageVersion()
+static int getCurrentVersion()
 {
-    return getCurrentVersion() + 1;
+    return [[[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleVersionKey] intValue];
 }
 
-int getCurrentVersion()
+static int getShowStartPageVersion()
 {
-    return [[[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleVersionKey] intValue];
+    return getCurrentVersion() + 1;
 }
 
-BOOL startPageDisabled()
+static BOOL startPageDisabled()
 {
     return [[NSUserDefaults standardUserDefaults] boolForKey:@"StartPageDisabled"];
 }
 
-void addStartPageToArgumentsIfNeeded(NSMutableArray *arguments)
+static void addStartPageToArgumentsIfNeeded(NSMutableArray *arguments)
 {
     if (startPageDisabled())
         return;
@@ -89,31 +96,51 @@ void addStartPageToArgumentsIfNeeded(NSMutableArray *arguments)
     }
 }
 
+static cpu_type_t preferredArchitecture()
+{
+#if defined(__ppc__)
+    return CPU_TYPE_POWERPC;
+#elif defined(__LP64__)
+    return CPU_TYPE_X86_64;
+#else
+    return CPU_TYPE_X86;
+#endif
+}
+
 static void myExecve(NSString *executable, NSArray *args, NSDictionary *environment)
 {
     char **argv = (char **)calloc(sizeof(char *), [args count] + 1);
     char **env = (char **)calloc(sizeof(char *), [environment count] + 1);
-    
+
     NSEnumerator *e = [args objectEnumerator];
     NSString *s;
     int i = 0;
-    while (s = [e nextObject])
+    while ((s = [e nextObject]))
         argv[i++] = (char *) [s UTF8String];
-    
+
     e = [environment keyEnumerator];
     i = 0;
-    while (s = [e nextObject])
+    while ((s = [e nextObject]))
         env[i++] = (char *) [[NSString stringWithFormat:@"%@=%@", s, [environment objectForKey:s]] UTF8String];
-   
-    execve([executable fileSystemRepresentation], argv, env);
+
+    if (posix_spawnattr_init && posix_spawn && posix_spawnattr_setbinpref_np && posix_spawnattr_setflags) {
+        posix_spawnattr_t attr;
+        posix_spawnattr_init(&attr);
+        cpu_type_t architecturePreference[] = { preferredArchitecture(), CPU_TYPE_X86 };
+        posix_spawnattr_setbinpref_np(&attr, 2, architecturePreference, 0);
+        short flags = POSIX_SPAWN_SETEXEC;
+        posix_spawnattr_setflags(&attr, flags);
+        posix_spawn(NULL, [executable fileSystemRepresentation], NULL, &attr, argv, env);
+    } else
+        execve([executable fileSystemRepresentation], argv, env);
 }
 
-NSBundle *locateSafariBundle()
+static NSBundle *locateSafariBundle()
 {
     NSArray *applicationDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES);
     NSEnumerator *e = [applicationDirectories objectEnumerator];
     NSString *applicationDirectory;
-    while (applicationDirectory = [e nextObject]) {
+    while ((applicationDirectory = [e nextObject])) {
         NSString *possibleSafariPath = [applicationDirectory stringByAppendingPathComponent:@"Safari.app"];
         NSBundle *possibleSafariBundle = [NSBundle bundleWithPath:possibleSafariPath];
         if ([[possibleSafariBundle bundleIdentifier] isEqualToString:@"com.apple.Safari"])
@@ -130,24 +157,44 @@ NSBundle *locateSafariBundle()
     return safariBundle;
 }
 
+static NSString *currentMacOSXVersion()
+{
+    SInt32 version;
+    if (Gestalt(gestaltSystemVersion, &version) != noErr)
+        return @"10.4";
+
+    return [NSString stringWithFormat:@"%x.%x", (version & 0xFF00) >> 8, (version & 0x00F0) >> 4];
+}
+
+static BOOL checkFrameworkPath(NSString *frameworkPath)
+{
+    BOOL isDirectory = NO;
+    return [[NSFileManager defaultManager] fileExistsAtPath:frameworkPath isDirectory:&isDirectory] && isDirectory;
+}
+
 int main(int argc, char *argv[])
 {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    checkMacOSXVersion();
 
+    NSString *systemVersion = currentMacOSXVersion();
     NSBundle *safariBundle = locateSafariBundle();
     NSString *executablePath = [safariBundle executablePath];
-    NSString *frameworkPath = [[NSBundle mainBundle] resourcePath];
+    NSString *frameworkPath = [[[NSBundle mainBundle] privateFrameworksPath] stringByAppendingPathComponent:systemVersion];
     NSString *pathToEnablerLib = [[NSBundle mainBundle] pathForResource:@"WebKitNightlyEnabler" ofType:@"dylib"];
 
+    if (!checkFrameworkPath(frameworkPath))
+        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]);
+
     if ([frameworkPath rangeOfString:@":"].location != NSNotFound ||
         [pathToEnablerLib rangeOfString:@":"].location != NSNotFound)
         displayErrorAndQuit(@"Unable to launch Safari",
                             @"WebKit is located at a path containing an unsupported character.  Please move WebKit to a different location and try again.");
-    
-    NSMutableArray *arguments = [NSMutableArray arrayWithObjects:executablePath, @"-WebKitDeveloperExtras", @"YES", @"-WebKitScriptDebuggerEnabled", @"YES", nil];
-    NSMutableDictionary *environment = [NSDictionary dictionaryWithObjectsAndKeys:frameworkPath, @"DYLD_FRAMEWORK_PATH", @"YES", @"WEBKIT_UNSET_DYLD_FRAMEWORK_PATH",
-                                                                                  pathToEnablerLib, @"DYLD_INSERT_LIBRARIES", [[NSBundle mainBundle] executablePath], @"WebKitAppPath", nil];
+
+    NSMutableArray *arguments = [NSMutableArray arrayWithObject:executablePath];
+    NSMutableDictionary *environment = [[[NSDictionary dictionaryWithObjectsAndKeys:frameworkPath, @"DYLD_FRAMEWORK_PATH", @"YES", @"WEBKIT_UNSET_DYLD_FRAMEWORK_PATH",
+                                                                                    pathToEnablerLib, @"DYLD_INSERT_LIBRARIES", [[NSBundle mainBundle] executablePath], @"WebKitAppPath", nil] mutableCopy] autorelease];
+    [environment addEntriesFromDictionary:[[NSProcessInfo processInfo] environment]];
     addStartPageToArgumentsIfNeeded(arguments);
 
     while (*++argv)