Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrnorm committed Oct 1, 2024
1 parent 981180a commit 41b8ff8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pkg/chromemsg/configure_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,37 @@ import (
"golang.org/x/sys/windows/registry"
)

// Configure writes native messaging host configuration to various well-known folders,
// including Google Chrome, Arc, Microsoft Edge, and Vivaldi.
//
// See: https://developer.chrome.com/docs/extensions/develop/concepts/native-messaging#native-messaging-host
//
// The resulting file looks like this:
//
// {
// "name": "io.commonfate.granted",
// "description": "Granted BrowserSupport",
// "path": "/usr/local/bin/granted",
// "type": "stdio",
// "allowed_origins": [
// "chrome-extension://fcipjekpmlpmiikgdecbjbcpmenmceoh/"
// ]
// }
func ConfigureHost() error {
return configureWindows()
}

// configureWindows configures Windows registry entries pointing to the native messaging manifest file.
//
// From the Chrome developer documentation:
//
// "On Windows, the manifest file can be located anywhere in the file system.
// The application installer must create a registry key, either
// HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application
// or HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application,
// and set the default value of that key to the full path to the manifest file.
func configureWindows() error {
// Registry paths

paths := []string{
"Software\\Google\\Chrome\\NativeMessagingHosts",
"Software\\Chromium\\NativeMessagingHosts",
Expand Down

0 comments on commit 41b8ff8

Please sign in to comment.