Mac 命令行安装Chrome插件
2015-04-11 10:06
323 查看
1. 在终端调用命令行实现Chrome插件安装
/Applications/Google\Chrome.app/Contents/MacOS/Google\ Chrome --enable-easy-off-store-extension-install extensionPath其中extensionPath是指的插件文件位置(Chrome插件文件的后缀名是crx),例如~/Desktop/chromeExtension.crx
注意:安装插件之前要确保Chrome浏览器不在运行
2. 通过代码实现Chrome插件安装
- (void)startInstallChromeExtension {NSURL *url = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.google.Chrome"];
if (url) {
NSString *chromeExtensionPath = [[NSBundle mainBundle] pathForResource:EXTENSIONSOURCENAME ofType:@"crx" inDirectory:EXTENSIONDIRNAME];
NSDictionary *configuration = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:@"--enable-easy-off-store-extension-install",chromeExtensionPath,nil],NSWorkspaceLaunchConfigurationArguments, nil];
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:url
options:NSWorkspaceLaunchDefault
configuration:configuration error:nil];
}
}
- (IBAction)installChromeExtension:(id)sender {
NSArray *runningChromes = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.google.Chrome"];
if ([runningChromes count] > 0) {
NSAlert * alert = [NSAlert alertWithMessageText:NSLocalizedString(@"安装Chrome插件,需要关闭正在运行的Chrome浏览器,是否允许?", @"")
defaultButton:NSLocalizedString(@"OK", @"")
alternateButton:NSLocalizedString(@"Cancel", @"")
otherButton:nil
informativeTextWithFormat:@""];
NSInteger result = [alert runModal];
if (result == NSAlertDefaultReturn ) {
for (int i = 0; i < [runningChromes count]; i++) {
[(NSRunningApplication *)[runningChromes objectAtIndex:i] forceTerminate];
}
[self performSelector:@selector(startInstallChromeExtension) withObject:nil afterDelay:0.5];
}
}
else {
[self performSelector:@selector(startInstallChromeExtension) withObject:nil afterDelay:0.5];
}
}
源引:http://blog.csdn.net/lexiaoyao20/article/details/10406143
相关文章推荐
- Mac 命令行安装Chrome插件
- Mac下Chrome的插件安装目录在哪?
- mac本 chrome jsonView插件安装实用教程
- MAC OS X 命令行工具Terminal实用插件oh-my-zsh官方说明与安装引导
- 检测IE8及以下的浏览器并安装chrome frame插件
- Eclipse安装OpenExplorer插件(Mac、Windows通用)
- Fedora15上安装Chrome和lastpass插件
- chrome 浏览器中关于media player11插件的安装
- 谷歌浏览器Chrome上安装插件
- 下载chrome插件和离线安装CRX文件的方法
- chrome安装插件 "发生错误" 提示处理方法
- Chrome Flash插件的手动安装方法
- 【怎么安装Chrome插件】安装Chrome第三方插件
- mac命令行安装htop
- Chrome插件安装文件提取方法及 PwdHash Port 的插件下载
- Eclipse安装OpenExplorer插件(Mac、Windows通用)
- chrome离线安装插件
- Chrome Flash插件的手动安装方法
- hadoop学习(mac 上安装 hadoop伪分布式以及hadoop的eclipse插件)
- 下载chrome插件和离线安装CRX文件的方法