chromedp/cdp/browser/browser.go

117 lines
3.9 KiB
Go
Raw Normal View History

// Package browser provides the Chrome Debugging Protocol
// commands, types, and events for the Browser domain.
//
// The Browser domain defines methods and events for browser managing.
//
// Generated by the chromedp-gen command.
package browser
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/target"
)
// GetWindowForTargetParams get the browser window that contains the devtools
// target.
type GetWindowForTargetParams struct {
TargetID target.ID `json:"targetId"` // Devtools agent host id.
}
// GetWindowForTarget get the browser window that contains the devtools
// target.
//
// parameters:
// targetID - Devtools agent host id.
func GetWindowForTarget(targetID target.ID) *GetWindowForTargetParams {
return &GetWindowForTargetParams{
TargetID: targetID,
}
}
// GetWindowForTargetReturns return values.
type GetWindowForTargetReturns struct {
WindowID WindowID `json:"windowId,omitempty"` // Browser window id.
Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
}
// Do executes Browser.getWindowForTarget against the provided context and
// target handler.
//
// returns:
// windowID - Browser window id.
// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
func (p *GetWindowForTargetParams) Do(ctxt context.Context, h cdp.Handler) (windowID WindowID, bounds *Bounds, err error) {
// execute
var res GetWindowForTargetReturns
err = h.Execute(ctxt, cdp.CommandBrowserGetWindowForTarget, p, &res)
if err != nil {
return 0, nil, err
}
return res.WindowID, res.Bounds, nil
}
// SetWindowBoundsParams set position and/or size of the browser window.
type SetWindowBoundsParams struct {
WindowID WindowID `json:"windowId"` // Browser window id.
Bounds *Bounds `json:"bounds"` // New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
}
// SetWindowBounds set position and/or size of the browser window.
//
// parameters:
// windowID - Browser window id.
// bounds - New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
func SetWindowBounds(windowID WindowID, bounds *Bounds) *SetWindowBoundsParams {
return &SetWindowBoundsParams{
WindowID: windowID,
Bounds: bounds,
}
}
// Do executes Browser.setWindowBounds against the provided context and
// target handler.
func (p *SetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandBrowserSetWindowBounds, p, nil)
}
// GetWindowBoundsParams get position and size of the browser window.
type GetWindowBoundsParams struct {
WindowID WindowID `json:"windowId"` // Browser window id.
}
// GetWindowBounds get position and size of the browser window.
//
// parameters:
// windowID - Browser window id.
func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams {
return &GetWindowBoundsParams{
WindowID: windowID,
}
}
// GetWindowBoundsReturns return values.
type GetWindowBoundsReturns struct {
Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
}
// Do executes Browser.getWindowBounds against the provided context and
// target handler.
//
// returns:
// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
func (p *GetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (bounds *Bounds, err error) {
// execute
var res GetWindowBoundsReturns
err = h.Execute(ctxt, cdp.CommandBrowserGetWindowBounds, p, &res)
if err != nil {
return nil, err
}
return res.Bounds, nil
}