Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Added loadURL and setProxy functionality #307

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Event struct {
Username string `json:"username,omitempty"`
WindowID string `json:"windowId,omitempty"`
WindowOptions *WindowOptions `json:"windowOptions,omitempty"`
Proxy string `json:"proxy,omitempty"`
true-zero marked this conversation as resolved.
Show resolved Hide resolved
}

// EventAuthInfo represents an event auth info
Expand Down
22 changes: 22 additions & 0 deletions window.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
EventNameWindowCmdWebContentsCloseDevTools = "window.cmd.web.contents.close.dev.tools"
EventNameWindowCmdWebContentsOpenDevTools = "window.cmd.web.contents.open.dev.tools"
EventNameWindowCmdWebContentsExecuteJavaScript = "window.cmd.web.contents.execute.javascript"
EventNameWindowCmdWebContentsSetProxy = "window.cmd.web.contents.set.proxy"
EventNameWindowCmdLoadUrl = "window.cmd.load.url"
true-zero marked this conversation as resolved.
Show resolved Hide resolved
EventNameWindowEventBlur = "window.event.blur"
EventNameWindowEventClosed = "window.event.closed"
EventNameWindowEventDidFinishLoad = "window.event.did.finish.load"
Expand All @@ -54,8 +56,10 @@ const (
EventNameWindowEventUnresponsive = "window.event.unresponsive"
EventNameWindowEventDidGetRedirectRequest = "window.event.did.get.redirect.request"
EventNameWindowEventWebContentsExecutedJavaScript = "window.event.web.contents.executed.javascript"
EventNameWindowEventWebContentsSetProxy = "window.event.web.contents.set.proxy"
EventNameWindowEventWillNavigate = "window.event.will.navigate"
EventNameWindowEventUpdatedCustomOptions = "window.event.updated.custom.options"
EventNameWindowLoadUrl = "window.event.load.url"
true-zero marked this conversation as resolved.
Show resolved Hide resolved
)

// Title bar styles
Expand Down Expand Up @@ -534,6 +538,24 @@ func (w *Window) Unmaximize() (err error) {
return
}

// Loads the url
func (w *Window) LoadUrl(url string) (err error) {
true-zero marked this conversation as resolved.
Show resolved Hide resolved
if err = w.ctx.Err(); err != nil {
return
}
_, err = synchronousEvent(w.ctx, w, w.w, Event{Name: EventNameWindowCmdLoadUrl, TargetID: w.id, URL: url}, EventNameWindowLoadUrl)
return
}

// Sets the proxy
func (w *Window) SetProxy(proxy string) (err error) {
true-zero marked this conversation as resolved.
Show resolved Hide resolved
if err = w.ctx.Err(); err != nil {
return
}
_, err = synchronousEvent(w.ctx, w, w.w, Event{Name: EventNameWindowCmdWebContentsSetProxy, TargetID: w.id, Proxy: proxy}, EventNameWindowEventWebContentsSetProxy)
return
}

// UpdateCustomOptions updates the window custom options
func (w *Window) UpdateCustomOptions(o WindowCustomOptions) (err error) {
if err = w.ctx.Err(); err != nil {
Expand Down