func (c *Browser) GetWindowForTargetWithParams(ctx context.Context, v *BrowserGetWindowForTargetParams) (int, *BrowserBounds, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getWindowForTarget", Params: v})
	if err != nil {
		return 0, nil, err
	}
	var chromeData struct {
		Result struct {
			WindowId int
			Bounds   *BrowserBounds
		}
	}
	if resp == nil {
		return 0, nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return 0, nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return 0, nil, err
	}
	return chromeData.Result.WindowId, chromeData.Result.Bounds, nil
}
GetWindowForTargetWithParams - Get the browser window that contains the devtools target.
Returns -  windowId - Browser window id. bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
package gcdapi
import (
	"context"
	"github.com/wirepair/gcd/v2/gcdmessage"
)
type BrowserBounds struct {
	Left        int    `json:"left,omitempty"`         
	Top         int    `json:"top,omitempty"`          
	Width       int    `json:"width,omitempty"`        
	Height      int    `json:"height,omitempty"`       
	WindowState string `json:"windowState,omitempty"`  
}
type BrowserPermissionDescriptor struct {
	Name                     string `json:"name"`                                
	Sysex                    bool   `json:"sysex,omitempty"`                     
	UserVisibleOnly          bool   `json:"userVisibleOnly,omitempty"`           
	AllowWithoutSanitization bool   `json:"allowWithoutSanitization,omitempty"`  
	PanTiltZoom              bool   `json:"panTiltZoom,omitempty"`               
}
type BrowserBucket struct {
	Low   int `json:"low"`    
	High  int `json:"high"`   
	Count int `json:"count"`  
}
type BrowserHistogram struct {
	Name    string           `json:"name"`     
	Sum     int              `json:"sum"`      
	Count   int              `json:"count"`    
	Buckets []*BrowserBucket `json:"buckets"`  
}
type BrowserDownloadWillBeginEvent struct {
	Method string `json:"method"`
	Params struct {
		FrameId           string `json:"frameId"`            
		Guid              string `json:"guid"`               
		Url               string `json:"url"`                
		SuggestedFilename string `json:"suggestedFilename"`  
	} `json:"Params,omitempty"`
}
type BrowserDownloadProgressEvent struct {
	Method string `json:"method"`
	Params struct {
		Guid          string  `json:"guid"`           
		TotalBytes    float64 `json:"totalBytes"`     
		ReceivedBytes float64 `json:"receivedBytes"`  
		State         string  `json:"state"`          
	} `json:"Params,omitempty"`
}
type Browser struct {
	target gcdmessage.ChromeTargeter
}
func NewBrowser(target gcdmessage.ChromeTargeter) *Browser {
	c := &Browser{target: target}
	return c
}
type BrowserSetPermissionParams struct {
	Permission *BrowserPermissionDescriptor `json:"permission"`
	Setting string `json:"setting"`
	Origin string `json:"origin,omitempty"`
	BrowserContextId string `json:"browserContextId,omitempty"`
}
func (c *Browser) SetPermissionWithParams(ctx context.Context, v *BrowserSetPermissionParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.setPermission", Params: v})
}
func (c *Browser) SetPermission(ctx context.Context, permission *BrowserPermissionDescriptor, setting string, origin string, browserContextId string) (*gcdmessage.ChromeResponse, error) {
	var v BrowserSetPermissionParams
	v.Permission = permission
	v.Setting = setting
	v.Origin = origin
	v.BrowserContextId = browserContextId
	return c.SetPermissionWithParams(ctx, &v)
}
type BrowserGrantPermissionsParams struct {
	Permissions []string `json:"permissions"`
	Origin string `json:"origin,omitempty"`
	BrowserContextId string `json:"browserContextId,omitempty"`
}
func (c *Browser) GrantPermissionsWithParams(ctx context.Context, v *BrowserGrantPermissionsParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.grantPermissions", Params: v})
}
func (c *Browser) GrantPermissions(ctx context.Context, permissions []string, origin string, browserContextId string) (*gcdmessage.ChromeResponse, error) {
	var v BrowserGrantPermissionsParams
	v.Permissions = permissions
	v.Origin = origin
	v.BrowserContextId = browserContextId
	return c.GrantPermissionsWithParams(ctx, &v)
}
type BrowserResetPermissionsParams struct {
	BrowserContextId string `json:"browserContextId,omitempty"`
}
func (c *Browser) ResetPermissionsWithParams(ctx context.Context, v *BrowserResetPermissionsParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.resetPermissions", Params: v})
}
func (c *Browser) ResetPermissions(ctx context.Context, browserContextId string) (*gcdmessage.ChromeResponse, error) {
	var v BrowserResetPermissionsParams
	v.BrowserContextId = browserContextId
	return c.ResetPermissionsWithParams(ctx, &v)
}
type BrowserSetDownloadBehaviorParams struct {
	Behavior string `json:"behavior"`
	BrowserContextId string `json:"browserContextId,omitempty"`
	DownloadPath string `json:"downloadPath,omitempty"`
	EventsEnabled bool `json:"eventsEnabled,omitempty"`
}
func (c *Browser) SetDownloadBehaviorWithParams(ctx context.Context, v *BrowserSetDownloadBehaviorParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.setDownloadBehavior", Params: v})
}
func (c *Browser) SetDownloadBehavior(ctx context.Context, behavior string, browserContextId string, downloadPath string, eventsEnabled bool) (*gcdmessage.ChromeResponse, error) {
	var v BrowserSetDownloadBehaviorParams
	v.Behavior = behavior
	v.BrowserContextId = browserContextId
	v.DownloadPath = downloadPath
	v.EventsEnabled = eventsEnabled
	return c.SetDownloadBehaviorWithParams(ctx, &v)
}
type BrowserCancelDownloadParams struct {
	Guid string `json:"guid"`
	BrowserContextId string `json:"browserContextId,omitempty"`
}
func (c *Browser) CancelDownloadWithParams(ctx context.Context, v *BrowserCancelDownloadParams) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.cancelDownload", Params: v})
}
func (c *Browser) CancelDownload(ctx context.Context, guid string, browserContextId string) (*gcdmessage.ChromeResponse, error) {
	var v BrowserCancelDownloadParams
	v.Guid = guid
	v.BrowserContextId = browserContextId
	return c.CancelDownloadWithParams(ctx, &v)
}
func (c *Browser) Close(ctx context.Context) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.close"})
}
func (c *Browser) Crash(ctx context.Context) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.crash"})
}
func (c *Browser) CrashGpuProcess(ctx context.Context) (*gcdmessage.ChromeResponse, error) {
	return c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.crashGpuProcess"})
}
func (c *Browser) GetVersion(ctx context.Context) (string, string, string, string, string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getVersion"})
	if err != nil {
		return "", "", "", "", "", err
	}
	var chromeData struct {
		Result struct {
			ProtocolVersion string
			Product         string
			Revision        string
			UserAgent       string
			JsVersion       string
		}
	}
	if resp == nil {
		return "", "", "", "", "", &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", "", "", "", "", &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", "", "", "", "", err
	}
	return chromeData.Result.ProtocolVersion, chromeData.Result.Product, chromeData.Result.Revision, chromeData.Result.UserAgent, chromeData.Result.JsVersion, nil
}
func (c *Browser) GetBrowserCommandLine(ctx context.Context) ([]string, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getBrowserCommandLine"})
	if err != nil {
		return nil, err
	}
	var chromeData struct {
		Result struct {
			Arguments []string
		}
	}
	if resp == nil {
		return nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return nil, err
	}
	return chromeData.Result.Arguments, nil
}
type BrowserGetHistogramsParams struct {
	Query string `json:"query,omitempty"`
	Delta bool `json:"delta,omitempty"`
}
func (c *Browser) GetHistogramsWithParams(ctx context.Context, v *BrowserGetHistogramsParams) ([]*BrowserHistogram, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getHistograms", Params: v})
	if err != nil {
		return nil, err
	}
	var chromeData struct {
		Result struct {
			Histograms []*BrowserHistogram
		}
	}
	if resp == nil {
		return nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return nil, err
	}
	return chromeData.Result.Histograms, nil
}
func (c *Browser) GetHistograms(ctx context.Context, query string, delta bool) ([]*BrowserHistogram, error) {
	var v BrowserGetHistogramsParams
	v.Query = query
	v.Delta = delta
	return c.GetHistogramsWithParams(ctx, &v)
}
type BrowserGetHistogramParams struct {
	Name string `json:"name"`
	Delta bool `json:"delta,omitempty"`
}
func (c *Browser) GetHistogramWithParams(ctx context.Context, v *BrowserGetHistogramParams) (*BrowserHistogram, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getHistogram", Params: v})
	if err != nil {
		return nil, err
	}
	var chromeData struct {
		Result struct {
			Histogram *BrowserHistogram
		}
	}
	if resp == nil {
		return nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return nil, err
	}
	return chromeData.Result.Histogram, nil
}
func (c *Browser) GetHistogram(ctx context.Context, name string, delta bool) (*BrowserHistogram, error) {
	var v BrowserGetHistogramParams
	v.Name = name
	v.Delta = delta
	return c.GetHistogramWithParams(ctx, &v)
}
type BrowserGetWindowBoundsParams struct {
	WindowId int `json:"windowId"`
}
func (c *Browser) GetWindowBoundsWithParams(ctx context.Context, v *BrowserGetWindowBoundsParams) (*BrowserBounds, error) {
	resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Browser.getWindowBounds", Params: v})
	if err != nil {
		return nil, err
	}
	var chromeData struct {
		Result struct {
			Bounds *BrowserBounds
		}
	}
	if resp == nil {
		return nil, &gcdmessage.ChromeEmptyResponseErr{}
	}
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}
	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return nil, err
	}
	return chromeData.Result.Bounds, nil
}
func (c *Browser) GetWindowBounds(ctx context.Context, windowId int) (*BrowserBounds, error) {
	var v BrowserGetWindowBoundsParams
	v.WindowId = windowId
	return c.GetWindowBoundsWithParams(ctx, &v)
}
type BrowserGetWindowForTargetParams struct {
	TargetId string `json:"targetId,omitempty"`
}