From 55927c2a4565b45267feee0376bc5a4b5b985644 Mon Sep 17 00:00:00 2001 From: Kenneth Shaw Date: Sat, 25 May 2024 05:16:37 +0700 Subject: [PATCH] Updating to 127.0.6499.4_12.7.122 definitions --- audits/easyjson.go | 7 + audits/types.go | 10 +- cdproto.go | 4 + network/easyjson.go | 26 ++++ network/types.go | 41 +++--- pwa/easyjson.go | 314 ++++++++++++++++++++++++++++++++++++-------- pwa/pwa.go | 73 +++++++++- 7 files changed, 393 insertions(+), 82 deletions(-) diff --git a/audits/easyjson.go b/audits/easyjson.go index db16529..064ed04 100644 --- a/audits/easyjson.go +++ b/audits/easyjson.go @@ -2640,6 +2640,8 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoAudits23(in *jlexer.Lexer, ou out.OptOutPercentage = float64(in.Float64()) case "isOptOutTopLevel": out.IsOptOutTopLevel = bool(in.Bool()) + case "operation": + (out.Operation).UnmarshalEasyJSON(in) default: in.SkipRecursive() } @@ -2680,6 +2682,11 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoAudits23(out *jwriter.Writer, out.RawString(prefix) out.Bool(bool(in.IsOptOutTopLevel)) } + { + const prefix string = ",\"operation\":" + out.RawString(prefix) + (in.Operation).MarshalEasyJSON(out) + } out.RawByte('}') } diff --git a/audits/types.go b/audits/types.go index b384c23..94b93c5 100644 --- a/audits/types.go +++ b/audits/types.go @@ -1116,9 +1116,10 @@ type BounceTrackingIssueDetails struct { // // See: https://chromedevtools.github.io/devtools-protocol/tot/Audits#type-CookieDeprecationMetadataIssueDetails type CookieDeprecationMetadataIssueDetails struct { - AllowedSites []string `json:"allowedSites"` - OptOutPercentage float64 `json:"optOutPercentage"` - IsOptOutTopLevel bool `json:"isOptOutTopLevel"` + AllowedSites []string `json:"allowedSites"` + OptOutPercentage float64 `json:"optOutPercentage"` + IsOptOutTopLevel bool `json:"isOptOutTopLevel"` + Operation CookieOperation `json:"operation"` } // ClientHintIssueReason [no description]. @@ -1229,6 +1230,7 @@ const ( FederatedAuthRequestIssueReasonNotSignedInWithIdp FederatedAuthRequestIssueReason = "NotSignedInWithIdp" FederatedAuthRequestIssueReasonMissingTransientUserActivation FederatedAuthRequestIssueReason = "MissingTransientUserActivation" FederatedAuthRequestIssueReasonReplacedByButtonMode FederatedAuthRequestIssueReason = "ReplacedByButtonMode" + FederatedAuthRequestIssueReasonRelyingPartyOriginIsOpaque FederatedAuthRequestIssueReason = "RelyingPartyOriginIsOpaque" ) // MarshalEasyJSON satisfies easyjson.Marshaler. @@ -1325,6 +1327,8 @@ func (t *FederatedAuthRequestIssueReason) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = FederatedAuthRequestIssueReasonMissingTransientUserActivation case FederatedAuthRequestIssueReasonReplacedByButtonMode: *t = FederatedAuthRequestIssueReasonReplacedByButtonMode + case FederatedAuthRequestIssueReasonRelyingPartyOriginIsOpaque: + *t = FederatedAuthRequestIssueReasonRelyingPartyOriginIsOpaque default: in.AddError(fmt.Errorf("unknown FederatedAuthRequestIssueReason value: %v", v)) diff --git a/cdproto.go b/cdproto.go index c30f1b5..142c3eb 100644 --- a/cdproto.go +++ b/cdproto.go @@ -552,6 +552,7 @@ const ( CommandPWAInstall = pwa.CommandInstall CommandPWAUninstall = pwa.CommandUninstall CommandPWALaunch = pwa.CommandLaunch + CommandPWALaunchFilesInApp = pwa.CommandLaunchFilesInApp CommandPageAddScriptToEvaluateOnNewDocument = page.CommandAddScriptToEvaluateOnNewDocument CommandPageBringToFront = page.CommandBringToFront CommandPageCaptureScreenshot = page.CommandCaptureScreenshot @@ -2255,6 +2256,9 @@ func UnmarshalMessage(msg *Message) (interface{}, error) { case CommandPWALaunch: v = new(pwa.LaunchReturns) + case CommandPWALaunchFilesInApp: + v = new(pwa.LaunchFilesInAppReturns) + case CommandPageAddScriptToEvaluateOnNewDocument: v = new(page.AddScriptToEvaluateOnNewDocumentReturns) diff --git a/network/easyjson.go b/network/easyjson.go index 487b72a..dab16a2 100644 --- a/network/easyjson.go +++ b/network/easyjson.go @@ -2257,6 +2257,8 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork21(in *jlexer.Lexer, o out.RuleIDMatched = int64(in.Int64()) case "matchedSourceType": (out.MatchedSourceType).UnmarshalEasyJSON(in) + case "actualSourceType": + (out.ActualSourceType).UnmarshalEasyJSON(in) default: in.SkipRecursive() } @@ -2287,6 +2289,16 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork21(out *jwriter.Writer } (in.MatchedSourceType).MarshalEasyJSON(out) } + if in.ActualSourceType != "" { + const prefix string = ",\"actualSourceType\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (in.ActualSourceType).MarshalEasyJSON(out) + } out.RawByte('}') } @@ -3319,6 +3331,10 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork27(in *jlexer.Lexer, o out.WorkerFetchStart = float64(in.Float64()) case "workerRespondWithSettled": out.WorkerRespondWithSettled = float64(in.Float64()) + case "workerRouterEvaluationStart": + out.WorkerRouterEvaluationStart = float64(in.Float64()) + case "workerCacheLookupStart": + out.WorkerCacheLookupStart = float64(in.Float64()) case "sendStart": out.SendStart = float64(in.Float64()) case "sendEnd": @@ -3410,6 +3426,16 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork27(out *jwriter.Writer out.RawString(prefix) out.Float64(float64(in.WorkerRespondWithSettled)) } + if in.WorkerRouterEvaluationStart != 0 { + const prefix string = ",\"workerRouterEvaluationStart\":" + out.RawString(prefix) + out.Float64(float64(in.WorkerRouterEvaluationStart)) + } + if in.WorkerCacheLookupStart != 0 { + const prefix string = ",\"workerCacheLookupStart\":" + out.RawString(prefix) + out.Float64(float64(in.WorkerCacheLookupStart)) + } { const prefix string = ",\"sendStart\":" out.RawString(prefix) diff --git a/network/types.go b/network/types.go index da9c61c..363f3da 100644 --- a/network/types.go +++ b/network/types.go @@ -433,25 +433,27 @@ func (t *CookieSourceScheme) UnmarshalJSON(buf []byte) error { // // See: https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ResourceTiming type ResourceTiming struct { - RequestTime float64 `json:"requestTime"` // Timing's requestTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this requestTime. - ProxyStart float64 `json:"proxyStart"` // Started resolving proxy. - ProxyEnd float64 `json:"proxyEnd"` // Finished resolving proxy. - DNSStart float64 `json:"dnsStart"` // Started DNS address resolve. - DNSEnd float64 `json:"dnsEnd"` // Finished DNS address resolve. - ConnectStart float64 `json:"connectStart"` // Started connecting to the remote host. - ConnectEnd float64 `json:"connectEnd"` // Connected to the remote host. - SslStart float64 `json:"sslStart"` // Started SSL handshake. - SslEnd float64 `json:"sslEnd"` // Finished SSL handshake. - WorkerStart float64 `json:"workerStart"` // Started running ServiceWorker. - WorkerReady float64 `json:"workerReady"` // Finished Starting ServiceWorker. - WorkerFetchStart float64 `json:"workerFetchStart"` // Started fetch event. - WorkerRespondWithSettled float64 `json:"workerRespondWithSettled"` // Settled fetch event respondWith promise. - SendStart float64 `json:"sendStart"` // Started sending request. - SendEnd float64 `json:"sendEnd"` // Finished sending request. - PushStart float64 `json:"pushStart"` // Time the server started pushing request. - PushEnd float64 `json:"pushEnd"` // Time the server finished pushing request. - ReceiveHeadersStart float64 `json:"receiveHeadersStart"` // Started receiving response headers. - ReceiveHeadersEnd float64 `json:"receiveHeadersEnd"` // Finished receiving response headers. + RequestTime float64 `json:"requestTime"` // Timing's requestTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this requestTime. + ProxyStart float64 `json:"proxyStart"` // Started resolving proxy. + ProxyEnd float64 `json:"proxyEnd"` // Finished resolving proxy. + DNSStart float64 `json:"dnsStart"` // Started DNS address resolve. + DNSEnd float64 `json:"dnsEnd"` // Finished DNS address resolve. + ConnectStart float64 `json:"connectStart"` // Started connecting to the remote host. + ConnectEnd float64 `json:"connectEnd"` // Connected to the remote host. + SslStart float64 `json:"sslStart"` // Started SSL handshake. + SslEnd float64 `json:"sslEnd"` // Finished SSL handshake. + WorkerStart float64 `json:"workerStart"` // Started running ServiceWorker. + WorkerReady float64 `json:"workerReady"` // Finished Starting ServiceWorker. + WorkerFetchStart float64 `json:"workerFetchStart"` // Started fetch event. + WorkerRespondWithSettled float64 `json:"workerRespondWithSettled"` // Settled fetch event respondWith promise. + WorkerRouterEvaluationStart float64 `json:"workerRouterEvaluationStart,omitempty"` // Started ServiceWorker static routing source evaluation. + WorkerCacheLookupStart float64 `json:"workerCacheLookupStart,omitempty"` // Started cache lookup when the source was evaluated to cache. + SendStart float64 `json:"sendStart"` // Started sending request. + SendEnd float64 `json:"sendEnd"` // Finished sending request. + PushStart float64 `json:"pushStart"` // Time the server started pushing request. + PushEnd float64 `json:"pushEnd"` // Time the server finished pushing request. + ReceiveHeadersStart float64 `json:"receiveHeadersStart"` // Started receiving response headers. + ReceiveHeadersEnd float64 `json:"receiveHeadersEnd"` // Finished receiving response headers. } // ResourcePriority loading priority of a resource request. @@ -1073,6 +1075,7 @@ func (t *ServiceWorkerRouterSource) UnmarshalJSON(buf []byte) error { type ServiceWorkerRouterInfo struct { RuleIDMatched int64 `json:"ruleIdMatched,omitempty"` // ID of the rule matched. If there is a matched rule, this field will be set, otherwiser no value will be set. MatchedSourceType ServiceWorkerRouterSource `json:"matchedSourceType,omitempty"` // The router source of the matched rule. If there is a matched rule, this field will be set, otherwise no value will be set. + ActualSourceType ServiceWorkerRouterSource `json:"actualSourceType,omitempty"` // The actual router source used. } // Response HTTP response data. diff --git a/pwa/easyjson.go b/pwa/easyjson.go index 69ea792..54cad00 100644 --- a/pwa/easyjson.go +++ b/pwa/easyjson.go @@ -224,7 +224,209 @@ func (v *LaunchParams) UnmarshalJSON(data []byte) error { func (v *LaunchParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *InstallParams) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *LaunchFilesInAppReturns) { + 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 "targetIds": + if in.IsNull() { + in.Skip() + out.TargetIDs = nil + } else { + in.Delim('[') + if out.TargetIDs == nil { + if !in.IsDelim(']') { + out.TargetIDs = make([]target.ID, 0, 4) + } else { + out.TargetIDs = []target.ID{} + } + } else { + out.TargetIDs = (out.TargetIDs)[:0] + } + for !in.IsDelim(']') { + var v1 target.ID + v1 = target.ID(in.String()) + out.TargetIDs = append(out.TargetIDs, v1) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in LaunchFilesInAppReturns) { + out.RawByte('{') + first := true + _ = first + if len(in.TargetIDs) != 0 { + const prefix string = ",\"targetIds\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('[') + for v2, v3 := range in.TargetIDs { + if v2 > 0 { + out.RawByte(',') + } + out.String(string(v3)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v LaunchFilesInAppReturns) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v LaunchFilesInAppReturns) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *LaunchFilesInAppReturns) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *LaunchFilesInAppReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(l, v) +} +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(in *jlexer.Lexer, out *LaunchFilesInAppParams) { + 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 "manifestId": + out.ManifestID = string(in.String()) + case "files": + if in.IsNull() { + in.Skip() + out.Files = nil + } else { + in.Delim('[') + if out.Files == nil { + if !in.IsDelim(']') { + out.Files = make([]string, 0, 4) + } else { + out.Files = []string{} + } + } else { + out.Files = (out.Files)[:0] + } + for !in.IsDelim(']') { + var v4 string + v4 = string(in.String()) + out.Files = append(out.Files, v4) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(out *jwriter.Writer, in LaunchFilesInAppParams) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"manifestId\":" + out.RawString(prefix[1:]) + out.String(string(in.ManifestID)) + } + { + const prefix string = ",\"files\":" + out.RawString(prefix) + if in.Files == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v5, v6 := range in.Files { + if v5 > 0 { + out.RawByte(',') + } + out.String(string(v6)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v LaunchFilesInAppParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v LaunchFilesInAppParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *LaunchFilesInAppParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *LaunchFilesInAppParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(l, v) +} +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(in *jlexer.Lexer, out *InstallParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -257,7 +459,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *I in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in InstallParams) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(out *jwriter.Writer, in InstallParams) { out.RawByte('{') first := true _ = first @@ -277,27 +479,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v InstallParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v InstallParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *InstallParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *InstallParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(in *jlexer.Lexer, out *GetOsAppStateReturns) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(in *jlexer.Lexer, out *GetOsAppStateReturns) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -334,17 +536,17 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(in *jlexer.Lexer, out *G out.FileHandlers = (out.FileHandlers)[:0] } for !in.IsDelim(']') { - var v1 *FileHandler + var v7 *FileHandler if in.IsNull() { in.Skip() - v1 = nil + v7 = nil } else { - if v1 == nil { - v1 = new(FileHandler) + if v7 == nil { + v7 = new(FileHandler) } - (*v1).UnmarshalEasyJSON(in) + (*v7).UnmarshalEasyJSON(in) } - out.FileHandlers = append(out.FileHandlers, v1) + out.FileHandlers = append(out.FileHandlers, v7) in.WantComma() } in.Delim(']') @@ -359,7 +561,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(in *jlexer.Lexer, out *G in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(out *jwriter.Writer, in GetOsAppStateReturns) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(out *jwriter.Writer, in GetOsAppStateReturns) { out.RawByte('{') first := true _ = first @@ -379,14 +581,14 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(out *jwriter.Writer, in } { out.RawByte('[') - for v2, v3 := range in.FileHandlers { - if v2 > 0 { + for v8, v9 := range in.FileHandlers { + if v8 > 0 { out.RawByte(',') } - if v3 == nil { + if v9 == nil { out.RawString("null") } else { - (*v3).MarshalEasyJSON(out) + (*v9).MarshalEasyJSON(out) } } out.RawByte(']') @@ -398,27 +600,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v GetOsAppStateReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v GetOsAppStateReturns) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *GetOsAppStateReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *GetOsAppStateReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(in *jlexer.Lexer, out *GetOsAppStateParams) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(in *jlexer.Lexer, out *GetOsAppStateParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -449,7 +651,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(in *jlexer.Lexer, out *G in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(out *jwriter.Writer, in GetOsAppStateParams) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(out *jwriter.Writer, in GetOsAppStateParams) { out.RawByte('{') first := true _ = first @@ -464,27 +666,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v GetOsAppStateParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v GetOsAppStateParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *GetOsAppStateParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *GetOsAppStateParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(in *jlexer.Lexer, out *FileHandlerAccept) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa8(in *jlexer.Lexer, out *FileHandlerAccept) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -521,9 +723,9 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(in *jlexer.Lexer, out *F out.FileExtensions = (out.FileExtensions)[:0] } for !in.IsDelim(']') { - var v4 string - v4 = string(in.String()) - out.FileExtensions = append(out.FileExtensions, v4) + var v10 string + v10 = string(in.String()) + out.FileExtensions = append(out.FileExtensions, v10) in.WantComma() } in.Delim(']') @@ -538,7 +740,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(in *jlexer.Lexer, out *F in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(out *jwriter.Writer, in FileHandlerAccept) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa8(out *jwriter.Writer, in FileHandlerAccept) { out.RawByte('{') first := true _ = first @@ -554,11 +756,11 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(out *jwriter.Writer, in out.RawString("null") } else { out.RawByte('[') - for v5, v6 := range in.FileExtensions { - if v5 > 0 { + for v11, v12 := range in.FileExtensions { + if v11 > 0 { out.RawByte(',') } - out.String(string(v6)) + out.String(string(v12)) } out.RawByte(']') } @@ -569,27 +771,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v FileHandlerAccept) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa8(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v FileHandlerAccept) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa6(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa8(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *FileHandlerAccept) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa8(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *FileHandlerAccept) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa6(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa8(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(in *jlexer.Lexer, out *FileHandler) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa9(in *jlexer.Lexer, out *FileHandler) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -626,17 +828,17 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(in *jlexer.Lexer, out *F out.Accepts = (out.Accepts)[:0] } for !in.IsDelim(']') { - var v7 *FileHandlerAccept + var v13 *FileHandlerAccept if in.IsNull() { in.Skip() - v7 = nil + v13 = nil } else { - if v7 == nil { - v7 = new(FileHandlerAccept) + if v13 == nil { + v13 = new(FileHandlerAccept) } - (*v7).UnmarshalEasyJSON(in) + (*v13).UnmarshalEasyJSON(in) } - out.Accepts = append(out.Accepts, v7) + out.Accepts = append(out.Accepts, v13) in.WantComma() } in.Delim(']') @@ -653,7 +855,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(in *jlexer.Lexer, out *F in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(out *jwriter.Writer, in FileHandler) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa9(out *jwriter.Writer, in FileHandler) { out.RawByte('{') first := true _ = first @@ -669,14 +871,14 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(out *jwriter.Writer, in out.RawString("null") } else { out.RawByte('[') - for v8, v9 := range in.Accepts { - if v8 > 0 { + for v14, v15 := range in.Accepts { + if v14 > 0 { out.RawByte(',') } - if v9 == nil { + if v15 == nil { out.RawString("null") } else { - (*v9).MarshalEasyJSON(out) + (*v15).MarshalEasyJSON(out) } } out.RawByte(']') @@ -693,23 +895,23 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v FileHandler) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa9(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v FileHandler) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa7(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa9(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *FileHandler) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa9(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *FileHandler) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa7(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa9(l, v) } diff --git a/pwa/pwa.go b/pwa/pwa.go index ee4e4b6..5723cc4 100644 --- a/pwa/pwa.go +++ b/pwa/pwa.go @@ -179,10 +179,75 @@ func (p *LaunchParams) Do(ctx context.Context) (targetID target.ID, err error) { return res.TargetID, nil } +// LaunchFilesInAppParams opens one or more local files from an installed web +// app identified by its manifestId. The web app needs to have file handlers +// registered to process the files. The API returns one or more tabs / web +// contents' based Target.TargetIDs which can be used to attach to via +// Target.attachToTarget or similar APIs. If some files in the parameters cannot +// be handled by the web app, they will be ignored. If none of the files can be +// handled, this API returns an error. If no files provided as the parameter, +// this API also returns an error. According to the definition of the file +// handlers in the manifest file, one Target.TargetID may represent a tab +// handling one or more files. The order of the returned Target.TargetIDs is +// also not guaranteed. TODO(crbug.com/339454034): Check the existences of the +// input files. +type LaunchFilesInAppParams struct { + ManifestID string `json:"manifestId"` + Files []string `json:"files"` +} + +// LaunchFilesInApp opens one or more local files from an installed web app +// identified by its manifestId. The web app needs to have file handlers +// registered to process the files. The API returns one or more tabs / web +// contents' based Target.TargetIDs which can be used to attach to via +// Target.attachToTarget or similar APIs. If some files in the parameters cannot +// be handled by the web app, they will be ignored. If none of the files can be +// handled, this API returns an error. If no files provided as the parameter, +// this API also returns an error. According to the definition of the file +// handlers in the manifest file, one Target.TargetID may represent a tab +// handling one or more files. The order of the returned Target.TargetIDs is +// also not guaranteed. TODO(crbug.com/339454034): Check the existences of the +// input files. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/PWA#method-launchFilesInApp +// +// parameters: +// +// manifestID +// files +func LaunchFilesInApp(manifestID string, files []string) *LaunchFilesInAppParams { + return &LaunchFilesInAppParams{ + ManifestID: manifestID, + Files: files, + } +} + +// LaunchFilesInAppReturns return values. +type LaunchFilesInAppReturns struct { + TargetIDs []target.ID `json:"targetIds,omitempty"` // IDs of the tab targets created as the result. +} + +// Do executes PWA.launchFilesInApp against the provided context. +// +// returns: +// +// targetIDs - IDs of the tab targets created as the result. +func (p *LaunchFilesInAppParams) Do(ctx context.Context) (targetIDs []target.ID, err error) { + // execute + var res LaunchFilesInAppReturns + err = cdp.Execute(ctx, CommandLaunchFilesInApp, p, &res) + if err != nil { + return nil, err + } + + return res.TargetIDs, nil +} + // Command names. const ( - CommandGetOsAppState = "PWA.getOsAppState" - CommandInstall = "PWA.install" - CommandUninstall = "PWA.uninstall" - CommandLaunch = "PWA.launch" + CommandGetOsAppState = "PWA.getOsAppState" + CommandInstall = "PWA.install" + CommandUninstall = "PWA.uninstall" + CommandLaunch = "PWA.launch" + CommandLaunchFilesInApp = "PWA.launchFilesInApp" )