From 7123283c3e2991feff3b98651768e6148b8857cc Mon Sep 17 00:00:00 2001 From: Kenneth Shaw Date: Mon, 14 Aug 2017 07:59:43 +0700 Subject: [PATCH] Updating to latest protocol.json --- cdp/browser/browser.go | 37 ++++++ cdp/browser/easyjson.go | 180 +++++++++++++++++++++++++++- cdp/cdp.go | 6 +- cdp/cdputil/cdputil.go | 6 +- cdp/security/easyjson.go | 207 ++++++++++++++------------------- cdp/security/security.go | 15 --- cdp/security/types.go | 2 +- cmd/chromedp-gen/protocol.json | 48 ++++++-- 8 files changed, 347 insertions(+), 154 deletions(-) diff --git a/cdp/browser/browser.go b/cdp/browser/browser.go index 935aa2c..3b4dd90 100644 --- a/cdp/browser/browser.go +++ b/cdp/browser/browser.go @@ -55,6 +55,43 @@ func (p *GetWindowForTargetParams) Do(ctxt context.Context, h cdp.Handler) (wind return res.WindowID, res.Bounds, nil } +// GetVersionParams returns version information. +type GetVersionParams struct{} + +// GetVersion returns version information. +func GetVersion() *GetVersionParams { + return &GetVersionParams{} +} + +// GetVersionReturns return values. +type GetVersionReturns struct { + ProtocolVersion string `json:"protocolVersion,omitempty"` // Protocol version. + Product string `json:"product,omitempty"` // Product name. + Revision string `json:"revision,omitempty"` // Product revision. + UserAgent string `json:"userAgent,omitempty"` // User-Agent. + JsVersion string `json:"jsVersion,omitempty"` // V8 version. +} + +// Do executes Browser.getVersion against the provided context and +// target handler. +// +// returns: +// protocolVersion - Protocol version. +// product - Product name. +// revision - Product revision. +// userAgent - User-Agent. +// jsVersion - V8 version. +func (p *GetVersionParams) Do(ctxt context.Context, h cdp.Handler) (protocolVersion string, product string, revision string, userAgent string, jsVersion string, err error) { + // execute + var res GetVersionReturns + err = h.Execute(ctxt, cdp.CommandBrowserGetVersion, nil, &res) + if err != nil { + return "", "", "", "", "", err + } + + return res.ProtocolVersion, res.Product, res.Revision, res.UserAgent, res.JsVersion, nil +} + // SetWindowBoundsParams set position and/or size of the browser window. type SetWindowBoundsParams struct { WindowID WindowID `json:"windowId"` // Browser window id. diff --git a/cdp/browser/easyjson.go b/cdp/browser/easyjson.go index 18ba1c8..1de3633 100644 --- a/cdp/browser/easyjson.go +++ b/cdp/browser/easyjson.go @@ -411,7 +411,175 @@ func (v *GetWindowBoundsParams) UnmarshalJSON(data []byte) error { func (v *GetWindowBoundsParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser4(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(in *jlexer.Lexer, out *Bounds) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(in *jlexer.Lexer, out *GetVersionReturns) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "protocolVersion": + out.ProtocolVersion = string(in.String()) + case "product": + out.Product = string(in.String()) + case "revision": + out.Revision = string(in.String()) + case "userAgent": + out.UserAgent = string(in.String()) + case "jsVersion": + out.JsVersion = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(out *jwriter.Writer, in GetVersionReturns) { + out.RawByte('{') + first := true + _ = first + if in.ProtocolVersion != "" { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"protocolVersion\":") + out.String(string(in.ProtocolVersion)) + } + if in.Product != "" { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"product\":") + out.String(string(in.Product)) + } + if in.Revision != "" { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"revision\":") + out.String(string(in.Revision)) + } + if in.UserAgent != "" { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"userAgent\":") + out.String(string(in.UserAgent)) + } + if in.JsVersion != "" { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"jsVersion\":") + out.String(string(in.JsVersion)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v GetVersionReturns) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v GetVersionReturns) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *GetVersionReturns) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *GetVersionReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(l, v) +} +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser6(in *jlexer.Lexer, out *GetVersionParams) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser6(out *jwriter.Writer, in GetVersionParams) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v GetVersionParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser6(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v GetVersionParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser6(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *GetVersionParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser6(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *GetVersionParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser6(l, v) +} +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(in *jlexer.Lexer, out *Bounds) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -450,7 +618,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(in *jlexer.Lexer, out in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(out *jwriter.Writer, in Bounds) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(out *jwriter.Writer, in Bounds) { out.RawByte('{') first := true _ = first @@ -500,23 +668,23 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v Bounds) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Bounds) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Bounds) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Bounds) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(l, v) } diff --git a/cdp/cdp.go b/cdp/cdp.go index 4192a5d..ab1bd05 100644 --- a/cdp/cdp.go +++ b/cdp/cdp.go @@ -139,7 +139,6 @@ const ( EventSecurityCertificateError MethodType = "Security.certificateError" CommandSecurityEnable MethodType = "Security.enable" CommandSecurityDisable MethodType = "Security.disable" - CommandSecurityShowCertificateViewer MethodType = "Security.showCertificateViewer" CommandSecurityHandleCertificateError MethodType = "Security.handleCertificateError" CommandSecuritySetOverrideCertificateErrors MethodType = "Security.setOverrideCertificateErrors" EventNetworkResourceChangedPriority MethodType = "Network.resourceChangedPriority" @@ -393,6 +392,7 @@ const ( CommandTetheringBind MethodType = "Tethering.bind" CommandTetheringUnbind MethodType = "Tethering.unbind" CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget" + CommandBrowserGetVersion MethodType = "Browser.getVersion" CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds" CommandBrowserGetWindowBounds MethodType = "Browser.getWindowBounds" CommandSchemaGetDomains MethodType = "Schema.getDomains" @@ -668,8 +668,6 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = CommandSecurityEnable case CommandSecurityDisable: *t = CommandSecurityDisable - case CommandSecurityShowCertificateViewer: - *t = CommandSecurityShowCertificateViewer case CommandSecurityHandleCertificateError: *t = CommandSecurityHandleCertificateError case CommandSecuritySetOverrideCertificateErrors: @@ -1176,6 +1174,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = CommandTetheringUnbind case CommandBrowserGetWindowForTarget: *t = CommandBrowserGetWindowForTarget + case CommandBrowserGetVersion: + *t = CommandBrowserGetVersion case CommandBrowserSetWindowBounds: *t = CommandBrowserSetWindowBounds case CommandBrowserGetWindowBounds: diff --git a/cdp/cdputil/cdputil.go b/cdp/cdputil/cdputil.go index b98c04c..5ef56d6 100644 --- a/cdp/cdputil/cdputil.go +++ b/cdp/cdputil/cdputil.go @@ -315,9 +315,6 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandSecurityDisable: return emptyVal, nil - case cdp.CommandSecurityShowCertificateViewer: - return emptyVal, nil - case cdp.CommandSecurityHandleCertificateError: return emptyVal, nil @@ -1083,6 +1080,9 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandBrowserGetWindowForTarget: v = new(browser.GetWindowForTargetReturns) + case cdp.CommandBrowserGetVersion: + v = new(browser.GetVersionReturns) + case cdp.CommandBrowserSetWindowBounds: return emptyVal, nil diff --git a/cdp/security/easyjson.go b/cdp/security/easyjson.go index ec2280a..ba55ae5 100644 --- a/cdp/security/easyjson.go +++ b/cdp/security/easyjson.go @@ -42,10 +42,31 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(in *jlexer.Lexer, out out.Summary = string(in.String()) case "description": out.Description = string(in.String()) - case "hasCertificate": - out.HasCertificate = bool(in.Bool()) case "mixedContentType": (out.MixedContentType).UnmarshalEasyJSON(in) + case "certificate": + if in.IsNull() { + in.Skip() + out.Certificate = nil + } else { + in.Delim('[') + if out.Certificate == nil { + if !in.IsDelim(']') { + out.Certificate = make([]string, 0, 4) + } else { + out.Certificate = []string{} + } + } else { + out.Certificate = (out.Certificate)[:0] + } + for !in.IsDelim(']') { + var v1 string + v1 = string(in.String()) + out.Certificate = append(out.Certificate, v1) + in.WantComma() + } + in.Delim(']') + } default: in.SkipRecursive() } @@ -82,14 +103,25 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(out *jwriter.Writer, out.RawByte(',') } first = false - out.RawString("\"hasCertificate\":") - out.Bool(bool(in.HasCertificate)) + out.RawString("\"mixedContentType\":") + (in.MixedContentType).MarshalEasyJSON(out) if !first { out.RawByte(',') } first = false - out.RawString("\"mixedContentType\":") - (in.MixedContentType).MarshalEasyJSON(out) + out.RawString("\"certificate\":") + if in.Certificate == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v2, v3 := range in.Certificate { + if v2 > 0 { + out.RawByte(',') + } + out.String(string(v3)) + } + out.RawByte(']') + } out.RawByte('}') } @@ -116,66 +148,7 @@ func (v *StateExplanation) UnmarshalJSON(data []byte) error { func (v *StateExplanation) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(in *jlexer.Lexer, out *ShowCertificateViewerParams) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(out *jwriter.Writer, in ShowCertificateViewerParams) { - out.RawByte('{') - first := true - _ = first - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v ShowCertificateViewerParams) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v ShowCertificateViewerParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *ShowCertificateViewerParams) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *ShowCertificateViewerParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(l, v) -} -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(in *jlexer.Lexer, out *SetOverrideCertificateErrorsParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(in *jlexer.Lexer, out *SetOverrideCertificateErrorsParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -206,7 +179,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(out *jwriter.Writer, in SetOverrideCertificateErrorsParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(out *jwriter.Writer, in SetOverrideCertificateErrorsParams) { out.RawByte('{') first := true _ = first @@ -222,27 +195,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v SetOverrideCertificateErrorsParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v SetOverrideCertificateErrorsParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *SetOverrideCertificateErrorsParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *SetOverrideCertificateErrorsParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(in *jlexer.Lexer, out *InsecureContentStatus) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(in *jlexer.Lexer, out *InsecureContentStatus) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -285,7 +258,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(out *jwriter.Writer, in InsecureContentStatus) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(out *jwriter.Writer, in InsecureContentStatus) { out.RawByte('{') first := true _ = first @@ -337,27 +310,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v InsecureContentStatus) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v InsecureContentStatus) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *InsecureContentStatus) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *InsecureContentStatus) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(in *jlexer.Lexer, out *HandleCertificateErrorParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(in *jlexer.Lexer, out *HandleCertificateErrorParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -390,7 +363,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(out *jwriter.Writer, in HandleCertificateErrorParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(out *jwriter.Writer, in HandleCertificateErrorParams) { out.RawByte('{') first := true _ = first @@ -412,27 +385,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v HandleCertificateErrorParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v HandleCertificateErrorParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *HandleCertificateErrorParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *HandleCertificateErrorParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(in *jlexer.Lexer, out *EventSecurityStateChanged) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(in *jlexer.Lexer, out *EventSecurityStateChanged) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -471,17 +444,17 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(in *jlexer.Lexer, ou out.Explanations = (out.Explanations)[:0] } for !in.IsDelim(']') { - var v1 *StateExplanation + var v4 *StateExplanation if in.IsNull() { in.Skip() - v1 = nil + v4 = nil } else { - if v1 == nil { - v1 = new(StateExplanation) + if v4 == nil { + v4 = new(StateExplanation) } - (*v1).UnmarshalEasyJSON(in) + (*v4).UnmarshalEasyJSON(in) } - out.Explanations = append(out.Explanations, v1) + out.Explanations = append(out.Explanations, v4) in.WantComma() } in.Delim(']') @@ -508,7 +481,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(out *jwriter.Writer, in EventSecurityStateChanged) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(out *jwriter.Writer, in EventSecurityStateChanged) { out.RawByte('{') first := true _ = first @@ -533,14 +506,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(out *jwriter.Writer, out.RawString("null") } else { out.RawByte('[') - for v2, v3 := range in.Explanations { - if v2 > 0 { + for v5, v6 := range in.Explanations { + if v5 > 0 { out.RawByte(',') } - if v3 == nil { + if v6 == nil { out.RawString("null") } else { - (*v3).MarshalEasyJSON(out) + (*v6).MarshalEasyJSON(out) } } out.RawByte(']') @@ -569,27 +542,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v EventSecurityStateChanged) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v EventSecurityStateChanged) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *EventSecurityStateChanged) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *EventSecurityStateChanged) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(in *jlexer.Lexer, out *EventCertificateError) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(in *jlexer.Lexer, out *EventCertificateError) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -624,7 +597,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(out *jwriter.Writer, in EventCertificateError) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(out *jwriter.Writer, in EventCertificateError) { out.RawByte('{') first := true _ = first @@ -652,27 +625,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v EventCertificateError) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v EventCertificateError) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *EventCertificateError) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *EventCertificateError) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(in *jlexer.Lexer, out *EnableParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(in *jlexer.Lexer, out *EnableParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -701,7 +674,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(out *jwriter.Writer, in EnableParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(out *jwriter.Writer, in EnableParams) { out.RawByte('{') first := true _ = first @@ -711,27 +684,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v EnableParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *EnableParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity6(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity8(in *jlexer.Lexer, out *DisableParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(in *jlexer.Lexer, out *DisableParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -760,7 +733,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity8(in *jlexer.Lexer, ou in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity8(out *jwriter.Writer, in DisableParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(out *jwriter.Writer, in DisableParams) { out.RawByte('{') first := true _ = first @@ -770,23 +743,23 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity8(out *jwriter.Writer, // MarshalJSON supports json.Marshaler interface func (v DisableParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity8(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity8(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DisableParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity8(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity8(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity7(l, v) } diff --git a/cdp/security/security.go b/cdp/security/security.go index df8f40f..bcdf43a 100644 --- a/cdp/security/security.go +++ b/cdp/security/security.go @@ -42,21 +42,6 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandSecurityDisable, nil, nil) } -// ShowCertificateViewerParams displays native dialog with the certificate -// details. -type ShowCertificateViewerParams struct{} - -// ShowCertificateViewer displays native dialog with the certificate details. -func ShowCertificateViewer() *ShowCertificateViewerParams { - return &ShowCertificateViewerParams{} -} - -// Do executes Security.showCertificateViewer against the provided context and -// target handler. -func (p *ShowCertificateViewerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandSecurityShowCertificateViewer, nil, nil) -} - // HandleCertificateErrorParams handles a certificate error that fired a // certificateError event. type HandleCertificateErrorParams struct { diff --git a/cdp/security/types.go b/cdp/security/types.go index e0aa8e2..19c350d 100644 --- a/cdp/security/types.go +++ b/cdp/security/types.go @@ -124,8 +124,8 @@ type StateExplanation struct { SecurityState State `json:"securityState"` // Security state representing the severity of the factor being explained. Summary string `json:"summary"` // Short phrase describing the type of factor. Description string `json:"description"` // Full text explanation of the factor. - HasCertificate bool `json:"hasCertificate"` // True if the page has a certificate. MixedContentType MixedContentType `json:"mixedContentType"` // The type of mixed content described by the explanation. + Certificate []string `json:"certificate"` // Page certificate. } // InsecureContentStatus information about insecure content on the page. diff --git a/cmd/chromedp-gen/protocol.json b/cmd/chromedp-gen/protocol.json index 2b968c2..78a18ed 100644 --- a/cmd/chromedp-gen/protocol.json +++ b/cmd/chromedp-gen/protocol.json @@ -2293,15 +2293,18 @@ "type": "string", "description": "Full text explanation of the factor." }, - { - "name": "hasCertificate", - "type": "boolean", - "description": "True if the page has a certificate." - }, { "name": "mixedContentType", "$ref": "MixedContentType", "description": "The type of mixed content described by the explanation." + }, + { + "name": "certificate", + "type": "array", + "items": { + "type": "string" + }, + "description": "Page certificate." } ], "description": "An explanation of an factor contributing to the security state." @@ -2367,10 +2370,6 @@ "name": "disable", "description": "Disables tracking security state changes." }, - { - "name": "showCertificateViewer", - "description": "Displays native dialog with the certificate details." - }, { "name": "handleCertificateError", "description": "Handles a certificate error that fired a certificateError event.", @@ -11258,6 +11257,37 @@ } ] }, + { + "name": "getVersion", + "description": "Returns version information.", + "returns": [ + { + "name": "protocolVersion", + "type": "string", + "description": "Protocol version." + }, + { + "name": "product", + "type": "string", + "description": "Product name." + }, + { + "name": "revision", + "type": "string", + "description": "Product revision." + }, + { + "name": "userAgent", + "type": "string", + "description": "User-Agent." + }, + { + "name": "jsVersion", + "type": "string", + "description": "V8 version." + } + ] + }, { "name": "setWindowBounds", "description": "Set position and/or size of the browser window.",