diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:41:26 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:41:26 +0000 |
commit | 04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf (patch) | |
tree | 9decee40b998d4db7ce5d2fd97a6d8be0b5a90da /chrome | |
parent | 3f918787e1073e17439e55ed34f23ffdc31f891f (diff) | |
download | chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.zip chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.tar.gz chromium_src-04abd506d6a0ae3c5130bf1e026eadbe3b24ccbf.tar.bz2 |
Adapt (and move) mark@chromium.org's Keystone integration to Chromium.
Call it from the Browser. (no-op if not packaged for branding).
Add new build target "app_packaging" to package (if possible).
(app_packaging target intentionally left out of "All").
For convenience, here is the app_packaging script embedded in the xcodeproj:
PACKAGER="${PROJECT_DIR}/tools/mac/package_chrome.sh"
if [ -f "${PACKAGER}" ]; then
"${PACKAGER}"
fi
Mark, I know this is not in gyp... I am happy to have this klobbered
and redo it (in gyp) at the appropriate time.
Review URL: http://codereview.chromium.org/27293
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/keystone_glue.h | 33 | ||||
-rw-r--r-- | chrome/app/keystone_glue.m | 81 | ||||
-rw-r--r-- | chrome/browser/browser_main_mac.mm | 7 | ||||
-rw-r--r-- | chrome/chrome.xcodeproj/project.pbxproj | 74 |
4 files changed, 194 insertions, 1 deletions
diff --git a/chrome/app/keystone_glue.h b/chrome/app/keystone_glue.h new file mode 100644 index 0000000..0ebc2f7 --- /dev/null +++ b/chrome/app/keystone_glue.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/chrome/app/keystone_glue.m b/chrome/app/keystone_glue.m new file mode 100644 index 0000000..45ae1c2 --- /dev/null +++ b/chrome/app/keystone_glue.m @@ -0,0 +1,81 @@ +// 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 "keystone_glue.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 + +// TODO(mmentovai): Determine if the app is writable, and don't register for +// updates if not - but keep the periodic activity pings. ++ (void)registerWithKeystone { + // Figure out who we are. + NSBundle* mainBundle = [NSBundle mainBundle]; + NSDictionary* infoDictionary = [mainBundle infoDictionary]; + NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; + NSString* bundleIdentifier = [infoDictionary objectForKey:@"KSProductID"]; + if (bundleIdentifier == nil) { + bundleIdentifier = [mainBundle bundleIdentifier]; + } + // TODO(mmentovai): The svn version serves our purposes for now, but it will + // likely be replaced. The key problem is that it does not monotonically + // increase for releases when considering svn branches and tags. For the + // purposes of TestShell, though, which will likely only ever survive in + // auto-updatable form in builds straight from the trunk, this is fine. + NSString* version = [infoDictionary objectForKey:@"SVNRevision"]; + 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/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index c7ddda0..c5a07fd 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <crt_externs.h> #include <Cocoa/Cocoa.h> #include "base/command_line.h" #include "chrome/app/result_codes.h" #include "chrome/browser/app_controller_mac.h" #include "chrome/browser/browser_main_win.h" -#include <crt_externs.h> +#include "chrome/app/keystone_glue.h" namespace Platform { @@ -25,6 +26,10 @@ void WillInitializeMainMessageLoop(const CommandLine & command_line) { [NSApplication sharedApplication]; [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; + // Doesn't need to be in a GOOGLE_CHROME_BUILD since this references + // a framework only distributed with Google Chrome. + [KeystoneGlue registerWithKeystone]; + // TODO(port): Use of LSUIElement=1 is a temporary fix. The right // answer is to fix the renderer to not use Cocoa. // diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 274f8ae..dca3388 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -7,6 +7,18 @@ objects = { /* Begin PBXAggregateTarget section */ + 33017F800F585E4C00B6FA6D /* app_packaging */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33017F8B0F585EA300B6FA6D /* Build configuration list for PBXAggregateTarget "app_packaging" */; + buildPhases = ( + 33017F7F0F585E4C00B6FA6D /* ShellScript */, + ); + dependencies = ( + 33017F850F585E8500B6FA6D /* PBXTargetDependency */, + ); + name = app_packaging; + productName = "app packaging"; + }; 4D7B014C0E9D572C009A6919 /* run_unit_tests */ = { isa = PBXAggregateTarget; buildConfigurationList = 4D7B01530E9D5760009A6919 /* Build configuration list for PBXAggregateTarget "run_unit_tests" */; @@ -94,6 +106,7 @@ 2D70E0E2053C6C759EC97929 /* chrome_plugin_util.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFB950E9D4C9F009A6919 /* chrome_plugin_util.cc */; }; 2DF2A9EB8AF96926EE9B6B02 /* ipc_logging.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAE0E9D4C9F009A6919 /* ipc_logging.cc */; }; 3257B6150A16A88F55E5AE34 /* bookmark_drop_info.cc in Sources */ = {isa = PBXBuildFile; fileRef = 12F137DA942221A44BFA0967 /* bookmark_drop_info.cc */; }; + 33017F300F575FC600B6FA6D /* keystone_glue.m in Sources */ = {isa = PBXBuildFile; fileRef = 33017F2F0F575FC600B6FA6D /* keystone_glue.m */; }; 331218220F3BFF32006CB2B0 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 331B93A90F3BF2B9008B1C46 /* QuartzCore.framework */; }; 331218230F3BFF36006CB2B0 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 331B93AB0F3BF2DA008B1C46 /* Carbon.framework */; }; 331218290F3C007A006CB2B0 /* renderer_glue.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD80EAE868600EBCFC0 /* renderer_glue.cc */; }; @@ -691,6 +704,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 33017F840F585E8500B6FA6D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4D7BF2E90E9D46A4009A6919 /* Project object */; + proxyType = 1; + remoteGlobalIDString = E45060E30EE87B86003BE099; + remoteInfo = app; + }; 33121EDE0F3CF45B006CB2B0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4D7BFE5B0E9D52DC009A6919 /* icu.xcodeproj */; @@ -1954,6 +1974,8 @@ 26D97CE692D919FEB1521E43 /* ssl_error_info.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ssl_error_info.cc; path = ssl/ssl_error_info.cc; sourceTree = "<group>"; }; 28AA584AB2ECFB33C7C7FD8A /* template_url_parser.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url_parser.cc; sourceTree = "<group>"; }; 2F904214F0F0BA780D8DC4C9 /* dev_tools_client.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dev_tools_client.cc; sourceTree = "<group>"; }; + 33017F2E0F575FC600B6FA6D /* keystone_glue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keystone_glue.h; sourceTree = "<group>"; }; + 33017F2F0F575FC600B6FA6D /* keystone_glue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = keystone_glue.m; sourceTree = "<group>"; }; 331B93A90F3BF2B9008B1C46 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 331B93AB0F3BF2DA008B1C46 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_thread_unittest.cc; sourceTree = "<group>"; }; @@ -4458,6 +4480,8 @@ E45062EA0EE9877F003BE099 /* chrome_dll_main.cc */, E45060F10EE87D41003BE099 /* chrome_exe_main.mm */, E43A78240F17985E00ABD5D1 /* scoped_ole_initializer.h */, + 33017F2E0F575FC600B6FA6D /* keystone_glue.h */, + 33017F2F0F575FC600B6FA6D /* keystone_glue.m */, ); path = app; sourceTree = "<group>"; @@ -5105,6 +5129,7 @@ 4D7BFB040E9D4B8C009A6919 /* All */, E45076900F1532CE003BE099 /* Generate Headers */, E45060E30EE87B86003BE099 /* app */, + 33017F800F585E4C00B6FA6D /* app_packaging */, 4D7BF3050E9D477E009A6919 /* browser */, 4D7BFC190E9D4CB9009A6919 /* common */, 4D640CEA0EAE86BD00EBCFC0 /* renderer */, @@ -5479,6 +5504,19 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 33017F7F0F585E4C00B6FA6D /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/sh\n\nPACKAGER=\"${PROJECT_DIR}/tools/mac/package_chrome.sh\"\nif [ -f \"${PACKAGER}\" ]; then\n \"${PACKAGER}\"\nfi\n\n"; + }; 4D3D54770EC3A4D800650CA0 /* Strip If Needed */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -6069,12 +6107,18 @@ E42155D80F3240AF00A4A951 /* tab_strip_view.mm in Sources */, E46C519A0F2A20CC00B393B8 /* toolbar_button_cell.mm in Sources */, E46C51640F2A1DAB00B393B8 /* toolbar_view.mm in Sources */, + 33017F300F575FC600B6FA6D /* keystone_glue.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 33017F850F585E8500B6FA6D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E45060E30EE87B86003BE099 /* app */; + targetProxy = 33017F840F585E8500B6FA6D /* PBXContainerItemProxy */; + }; 33121EDF0F3CF45B006CB2B0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = icutu; @@ -6780,6 +6824,27 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 33017F810F585E4D00B6FA6D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + PRODUCT_NAME = "app packaging"; + }; + name = Debug; + }; + 33017F820F585E4D00B6FA6D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PRODUCT_NAME = "app packaging"; + ZERO_LINK = NO; + }; + name = Release; + }; 4D1F59EC0F2A6B590040C1E3 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 4D7BF2FD0E9D46E6009A6919 /* executable.xcconfig */; @@ -7144,6 +7209,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 33017F8B0F585EA300B6FA6D /* Build configuration list for PBXAggregateTarget "app_packaging" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33017F810F585E4D00B6FA6D /* Debug */, + 33017F820F585E4D00B6FA6D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 4D1F59F90F2A6B840040C1E3 /* Build configuration list for PBXNativeTarget "image_diff" */ = { isa = XCConfigurationList; buildConfigurations = ( |