diff --git a/cdproto.go b/cdproto.go index 0739623..7de64cf 100644 --- a/cdproto.go +++ b/cdproto.go @@ -361,6 +361,7 @@ const ( CommandEventBreakpointsRemoveInstrumentationBreakpoint = eventbreakpoints.CommandRemoveInstrumentationBreakpoint CommandEventBreakpointsDisable = eventbreakpoints.CommandDisable CommandExtensionsLoadUnpacked = extensions.CommandLoadUnpacked + CommandExtensionsGetStorageItems = extensions.CommandGetStorageItems CommandFedCmEnable = fedcm.CommandEnable CommandFedCmDisable = fedcm.CommandDisable CommandFedCmSelectAccount = fedcm.CommandSelectAccount @@ -1688,6 +1689,9 @@ func UnmarshalMessage(msg *Message) (interface{}, error) { case CommandExtensionsLoadUnpacked: v = new(extensions.LoadUnpackedReturns) + case CommandExtensionsGetStorageItems: + v = new(extensions.GetStorageItemsReturns) + case CommandFedCmEnable: return emptyVal, nil diff --git a/extensions/easyjson.go b/extensions/easyjson.go index 2d5bab6..fff519d 100644 --- a/extensions/easyjson.go +++ b/extensions/easyjson.go @@ -150,3 +150,180 @@ func (v *LoadUnpackedParams) UnmarshalJSON(data []byte) error { func (v *LoadUnpackedParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions1(l, v) } +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions2(in *jlexer.Lexer, out *GetStorageItemsReturns) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "data": + (out.Data).UnmarshalEasyJSON(in) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions2(out *jwriter.Writer, in GetStorageItemsReturns) { + out.RawByte('{') + first := true + _ = first + if (in.Data).IsDefined() { + const prefix string = ",\"data\":" + first = false + out.RawString(prefix[1:]) + (in.Data).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v GetStorageItemsReturns) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions2(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v GetStorageItemsReturns) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions2(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *GetStorageItemsReturns) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions2(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *GetStorageItemsReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions2(l, v) +} +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions3(in *jlexer.Lexer, out *GetStorageItemsParams) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "id": + out.ID = string(in.String()) + case "storageArea": + (out.StorageArea).UnmarshalEasyJSON(in) + case "keys": + if in.IsNull() { + in.Skip() + out.Keys = nil + } else { + in.Delim('[') + if out.Keys == nil { + if !in.IsDelim(']') { + out.Keys = make([]string, 0, 4) + } else { + out.Keys = []string{} + } + } else { + out.Keys = (out.Keys)[:0] + } + for !in.IsDelim(']') { + var v1 string + v1 = string(in.String()) + out.Keys = append(out.Keys, v1) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions3(out *jwriter.Writer, in GetStorageItemsParams) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"id\":" + out.RawString(prefix[1:]) + out.String(string(in.ID)) + } + { + const prefix string = ",\"storageArea\":" + out.RawString(prefix) + (in.StorageArea).MarshalEasyJSON(out) + } + if len(in.Keys) != 0 { + const prefix string = ",\"keys\":" + out.RawString(prefix) + { + out.RawByte('[') + for v2, v3 := range in.Keys { + if v2 > 0 { + out.RawByte(',') + } + out.String(string(v3)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v GetStorageItemsParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions3(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v GetStorageItemsParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoExtensions3(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *GetStorageItemsParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions3(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *GetStorageItemsParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoExtensions3(l, v) +} diff --git a/extensions/extensions.go b/extensions/extensions.go index e246b54..a08197a 100644 --- a/extensions/extensions.go +++ b/extensions/extensions.go @@ -1,9 +1,7 @@ // Package extensions provides the Chrome DevTools Protocol // commands, types, and events for the Extensions domain. // -// Defines commands and events for browser extensions. Available if the -// client is connected using the --remote-debugging-pipe flag and the -// --enable-unsafe-extension-debugging flag is set. +// Defines commands and events for browser extensions. // // Generated by the cdproto-gen command. package extensions @@ -14,18 +12,23 @@ import ( "context" "github.com/chromedp/cdproto/cdp" + "github.com/mailru/easyjson" ) // LoadUnpackedParams installs an unpacked extension from the filesystem // similar to --load-extension CLI flags. Returns extension ID once the -// extension has been installed. +// extension has been installed. Available if the client is connected using the +// --remote-debugging-pipe flag and the --enable-unsafe-extension-debugging flag +// is set. type LoadUnpackedParams struct { Path string `json:"path"` // Absolute file path. } // LoadUnpacked installs an unpacked extension from the filesystem similar to // --load-extension CLI flags. Returns extension ID once the extension has been -// installed. +// installed. Available if the client is connected using the +// --remote-debugging-pipe flag and the --enable-unsafe-extension-debugging flag +// is set. // // See: https://chromedevtools.github.io/devtools-protocol/tot/Extensions#method-loadUnpacked // @@ -59,7 +62,59 @@ func (p *LoadUnpackedParams) Do(ctx context.Context) (id string, err error) { return res.ID, nil } +// GetStorageItemsParams gets data from extension storage in the given area. +// If keys is specified, these are used to filter the result. +type GetStorageItemsParams struct { + ID string `json:"id"` // ID of extension. + StorageArea StorageArea `json:"storageArea"` // StorageArea to retrieve data from. + Keys []string `json:"keys,omitempty"` // Keys to retrieve. +} + +// GetStorageItems gets data from extension storage in the given area. If +// keys is specified, these are used to filter the result. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/Extensions#method-getStorageItems +// +// parameters: +// +// id - ID of extension. +// storageArea - StorageArea to retrieve data from. +func GetStorageItems(id string, storageArea StorageArea) *GetStorageItemsParams { + return &GetStorageItemsParams{ + ID: id, + StorageArea: storageArea, + } +} + +// WithKeys keys to retrieve. +func (p GetStorageItemsParams) WithKeys(keys []string) *GetStorageItemsParams { + p.Keys = keys + return &p +} + +// GetStorageItemsReturns return values. +type GetStorageItemsReturns struct { + Data easyjson.RawMessage `json:"data,omitempty"` +} + +// Do executes Extensions.getStorageItems against the provided context. +// +// returns: +// +// data +func (p *GetStorageItemsParams) Do(ctx context.Context) (data easyjson.RawMessage, err error) { + // execute + var res GetStorageItemsReturns + err = cdp.Execute(ctx, CommandGetStorageItems, p, &res) + if err != nil { + return nil, err + } + + return res.Data, nil +} + // Command names. const ( - CommandLoadUnpacked = "Extensions.loadUnpacked" + CommandLoadUnpacked = "Extensions.loadUnpacked" + CommandGetStorageItems = "Extensions.getStorageItems" ) diff --git a/extensions/types.go b/extensions/types.go new file mode 100644 index 0000000..19b1b7d --- /dev/null +++ b/extensions/types.go @@ -0,0 +1,62 @@ +package extensions + +// Code generated by cdproto-gen. DO NOT EDIT. + +import ( + "fmt" + + "github.com/mailru/easyjson" + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +// StorageArea storage areas. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/Extensions#type-StorageArea +type StorageArea string + +// String returns the StorageArea as string value. +func (t StorageArea) String() string { + return string(t) +} + +// StorageArea values. +const ( + StorageAreaSession StorageArea = "session" + StorageAreaLocal StorageArea = "local" + StorageAreaSync StorageArea = "sync" + StorageAreaManaged StorageArea = "managed" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t StorageArea) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t StorageArea) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *StorageArea) UnmarshalEasyJSON(in *jlexer.Lexer) { + v := in.String() + switch StorageArea(v) { + case StorageAreaSession: + *t = StorageAreaSession + case StorageAreaLocal: + *t = StorageAreaLocal + case StorageAreaSync: + *t = StorageAreaSync + case StorageAreaManaged: + *t = StorageAreaManaged + + default: + in.AddError(fmt.Errorf("unknown StorageArea value: %v", v)) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *StorageArea) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} diff --git a/page/types.go b/page/types.go index 4df5941..21a5dd4 100644 --- a/page/types.go +++ b/page/types.go @@ -37,6 +37,7 @@ func (t PermissionsPolicyFeature) String() string { // PermissionsPolicyFeature values. const ( PermissionsPolicyFeatureAccelerometer PermissionsPolicyFeature = "accelerometer" + PermissionsPolicyFeatureAllScreensCapture PermissionsPolicyFeature = "all-screens-capture" PermissionsPolicyFeatureAmbientLightSensor PermissionsPolicyFeature = "ambient-light-sensor" PermissionsPolicyFeatureAttributionReporting PermissionsPolicyFeature = "attribution-reporting" PermissionsPolicyFeatureAutoplay PermissionsPolicyFeature = "autoplay" @@ -93,6 +94,7 @@ const ( PermissionsPolicyFeatureKeyboardMap PermissionsPolicyFeature = "keyboard-map" PermissionsPolicyFeatureLocalFonts PermissionsPolicyFeature = "local-fonts" PermissionsPolicyFeatureMagnetometer PermissionsPolicyFeature = "magnetometer" + PermissionsPolicyFeatureMediaPlaybackWhileNotVisible PermissionsPolicyFeature = "media-playback-while-not-visible" PermissionsPolicyFeatureMicrophone PermissionsPolicyFeature = "microphone" PermissionsPolicyFeatureMidi PermissionsPolicyFeature = "midi" PermissionsPolicyFeatureOtpCredentials PermissionsPolicyFeature = "otp-credentials" @@ -140,6 +142,8 @@ func (t *PermissionsPolicyFeature) UnmarshalEasyJSON(in *jlexer.Lexer) { switch PermissionsPolicyFeature(v) { case PermissionsPolicyFeatureAccelerometer: *t = PermissionsPolicyFeatureAccelerometer + case PermissionsPolicyFeatureAllScreensCapture: + *t = PermissionsPolicyFeatureAllScreensCapture case PermissionsPolicyFeatureAmbientLightSensor: *t = PermissionsPolicyFeatureAmbientLightSensor case PermissionsPolicyFeatureAttributionReporting: @@ -252,6 +256,8 @@ func (t *PermissionsPolicyFeature) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = PermissionsPolicyFeatureLocalFonts case PermissionsPolicyFeatureMagnetometer: *t = PermissionsPolicyFeatureMagnetometer + case PermissionsPolicyFeatureMediaPlaybackWhileNotVisible: + *t = PermissionsPolicyFeatureMediaPlaybackWhileNotVisible case PermissionsPolicyFeatureMicrophone: *t = PermissionsPolicyFeatureMicrophone case PermissionsPolicyFeatureMidi: diff --git a/preload/types.go b/preload/types.go index 6603312..fe06b7c 100644 --- a/preload/types.go +++ b/preload/types.go @@ -281,6 +281,8 @@ const ( PrerenderFinalStatusJavaScriptInterfaceRemoved PrerenderFinalStatus = "JavaScriptInterfaceRemoved" PrerenderFinalStatusAllPrerenderingCanceled PrerenderFinalStatus = "AllPrerenderingCanceled" PrerenderFinalStatusWindowClosed PrerenderFinalStatus = "WindowClosed" + PrerenderFinalStatusSlowNetwork PrerenderFinalStatus = "SlowNetwork" + PrerenderFinalStatusOtherPrerenderedPageActivated PrerenderFinalStatus = "OtherPrerenderedPageActivated" ) // MarshalEasyJSON satisfies easyjson.Marshaler. @@ -435,6 +437,10 @@ func (t *PrerenderFinalStatus) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = PrerenderFinalStatusAllPrerenderingCanceled case PrerenderFinalStatusWindowClosed: *t = PrerenderFinalStatusWindowClosed + case PrerenderFinalStatusSlowNetwork: + *t = PrerenderFinalStatusSlowNetwork + case PrerenderFinalStatusOtherPrerenderedPageActivated: + *t = PrerenderFinalStatusOtherPrerenderedPageActivated default: in.AddError(fmt.Errorf("unknown PrerenderFinalStatus value: %v", v))