Commit 04542937 authored by mrowe@apple.com's avatar mrowe@apple.com

Add a hook to the WebKit launcher application to allow a link on the nightly build start page to

trigger an update via the built-in software update mechanism.

Reviewed by Sam Weinig.

* WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
* WebKitLauncher/WebKitLauncherURLProtocol.h: Added.
* WebKitLauncher/WebKitLauncherURLProtocol.m: Added.
(+[WebKitLauncherURLProtocol load]):
(+[WebKitLauncherURLProtocol canInitWithRequest:]): Only allow use of the x-webkit-launcher scheme from .webkit.org subdomains.
(+[WebKitLauncherURLProtocol canonicalRequestForRequest:]):
(-[WebKitLauncherURLProtocol startLoading]):
(-[WebKitLauncherURLProtocol stopLoading]):
(-[WebKitLauncherURLProtocol handleIsWebKitLauncherAvailableJS]): Return a brief JavaScript snippet that can be used to programatically
determine whether the x-webkit-launcher is available and working.
(-[WebKitLauncherURLProtocol handleCheckForUpdates]): Trigger a software update on the main thread.
(-[WebKitLauncherURLProtocol resourceNotFound]): Fail with a generic "File does not exist" error.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ccc3e5a8
2009-06-21 Mark Rowe <mrowe@apple.com>
Reviewed by Sam Weinig.
Add a hook to the WebKit launcher application to allow a link on the nightly build start page to
trigger an update via the built-in software update mechanism.
* WebKitLauncher/WebKitLauncher.xcodeproj/project.pbxproj:
* WebKitLauncher/WebKitLauncherURLProtocol.h: Added.
* WebKitLauncher/WebKitLauncherURLProtocol.m: Added.
(+[WebKitLauncherURLProtocol load]):
(+[WebKitLauncherURLProtocol canInitWithRequest:]): Only allow use of the x-webkit-launcher scheme from .webkit.org subdomains.
(+[WebKitLauncherURLProtocol canonicalRequestForRequest:]):
(-[WebKitLauncherURLProtocol startLoading]):
(-[WebKitLauncherURLProtocol stopLoading]):
(-[WebKitLauncherURLProtocol handleIsWebKitLauncherAvailableJS]): Return a brief JavaScript snippet that can be used to programatically
determine whether the x-webkit-launcher is available and working.
(-[WebKitLauncherURLProtocol handleCheckForUpdates]): Trigger a software update on the main thread.
(-[WebKitLauncherURLProtocol resourceNotFound]): Fail with a generic "File does not exist" error.
2009-06-20 Jan Michael Alonzo <jmalonzo@webkit.org>
Reviewed by Gustavo Noronha and Xan Lopez.
......
......@@ -21,6 +21,8 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
5D1067640FE63758002A2868 /* WebKitLauncherURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D1067620FE63758002A2868 /* WebKitLauncherURLProtocol.h */; };
5D1067650FE63758002A2868 /* WebKitLauncherURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D1067630FE63758002A2868 /* WebKitLauncherURLProtocol.m */; };
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 */; };
......@@ -61,6 +63,8 @@
/* Begin PBXFileReference section */
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
5D1067620FE63758002A2868 /* WebKitLauncherURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitLauncherURLProtocol.h; sourceTree = "<group>"; };
5D1067630FE63758002A2868 /* WebKitLauncherURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitLauncherURLProtocol.m; sourceTree = "<group>"; };
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; };
......@@ -130,6 +134,8 @@
29B97315FDCFA39411CA2CEA /* Source */ = {
isa = PBXGroup;
children = (
5D1067620FE63758002A2868 /* WebKitLauncherURLProtocol.h */,
5D1067630FE63758002A2868 /* WebKitLauncherURLProtocol.m */,
5DA88F790FC813EB00AB2F62 /* WebKitNightlyEnabler.h */,
5D650F3509DB8B370075E9A8 /* WebKitNightlyEnabler.m */,
5DA88F6B0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h */,
......@@ -177,6 +183,7 @@
files = (
5DA88F6D0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.h in Headers */,
5DA88F7A0FC813EB00AB2F62 /* WebKitNightlyEnabler.h in Headers */,
5D1067640FE63758002A2868 /* WebKitLauncherURLProtocol.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -294,6 +301,7 @@
files = (
5D650F3609DB8B370075E9A8 /* WebKitNightlyEnabler.m in Sources */,
5DA88F6E0FC8136000AB2F62 /* WebKitNightlyEnablerSparkle.m in Sources */,
5D1067650FE63758002A2868 /* WebKitLauncherURLProtocol.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*
* 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.
*/
#import <Foundation/Foundation.h>
@interface WebKitLauncherURLProtocol : NSURLProtocol
{
}
@end
/*
* 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.
*/
#import "WebKitLauncherURLProtocol.h"
#import "WebKitNightlyEnabler.h"
#if ENABLE_SPARKLE
#import <AppKit/AppKit.h>
#import <Sparkle/Sparkle.h>
#endif
@interface WebKitLauncherURLProtocol (ImplementationDetails)
-(void)handleIsWebKitLauncherAvailableJS;
-(void)handleCheckForUpdates;
-(void)resourceNotFound;
@end
@implementation WebKitLauncherURLProtocol
+(void)load
{
[NSURLProtocol registerClass:self];
}
+(BOOL)canInitWithRequest:(NSURLRequest *)request
{
if (![[[request URL] scheme] isEqualToString:@"x-webkit-launcher"])
return NO;
NSURL *mainDocumentURL = [request mainDocumentURL];
if (!mainDocumentURL)
return NO;
NSString *mainDocumentHost = [mainDocumentURL host];
if (![mainDocumentHost isEqualToString:@"webkit.org"] && ![mainDocumentHost hasSuffix:@".webkit.org"])
return NO;
return YES;
}
+(NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
{
return request;
}
-(void)startLoading
{
NSURLRequest *request = [self request];
NSString *resourceSpecifier = [[request URL] resourceSpecifier];
if ([resourceSpecifier isEqualToString:@"is-x-webkit-launcher-available.js"]) {
[self handleIsWebKitLauncherAvailableJS];
return;
}
#if ENABLE_SPARKLE
if ([resourceSpecifier isEqualToString:@"check-for-updates"]) {
[self handleCheckForUpdates];
return;
}
#endif
[self resourceNotFound];
}
-(void)stopLoading
{
}
-(void)handleIsWebKitLauncherAvailableJS
{
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];
NSData *data = [@"var isWebKitLauncherAvailable = true;" dataUsingEncoding:NSUTF8StringEncoding];
[client URLProtocol:self didLoadData:data];
[client URLProtocolDidFinishLoading:self];
}
#if ENABLE_SPARKLE
-(void)handleCheckForUpdates
{
id client = [self client];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL] MIMEType:@"text/plain" expectedContentLength:0 textEncodingName:@"utf-8"];
[client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
[response release];
SUUpdater *updater = [SUUpdater updaterForBundle:webKitLauncherBundle()];
[updater performSelectorOnMainThread:@selector(checkForUpdates:) withObject:self waitUntilDone:NO];
[client URLProtocolDidFinishLoading:self];
}
#endif
-(void)resourceNotFound
{
id client = [self client];
NSDictionary *infoDictionary = [NSDictionary dictionaryWithObject:NSErrorFailingURLStringKey forKey:[[self request] URL]];
NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:infoDictionary];
[client URLProtocol:self didFailWithError:error];
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment