-
Notifications
You must be signed in to change notification settings - Fork 48
/
domain.go
125 lines (107 loc) · 4.26 KB
/
domain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Code generated by cdpgen. DO NOT EDIT.
// Package security implements the Security domain. Security
package security
import (
"context"
"github.com/mafredri/cdp/protocol/internal"
"github.com/mafredri/cdp/rpcc"
)
// domainClient is a client for the Security domain. Security
type domainClient struct{ conn *rpcc.Conn }
// NewClient returns a client for the Security domain with the connection set to conn.
func NewClient(conn *rpcc.Conn) *domainClient {
return &domainClient{conn: conn}
}
// Disable invokes the Security method. Disables tracking security state
// changes.
func (d *domainClient) Disable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Security.disable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Security", Op: "Disable", Err: err}
}
return
}
// Enable invokes the Security method. Enables tracking security state
// changes.
func (d *domainClient) Enable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Security.enable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Security", Op: "Enable", Err: err}
}
return
}
// SetIgnoreCertificateErrors invokes the Security method. Enable/disable
// whether all certificate errors should be ignored.
func (d *domainClient) SetIgnoreCertificateErrors(ctx context.Context, args *SetIgnoreCertificateErrorsArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Security.setIgnoreCertificateErrors", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Security.setIgnoreCertificateErrors", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Security", Op: "SetIgnoreCertificateErrors", Err: err}
}
return
}
// HandleCertificateError invokes the Security method. Handles a certificate
// error that fired a certificateError event.
func (d *domainClient) HandleCertificateError(ctx context.Context, args *HandleCertificateErrorArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Security.handleCertificateError", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Security.handleCertificateError", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Security", Op: "HandleCertificateError", Err: err}
}
return
}
// SetOverrideCertificateErrors invokes the Security method. Enable/disable
// overriding certificate errors. If enabled, all certificate error events need
// to be handled by the DevTools client and should be answered with
// `handleCertificateError` commands.
func (d *domainClient) SetOverrideCertificateErrors(ctx context.Context, args *SetOverrideCertificateErrorsArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Security.setOverrideCertificateErrors", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Security.setOverrideCertificateErrors", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Security", Op: "SetOverrideCertificateErrors", Err: err}
}
return
}
func (d *domainClient) CertificateError(ctx context.Context) (CertificateErrorClient, error) {
s, err := rpcc.NewStream(ctx, "Security.certificateError", d.conn)
if err != nil {
return nil, err
}
return &certificateErrorClient{Stream: s}, nil
}
type certificateErrorClient struct{ rpcc.Stream }
// GetStream returns the original Stream for use with cdp.Sync.
func (c *certificateErrorClient) GetStream() rpcc.Stream { return c.Stream }
func (c *certificateErrorClient) Recv() (*CertificateErrorReply, error) {
event := new(CertificateErrorReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Security", Op: "CertificateError Recv", Err: err}
}
return event, nil
}
func (d *domainClient) SecurityStateChanged(ctx context.Context) (StateChangedClient, error) {
s, err := rpcc.NewStream(ctx, "Security.securityStateChanged", d.conn)
if err != nil {
return nil, err
}
return &stateChangedClient{Stream: s}, nil
}
type stateChangedClient struct{ rpcc.Stream }
// GetStream returns the original Stream for use with cdp.Sync.
func (c *stateChangedClient) GetStream() rpcc.Stream { return c.Stream }
func (c *stateChangedClient) Recv() (*StateChangedReply, error) {
event := new(StateChangedReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Security", Op: "SecurityStateChanged Recv", Err: err}
}
return event, nil
}