Skip to content

Add a function to check what is the default browser #942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #907
Xayton opened this issue Apr 29, 2024 · 1 comment · Fixed by #941
Closed
Tracked by #907

Add a function to check what is the default browser #942

Xayton opened this issue Apr 29, 2024 · 1 comment · Fixed by #941
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@Xayton
Copy link
Contributor

Xayton commented Apr 29, 2024

In order to show the message about the "HTTPS Certificates" only to users that actually need it, we could check the default browser. If the user's default browser is Safari, we ask to install/update the certificates, otherwise we do nothing.

@Xayton Xayton self-assigned this Apr 29, 2024
@Xayton Xayton added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Apr 29, 2024
@Xayton
Copy link
Contributor Author

Xayton commented Apr 29, 2024

Here the code that could be used by CGO:

const char *getDefaultBrowserName() {
    NSURL *defaultBrowserURL = [[NSWorkspace sharedWorkspace] URLForApplicationToOpenURL:[NSURL URLWithString:@"http://"]];
    if (defaultBrowserURL) {
        NSBundle *defaultBrowserBundle = [NSBundle bundleWithURL:defaultBrowserURL];
        NSString *defaultBrowser = [defaultBrowserBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
        
        return [defaultBrowser cStringUsingEncoding:[NSString defaultCStringEncoding]];
    }

    return nil;
}

CC: @MatteoPologruto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
2 participants