summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 22:06:14 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 22:06:14 +0000
commitb6626dd455c2fd13da2e3244a5124b253324d948 (patch)
treedc2e5c69d75043c3614a21bc591fcfee50d981f1
parenta7d069875e5c57d19e7a8490721fd479042e174a (diff)
downloadchromium_src-b6626dd455c2fd13da2e3244a5124b253324d948.zip
chromium_src-b6626dd455c2fd13da2e3244a5124b253324d948.tar.gz
chromium_src-b6626dd455c2fd13da2e3244a5124b253324d948.tar.bz2
Provisional Keystone support in Mac TestShell
Review URL: http://codereview.chromium.org/18117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8228 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/test_shell/mac/KeystoneGlue.h33
-rw-r--r--webkit/tools/test_shell/mac/KeystoneGlue.m71
-rw-r--r--webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj6
-rw-r--r--webkit/tools/test_shell/mac/main.mm4
4 files changed, 114 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/mac/KeystoneGlue.h b/webkit/tools/test_shell/mac/KeystoneGlue.h
new file mode 100644
index 0000000..0ebc2f7
--- /dev/null
+++ b/webkit/tools/test_shell/mac/KeystoneGlue.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_TOOLS_TEST_SHELL_MAC_KEYSTONE_GLUE_H_
+#define WEBKIT_TOOLS_TEST_SHELL_MAC_KEYSTONE_GLUE_H_
+
+#import <Foundation/Foundation.h>
+
+// KeystoneGlue is an adapter around the KSRegistration class, allowing it to
+// be used without linking directly against its containing KeystoneRegistration
+// framework. This is used in an environment where most builds (such as
+// developer builds) don't want or need Keystone support and might not even
+// have the framework available. Enabling Keystone support in an application
+// that uses KeystoneGlue is as simple as dropping
+// KeystoneRegistration.framework in the application's Frameworks directory
+// and providing the relevant information in its Info.plist. KeystoneGlue
+// requires that the KSUpdateURL key be set in the application's Info.plist,
+// and that it contain a string identifying the update URL to be used by
+// Keystone.
+
+@interface KeystoneGlue : NSObject
+
+// Load KeystoneRegistration.framework if present, call into it to register
+// with Keystone, and set up periodic activity pings.
++ (void)registerWithKeystone;
+
+// Called periodically to announce activity by pinging the Keystone server.
++ (void)markActive:(NSTimer*)timer;
+
+@end
+
+#endif // WEBKIT_TOOLS_TEST_SHELL_MAC_KEYSTONE_GLUE_H_
diff --git a/webkit/tools/test_shell/mac/KeystoneGlue.m b/webkit/tools/test_shell/mac/KeystoneGlue.m
new file mode 100644
index 0000000..64538fa
--- /dev/null
+++ b/webkit/tools/test_shell/mac/KeystoneGlue.m
@@ -0,0 +1,71 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "KeystoneGlue.h"
+
+// Provide declarations of the Keystone registration bits needed here. From
+// KSRegistration.h.
+typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType;
+@interface KSRegistration : NSObject
++ (id)registrationWithProductID:(NSString*)productID;
+- (BOOL)registerWithVersion:(NSString*)version
+ existenceCheckerType:(KSExistenceCheckerType)xctype
+ existenceCheckerString:(NSString*)xc
+ serverURLString:(NSString*)serverURLString;
+- (void)setActive;
+@end
+
+@implementation KeystoneGlue
+
++ (void)registerWithKeystone {
+ // Figure out who we are.
+ NSBundle* mainBundle = [NSBundle mainBundle];
+ NSString* bundleIdentifier = [mainBundle bundleIdentifier];
+ NSDictionary* infoDictionary = [mainBundle infoDictionary];
+ NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"];
+ NSString* version = [infoDictionary objectForKey:(id)kCFBundleVersionKey];
+ if (!bundleIdentifier || !url || !version) {
+ // If parameters required for Keystone are missing, don't use it.
+ return;
+ }
+
+ // Load the KeystoneRegistration framework bundle.
+ NSString* ksrPath =
+ [[mainBundle privateFrameworksPath]
+ stringByAppendingPathComponent:@"KeystoneRegistration.framework"];
+ NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath];
+ [ksrBundle load];
+
+ // Harness the KSRegistration class.
+ Class ksrClass = [ksrBundle classNamed:@"KSRegistration"];
+ KSRegistration* ksr = [ksrClass registrationWithProductID:bundleIdentifier];
+ if (!ksr) {
+ // Strictly speaking, this isn't necessary, because it's harmless to send
+ // messages to nil. However, if there really isn't a
+ // KeystoneRegistration.framework or KSRegistration class, bailing out here
+ // avoids setting up the timer that will only be able to perform no-ops.
+ return;
+ }
+
+ // Keystone will asynchronously handle installation and registration as
+ // needed.
+ [ksr registerWithVersion:version
+ existenceCheckerType:kKSPathExistenceChecker
+ existenceCheckerString:[mainBundle bundlePath]
+ serverURLString:url];
+
+ // Set up hourly activity pings.
+ [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour
+ target:self
+ selector:@selector(markActive:)
+ userInfo:ksr
+ repeats:YES];
+}
+
++ (void)markActive:(NSTimer*)timer {
+ KSRegistration* ksr = [timer userInfo];
+ [ksr setActive];
+}
+
+@end
diff --git a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
index 7032f39..9d3bcd6 100644
--- a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
+++ b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
@@ -35,6 +35,7 @@
/* Begin PBXBuildFile section */
4D1638790EBFA714008F024E /* libsqlite.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1638760EBFA6F7008F024E /* libsqlite.a */; };
+ 4D4164FC0F212E6500F2F4A0 /* KeystoneGlue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D4164FB0F212E6500F2F4A0 /* KeystoneGlue.m */; };
4D4C57FC0EF1A314002CA805 /* multipart_response_delegate_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4506B9E0EF02C7E003BE099 /* multipart_response_delegate_unittest.cc */; };
4D4C58D90EF1A6D0002CA805 /* password_autocomplete_listener_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4506BA00EF02C85003BE099 /* password_autocomplete_listener_unittest.cc */; };
4DB687D70EAFE7C800AB2128 /* libxslt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB687D40EAFE79200AB2128 /* libxslt.a */; };
@@ -707,6 +708,8 @@
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* TestShell_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestShell_Prefix.pch; sourceTree = "<group>"; };
4D16386E0EBFA6F7008F024E /* sqlite.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = sqlite.xcodeproj; path = third_party/sqlite/sqlite.xcodeproj; sourceTree = "<group>"; };
+ 4D4164FA0F212E6500F2F4A0 /* KeystoneGlue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeystoneGlue.h; sourceTree = "<group>"; };
+ 4D4164FB0F212E6500F2F4A0 /* KeystoneGlue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeystoneGlue.m; sourceTree = "<group>"; };
4DB687CA0EAFE79200AB2128 /* libxslt.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libxslt.xcodeproj; path = third_party/libxslt/libxslt.xcodeproj; sourceTree = "<group>"; };
4DB7FA6E0E9BF33B00C66CE0 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<group>"; };
4DB7FEA70E9BF98C00C66CE0 /* libWebKitSystemInterfaceLeopard.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWebKitSystemInterfaceLeopard.a; path = ../../../../third_party/WebKit/WebKitLibraries/libWebKitSystemInterfaceLeopard.a; sourceTree = SOURCE_ROOT; };
@@ -1162,6 +1165,8 @@
children = (
F431EA480F1D141300E8D37F /* DumpRenderTreePasteboard.m */,
F431EA490F1D141300E8D37F /* DumpRenderTreePasteboard.h */,
+ 4D4164FA0F212E6500F2F4A0 /* KeystoneGlue.h */,
+ 4D4164FB0F212E6500F2F4A0 /* KeystoneGlue.m */,
29B97316FDCFA39411CA2CEA /* main.mm */,
ABA65EFD0DD50BFF003A4FC8 /* test_shell_webview.h */,
ABA65EFE0DD50BFF003A4FC8 /* test_shell_webview.mm */,
@@ -1900,6 +1905,7 @@
files = (
F431EA4A0F1D141300E8D37F /* DumpRenderTreePasteboard.m in Sources */,
E45629160E26B4FE005E4685 /* event_sending_controller.cc in Sources */,
+ 4D4164FC0F212E6500F2F4A0 /* KeystoneGlue.m in Sources */,
E45629170E26B4FE005E4685 /* layout_test_controller.cc in Sources */,
E45629150E26B4FE005E4685 /* main.mm in Sources */,
53E50D280ECA1B21001784B4 /* simple_clipboard_impl.cc in Sources */,
diff --git a/webkit/tools/test_shell/mac/main.mm b/webkit/tools/test_shell/mac/main.mm
index 0bb6c70..19c3507 100644
--- a/webkit/tools/test_shell/mac/main.mm
+++ b/webkit/tools/test_shell/mac/main.mm
@@ -25,6 +25,7 @@
#include "webkit/tools/test_shell/test_shell.h"
#include "webkit/tools/test_shell/test_shell_request_context.h"
#include "webkit/tools/test_shell/test_shell_switches.h"
+#import "webkit/tools/test_shell/mac/KeystoneGlue.h"
#include "WebSystemInterface.h"
@@ -221,6 +222,9 @@ int main(const int argc, const char *argv[]) {
// Default to a homepage if we're interactive
if (!layout_test_mode) {
+ // If Keystone is available, set it up if needed and register with it.
+ [KeystoneGlue registerWithKeystone];
+
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *testShellPath =
[resourcePath stringByAppendingPathComponent:@"test_shell/index.html"];