WebKitTools:
authorddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Jul 2006 13:05:27 +0000 (13:05 +0000)
committerddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Jul 2006 13:05:27 +0000 (13:05 +0000)
        Reviewed by Alexy Proskuryakov.  Patch by Mark Rowe.

        Bug 9692: Warning about Safari extensions on every launch is obnoxious
        http://bugzilla.opendarwin.org/show_bug.cgi?id=9692

        * WebKitLauncher/WebKitNightlyEnabler.m:
        (myApplicationWillTerminate): Note that we are exiting cleanly.
        (cleanUpAfterOurselves): Install bundle load tracking only if we failed
         to exit cleanly on our last invocation.  This doesn't play nicely with
         multiple concurrent instances of WebKit.app so it can be disabled via
         defaults write com.apple.Safari WKNEShouldMonitorShutdowns -bool NO.

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

WebKitTools/ChangeLog
WebKitTools/WebKitLauncher/WebKitNightlyEnabler.m

index 57c26f6..239f69b 100644 (file)
@@ -2,6 +2,20 @@
 
         Reviewed by Alexy Proskuryakov.
 
+        Bug 9692: Warning about Safari extensions on every launch is obnoxious
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9692
+
+        * WebKitLauncher/WebKitNightlyEnabler.m:
+        (myApplicationWillTerminate): Note that we are exiting cleanly.
+        (cleanUpAfterOurselves): Install bundle load tracking only if we failed
+         to exit cleanly on our last invocation.  This doesn't play nicely with
+         multiple concurrent instances of WebKit.app so it can be disabled via
+         defaults write com.apple.Safari WKNEShouldMonitorShutdowns -bool NO.
+
+2006-07-02  Mark Rowe  <opendarwin.org@bdash.net.nz>
+
+        Reviewed by Alexy Proskuryakov.
+
         Bug 9654: Refresh Loop when accessing feed URLs
         http://bugzilla.opendarwin.org/show_bug.cgi?id=9654
 
index d04fc4d..7a6bf16 100644 (file)
@@ -37,6 +37,9 @@
 static void cleanUpAfterOurselves(void) __attribute__ ((constructor));
 static void *symbol_lookup(char *symbol);
 
+static NSString *WKNEDidShutDownCleanly = @"WKNEDidShutDownCleanly";
+static NSString *WKNEShouldMonitorShutdowns = @"WKNEShouldMonitorShutdowns";
+
 static bool extensionBundlesWereLoaded = NO;
 static NSSet *extensionPaths = nil;
 
@@ -82,6 +85,13 @@ static void myApplicationWillFinishLaunching(CFNotificationCenterRef center, voi
                                      @"Safari extensions were detected on your system. They 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);
 }
 
+static void myApplicationWillTerminate(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
+{
+    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+    [userDefaults setBool:YES forKey:WKNEDidShutDownCleanly];
+    [userDefaults synchronize];
+}
+
 void cleanUpAfterOurselves(void)
 {
     char **args = *(char***)_NSGetArgv();
@@ -98,12 +108,28 @@ void cleanUpAfterOurselves(void)
                                                     @"~/Library/Application Enhancers/", @"/Library/Application Enhancers/",
                                                     nil];
 
-    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myBundleDidLoad,
-                                    myBundleDidLoad, (CFStringRef) NSBundleDidLoadNotification,
-                                    NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
-    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myApplicationWillFinishLaunching,
-                                    myApplicationWillFinishLaunching, (CFStringRef) NSApplicationWillFinishLaunchingNotification,
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+    NSDictionary *defaultPrefs = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], WKNEDidShutDownCleanly,
+                                                                            [NSNumber numberWithBool:YES], WKNEShouldMonitorShutdowns, nil];
+    [userDefaults registerDefaults:defaultPrefs];
+    if ([userDefaults boolForKey:WKNEShouldMonitorShutdowns] && ![userDefaults boolForKey:WKNEDidShutDownCleanly])
+    {
+        NSLog(@"WebKit failed to shut down cleanly.  Checking for Safari extensions.");
+        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myBundleDidLoad,
+                                        myBundleDidLoad, (CFStringRef) NSBundleDidLoadNotification,
+                                        NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
+        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myApplicationWillFinishLaunching,
+                                        myApplicationWillFinishLaunching, (CFStringRef) NSApplicationWillFinishLaunchingNotification,
+                                        NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
+    }
+    [userDefaults setBool:NO forKey:WKNEDidShutDownCleanly];
+    [userDefaults synchronize];
+
+    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), &myApplicationWillTerminate,
+                                    myApplicationWillTerminate, (CFStringRef) NSApplicationWillTerminateNotification,
                                     NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
+    [pool release];
 }
 
 #if __LP64__