Skip to content

Commit

Permalink
fix: shouldn't reset the user preferences by default
Browse files Browse the repository at this point in the history
Resolve #1041
  • Loading branch information
ysmood committed Apr 17, 2024
1 parent a565903 commit 4efda70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func New() *Launcher {
// enable headless by default
flags.Headless: nil,

flags.Preferences: {`{"plugins":{"always_open_pdf_externally": true}}`},

// to disable the init blank window
"no-first-run": nil,
"no-startup-window": nil,
Expand Down Expand Up @@ -255,6 +253,12 @@ func (l *Launcher) Preferences(pref string) *Launcher {
return l.Set(flags.Preferences, pref)
}

// AlwaysOpenPDFExternally switch.
// It will set chromium user preferences to enable the always_open_pdf_externally option.
func (l *Launcher) AlwaysOpenPDFExternally() *Launcher {
return l.Set(flags.Preferences, `{"plugins":{"always_open_pdf_externally": true}}`)
}

// Leakless switch. If enabled, the browser will be force killed after the Go process exits.
// The doc of leakless: https://github.com/ysmood/leakless.
func (l *Launcher) Leakless(enable bool) *Launcher {
Expand Down
2 changes: 1 addition & 1 deletion lib/launcher/launcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestLaunch(t *testing.T) {
defaults.Proxy = "test.com"
defer func() { defaults.ResetWith("") }()

l := launcher.New().Preferences("")
l := launcher.New().Preferences("").AlwaysOpenPDFExternally()
defer l.Kill()

u := l.MustLaunch()
Expand Down

0 comments on commit 4efda70

Please sign in to comment.