Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
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 *WindowProxyOptions `json:"proxy,omitempty"`
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this field upwards so that fields are sorted alphabetically?

}

// 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"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this field upwards so that fields are sorted alphabetically?

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"
EventNameWindowLoadedURL = "window.event.loaded.url"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name should be EventNameWindowEventLoadedURL (with Event in the middle)

Also could you move this field upwards so that fields are sorted alphabetically?

)

// 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) {
if err = w.ctx.Err(); err != nil {
return
}
_, err = synchronousEvent(w.ctx, w, w.w, Event{Name: EventNameWindowCmdLoadURL, TargetID: w.id, URL: url}, EventNameWindowLoadedURL)
return
}

// Sets the proxy
func (w *Window) SetProxy(proxy *WindowProxyOptions) (err error) {
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