Skip to content

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

Closed
@Xayton

Description

@Xayton

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.

Activity

self-assigned this
on Apr 29, 2024
Xayton

Xayton commented on Apr 29, 2024

@Xayton
ContributorAuthor

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Add a function to check what is the default browser · Issue #942 · arduino/arduino-create-agent