Skip to content

Commit ff75d03

Browse files
committed
Add option to override bundle identifier
with environment variable
1 parent d7923e1 commit ff75d03

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

chrome-cli/App.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@interface App : NSObject
1313

14+
- (id)initWithBundleIdentifier:(NSString *)bundleIdentifier;
1415
- (void)listWindows:(Arguments *)args;
1516
- (void)listTabs:(Arguments *)args;
1617
- (void)listTabsLinks:(Arguments *)args;

chrome-cli/App.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@
1111

1212

1313
static NSInteger const kMaxLaunchTimeInSeconds = 15;
14-
static NSString * const kVersion = @"1.6.0";
14+
static NSString * const kVersion = @"1.7.0";
1515
static NSString * const kJsPrintSource = @"(function() { return document.getElementsByTagName('html')[0].outerHTML })();";
1616

1717

18-
@implementation App
18+
@implementation App {
19+
NSString *bundleIdentifier;
20+
}
21+
22+
- (id)initWithBundleIdentifier:(NSString *)bundleIdentifier {
23+
self = [super init];
24+
self->bundleIdentifier = bundleIdentifier;
25+
return self;
26+
}
1927

2028

2129
- (chromeApplication *)chrome {
22-
chromeApplication *chrome = [SBApplication applicationWithBundleIdentifier:@"com.google.Chrome"];
30+
chromeApplication *chrome = [SBApplication applicationWithBundleIdentifier:self->bundleIdentifier];
2331

2432
if ([chrome isRunning]) {
2533
return chrome;

chrome-cli/main.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
int main(int argc, const char * argv[])
1414
{
15-
App *app = [[App alloc] init];
15+
NSString *bundleIdentifier = [[[NSProcessInfo processInfo] environment] objectForKey:@"CHROME_BUNDLE_IDENTIFIER"];
16+
if (!bundleIdentifier) {
17+
bundleIdentifier = @"com.google.Chrome";
18+
}
19+
20+
App *app = [[App alloc] initWithBundleIdentifier:bundleIdentifier];
1621
Argonaut *argonaut = [[Argonaut alloc] init];
1722

1823
[argonaut add:@"-h" target:argonaut action:@selector(printUsage:) description:@"Print help"];

0 commit comments

Comments
 (0)