File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,18 @@ const char *getExpirationDate(char *expirationDate){
188188
189189 return "";
190190}
191+
192+ const char *getDefaultBrowserName() {
193+ NSURL *defaultBrowserURL = [[NSWorkspace sharedWorkspace] URLForApplicationToOpenURL:[NSURL URLWithString:@"http://"]];
194+ if (defaultBrowserURL) {
195+ NSBundle *defaultBrowserBundle = [NSBundle bundleWithURL:defaultBrowserURL];
196+ NSString *defaultBrowser = [defaultBrowserBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
197+
198+ return [defaultBrowser cStringUsingEncoding:[NSString defaultCStringEncoding]];
199+ }
200+
201+ return "";
202+ }
191203*/
192204import "C"
193205import (
@@ -260,3 +272,10 @@ func GetExpirationDate() (string, error) {
260272 date := C .GoString (dateString )
261273 return date , nil
262274}
275+
276+ // GetDefaultBrowserName returns the name of the default browser
277+ func GetDefaultBrowserName () string {
278+ log .Infof ("Retrieving default browser name" )
279+ p := C .getDefaultBrowserName ()
280+ return C .GoString (p )
281+ }
Original file line number Diff line number Diff line change @@ -48,3 +48,9 @@ func GetExpirationDate() (string, error) {
4848 log .Warn ("platform not supported for retrieving certificates expiration date" )
4949 return "" , errors .New ("platform not supported for retrieving certificates expiration date" )
5050}
51+
52+ // GetDefaultBrowserName won't do anything on unsupported Operative Systems
53+ func GetDefaultBrowserName () string {
54+ log .Warn ("platform not supported for retrieving default browser name" )
55+ return ""
56+ }
You can’t perform that action at this time.
0 commit comments