133 lines
2.7 KiB
Go
133 lines
2.7 KiB
Go
|
// Package deviceorientation provides the Chrome Debugging Protocol
|
||
|
// commands, types, and events for the Chrome DeviceOrientation domain.
|
||
|
//
|
||
|
// Generated by the chromedp-gen command.
|
||
|
package deviceorientation
|
||
|
|
||
|
// AUTOGENERATED. DO NOT EDIT.
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
. "github.com/knq/chromedp/cdp"
|
||
|
"github.com/mailru/easyjson"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
_ BackendNode
|
||
|
_ BackendNodeID
|
||
|
_ ComputedProperty
|
||
|
_ ErrorType
|
||
|
_ Frame
|
||
|
_ FrameID
|
||
|
_ LoaderID
|
||
|
_ Message
|
||
|
_ MessageError
|
||
|
_ MethodType
|
||
|
_ Node
|
||
|
_ NodeID
|
||
|
_ NodeType
|
||
|
_ PseudoType
|
||
|
_ RGBA
|
||
|
_ ShadowRootType
|
||
|
_ Timestamp
|
||
|
)
|
||
|
|
||
|
// SetDeviceOrientationOverrideParams overrides the Device Orientation.
|
||
|
type SetDeviceOrientationOverrideParams struct {
|
||
|
Alpha float64 `json:"alpha"` // Mock alpha
|
||
|
Beta float64 `json:"beta"` // Mock beta
|
||
|
Gamma float64 `json:"gamma"` // Mock gamma
|
||
|
}
|
||
|
|
||
|
// SetDeviceOrientationOverride overrides the Device Orientation.
|
||
|
//
|
||
|
// parameters:
|
||
|
// alpha - Mock alpha
|
||
|
// beta - Mock beta
|
||
|
// gamma - Mock gamma
|
||
|
func SetDeviceOrientationOverride(alpha float64, beta float64, gamma float64) *SetDeviceOrientationOverrideParams {
|
||
|
return &SetDeviceOrientationOverrideParams{
|
||
|
Alpha: alpha,
|
||
|
Beta: beta,
|
||
|
Gamma: gamma,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Do executes DeviceOrientation.setDeviceOrientationOverride.
|
||
|
func (p *SetDeviceOrientationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
|
||
|
if ctxt == nil {
|
||
|
ctxt = context.Background()
|
||
|
}
|
||
|
|
||
|
// marshal
|
||
|
buf, err := easyjson.Marshal(p)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// execute
|
||
|
ch := h.Execute(ctxt, CommandDeviceOrientationSetDeviceOrientationOverride, easyjson.RawMessage(buf))
|
||
|
|
||
|
// read response
|
||
|
select {
|
||
|
case res := <-ch:
|
||
|
if res == nil {
|
||
|
return ErrChannelClosed
|
||
|
}
|
||
|
|
||
|
switch v := res.(type) {
|
||
|
case easyjson.RawMessage:
|
||
|
return nil
|
||
|
|
||
|
case error:
|
||
|
return v
|
||
|
}
|
||
|
|
||
|
case <-ctxt.Done():
|
||
|
return ErrContextDone
|
||
|
}
|
||
|
|
||
|
return ErrUnknownResult
|
||
|
}
|
||
|
|
||
|
// ClearDeviceOrientationOverrideParams clears the overridden Device
|
||
|
// Orientation.
|
||
|
type ClearDeviceOrientationOverrideParams struct{}
|
||
|
|
||
|
// ClearDeviceOrientationOverride clears the overridden Device Orientation.
|
||
|
func ClearDeviceOrientationOverride() *ClearDeviceOrientationOverrideParams {
|
||
|
return &ClearDeviceOrientationOverrideParams{}
|
||
|
}
|
||
|
|
||
|
// Do executes DeviceOrientation.clearDeviceOrientationOverride.
|
||
|
func (p *ClearDeviceOrientationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
|
||
|
if ctxt == nil {
|
||
|
ctxt = context.Background()
|
||
|
}
|
||
|
|
||
|
// execute
|
||
|
ch := h.Execute(ctxt, CommandDeviceOrientationClearDeviceOrientationOverride, Empty)
|
||
|
|
||
|
// read response
|
||
|
select {
|
||
|
case res := <-ch:
|
||
|
if res == nil {
|
||
|
return ErrChannelClosed
|
||
|
}
|
||
|
|
||
|
switch v := res.(type) {
|
||
|
case easyjson.RawMessage:
|
||
|
return nil
|
||
|
|
||
|
case error:
|
||
|
return v
|
||
|
}
|
||
|
|
||
|
case <-ctxt.Done():
|
||
|
return ErrContextDone
|
||
|
}
|
||
|
|
||
|
return ErrUnknownResult
|
||
|
}
|