browser.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. // Package browser provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Browser domain.
  3. //
  4. // The Browser domain defines methods and events for browser managing.
  5. //
  6. // Generated by the cdproto-gen command.
  7. package browser
  8. // Code generated by cdproto-gen. DO NOT EDIT.
  9. import (
  10. "context"
  11. "github.com/chromedp/cdproto/cdp"
  12. "github.com/chromedp/cdproto/target"
  13. )
  14. // SetPermissionParams set permission settings for given origin.
  15. type SetPermissionParams struct {
  16. Permission *PermissionDescriptor `json:"permission"` // Descriptor of permission to override.
  17. Setting PermissionSetting `json:"setting"` // Setting of the permission.
  18. Origin string `json:"origin,omitempty,omitzero"` // Origin the permission applies to, all origins if not specified.
  19. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // Context to override. When omitted, default browser context is used.
  20. }
  21. // SetPermission set permission settings for given origin.
  22. //
  23. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setPermission
  24. //
  25. // parameters:
  26. //
  27. // permission - Descriptor of permission to override.
  28. // setting - Setting of the permission.
  29. func SetPermission(permission *PermissionDescriptor, setting PermissionSetting) *SetPermissionParams {
  30. return &SetPermissionParams{
  31. Permission: permission,
  32. Setting: setting,
  33. }
  34. }
  35. // WithOrigin origin the permission applies to, all origins if not specified.
  36. func (p SetPermissionParams) WithOrigin(origin string) *SetPermissionParams {
  37. p.Origin = origin
  38. return &p
  39. }
  40. // WithBrowserContextID context to override. When omitted, default browser
  41. // context is used.
  42. func (p SetPermissionParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *SetPermissionParams {
  43. p.BrowserContextID = browserContextID
  44. return &p
  45. }
  46. // Do executes Browser.setPermission against the provided context.
  47. func (p *SetPermissionParams) Do(ctx context.Context) (err error) {
  48. return cdp.Execute(ctx, CommandSetPermission, p, nil)
  49. }
  50. // GrantPermissionsParams grant specific permissions to the given origin and
  51. // reject all others.
  52. type GrantPermissionsParams struct {
  53. Permissions []PermissionType `json:"permissions"`
  54. Origin string `json:"origin,omitempty,omitzero"` // Origin the permission applies to, all origins if not specified.
  55. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // BrowserContext to override permissions. When omitted, default browser context is used.
  56. }
  57. // GrantPermissions grant specific permissions to the given origin and reject
  58. // all others.
  59. //
  60. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-grantPermissions
  61. //
  62. // parameters:
  63. //
  64. // permissions
  65. func GrantPermissions(permissions []PermissionType) *GrantPermissionsParams {
  66. return &GrantPermissionsParams{
  67. Permissions: permissions,
  68. }
  69. }
  70. // WithOrigin origin the permission applies to, all origins if not specified.
  71. func (p GrantPermissionsParams) WithOrigin(origin string) *GrantPermissionsParams {
  72. p.Origin = origin
  73. return &p
  74. }
  75. // WithBrowserContextID browserContext to override permissions. When omitted,
  76. // default browser context is used.
  77. func (p GrantPermissionsParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *GrantPermissionsParams {
  78. p.BrowserContextID = browserContextID
  79. return &p
  80. }
  81. // Do executes Browser.grantPermissions against the provided context.
  82. func (p *GrantPermissionsParams) Do(ctx context.Context) (err error) {
  83. return cdp.Execute(ctx, CommandGrantPermissions, p, nil)
  84. }
  85. // ResetPermissionsParams reset all permission management for all origins.
  86. type ResetPermissionsParams struct {
  87. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // BrowserContext to reset permissions. When omitted, default browser context is used.
  88. }
  89. // ResetPermissions reset all permission management for all origins.
  90. //
  91. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-resetPermissions
  92. //
  93. // parameters:
  94. func ResetPermissions() *ResetPermissionsParams {
  95. return &ResetPermissionsParams{}
  96. }
  97. // WithBrowserContextID browserContext to reset permissions. When omitted,
  98. // default browser context is used.
  99. func (p ResetPermissionsParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *ResetPermissionsParams {
  100. p.BrowserContextID = browserContextID
  101. return &p
  102. }
  103. // Do executes Browser.resetPermissions against the provided context.
  104. func (p *ResetPermissionsParams) Do(ctx context.Context) (err error) {
  105. return cdp.Execute(ctx, CommandResetPermissions, p, nil)
  106. }
  107. // SetDownloadBehaviorParams set the behavior when downloading a file.
  108. type SetDownloadBehaviorParams struct {
  109. Behavior SetDownloadBehaviorBehavior `json:"behavior"` // Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). |allowAndName| allows download and names files according to their download guids.
  110. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // BrowserContext to set download behavior. When omitted, default browser context is used.
  111. DownloadPath string `json:"downloadPath,omitempty,omitzero"` // The default path to save downloaded files to. This is required if behavior is set to 'allow' or 'allowAndName'.
  112. EventsEnabled bool `json:"eventsEnabled"` // Whether to emit download events (defaults to false).
  113. }
  114. // SetDownloadBehavior set the behavior when downloading a file.
  115. //
  116. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setDownloadBehavior
  117. //
  118. // parameters:
  119. //
  120. // behavior - Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). |allowAndName| allows download and names files according to their download guids.
  121. func SetDownloadBehavior(behavior SetDownloadBehaviorBehavior) *SetDownloadBehaviorParams {
  122. return &SetDownloadBehaviorParams{
  123. Behavior: behavior,
  124. EventsEnabled: false,
  125. }
  126. }
  127. // WithBrowserContextID browserContext to set download behavior. When
  128. // omitted, default browser context is used.
  129. func (p SetDownloadBehaviorParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *SetDownloadBehaviorParams {
  130. p.BrowserContextID = browserContextID
  131. return &p
  132. }
  133. // WithDownloadPath the default path to save downloaded files to. This is
  134. // required if behavior is set to 'allow' or 'allowAndName'.
  135. func (p SetDownloadBehaviorParams) WithDownloadPath(downloadPath string) *SetDownloadBehaviorParams {
  136. p.DownloadPath = downloadPath
  137. return &p
  138. }
  139. // WithEventsEnabled whether to emit download events (defaults to false).
  140. func (p SetDownloadBehaviorParams) WithEventsEnabled(eventsEnabled bool) *SetDownloadBehaviorParams {
  141. p.EventsEnabled = eventsEnabled
  142. return &p
  143. }
  144. // Do executes Browser.setDownloadBehavior against the provided context.
  145. func (p *SetDownloadBehaviorParams) Do(ctx context.Context) (err error) {
  146. return cdp.Execute(ctx, CommandSetDownloadBehavior, p, nil)
  147. }
  148. // CancelDownloadParams cancel a download if in progress.
  149. type CancelDownloadParams struct {
  150. GUID string `json:"guid"` // Global unique identifier of the download.
  151. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // BrowserContext to perform the action in. When omitted, default browser context is used.
  152. }
  153. // CancelDownload cancel a download if in progress.
  154. //
  155. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-cancelDownload
  156. //
  157. // parameters:
  158. //
  159. // guid - Global unique identifier of the download.
  160. func CancelDownload(guid string) *CancelDownloadParams {
  161. return &CancelDownloadParams{
  162. GUID: guid,
  163. }
  164. }
  165. // WithBrowserContextID browserContext to perform the action in. When
  166. // omitted, default browser context is used.
  167. func (p CancelDownloadParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *CancelDownloadParams {
  168. p.BrowserContextID = browserContextID
  169. return &p
  170. }
  171. // Do executes Browser.cancelDownload against the provided context.
  172. func (p *CancelDownloadParams) Do(ctx context.Context) (err error) {
  173. return cdp.Execute(ctx, CommandCancelDownload, p, nil)
  174. }
  175. // CloseParams close browser gracefully.
  176. type CloseParams struct{}
  177. // Close close browser gracefully.
  178. //
  179. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-close
  180. func Close() *CloseParams {
  181. return &CloseParams{}
  182. }
  183. // Do executes Browser.close against the provided context.
  184. func (p *CloseParams) Do(ctx context.Context) (err error) {
  185. return cdp.Execute(ctx, CommandClose, nil, nil)
  186. }
  187. // CrashParams crashes browser on the main thread.
  188. type CrashParams struct{}
  189. // Crash crashes browser on the main thread.
  190. //
  191. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-crash
  192. func Crash() *CrashParams {
  193. return &CrashParams{}
  194. }
  195. // Do executes Browser.crash against the provided context.
  196. func (p *CrashParams) Do(ctx context.Context) (err error) {
  197. return cdp.Execute(ctx, CommandCrash, nil, nil)
  198. }
  199. // CrashGPUProcessParams crashes GPU process.
  200. type CrashGPUProcessParams struct{}
  201. // CrashGPUProcess crashes GPU process.
  202. //
  203. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-crashGpuProcess
  204. func CrashGPUProcess() *CrashGPUProcessParams {
  205. return &CrashGPUProcessParams{}
  206. }
  207. // Do executes Browser.crashGpuProcess against the provided context.
  208. func (p *CrashGPUProcessParams) Do(ctx context.Context) (err error) {
  209. return cdp.Execute(ctx, CommandCrashGPUProcess, nil, nil)
  210. }
  211. // GetVersionParams returns version information.
  212. type GetVersionParams struct{}
  213. // GetVersion returns version information.
  214. //
  215. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getVersion
  216. func GetVersion() *GetVersionParams {
  217. return &GetVersionParams{}
  218. }
  219. // GetVersionReturns return values.
  220. type GetVersionReturns struct {
  221. ProtocolVersion string `json:"protocolVersion,omitempty,omitzero"` // Protocol version.
  222. Product string `json:"product,omitempty,omitzero"` // Product name.
  223. Revision string `json:"revision,omitempty,omitzero"` // Product revision.
  224. UserAgent string `json:"userAgent,omitempty,omitzero"` // User-Agent.
  225. JsVersion string `json:"jsVersion,omitempty,omitzero"` // V8 version.
  226. }
  227. // Do executes Browser.getVersion against the provided context.
  228. //
  229. // returns:
  230. //
  231. // protocolVersion - Protocol version.
  232. // product - Product name.
  233. // revision - Product revision.
  234. // userAgent - User-Agent.
  235. // jsVersion - V8 version.
  236. func (p *GetVersionParams) Do(ctx context.Context) (protocolVersion string, product string, revision string, userAgent string, jsVersion string, err error) {
  237. // execute
  238. var res GetVersionReturns
  239. err = cdp.Execute(ctx, CommandGetVersion, nil, &res)
  240. if err != nil {
  241. return "", "", "", "", "", err
  242. }
  243. return res.ProtocolVersion, res.Product, res.Revision, res.UserAgent, res.JsVersion, nil
  244. }
  245. // GetBrowserCommandLineParams returns the command line switches for the
  246. // browser process if, and only if --enable-automation is on the commandline.
  247. type GetBrowserCommandLineParams struct{}
  248. // GetBrowserCommandLine returns the command line switches for the browser
  249. // process if, and only if --enable-automation is on the commandline.
  250. //
  251. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getBrowserCommandLine
  252. func GetBrowserCommandLine() *GetBrowserCommandLineParams {
  253. return &GetBrowserCommandLineParams{}
  254. }
  255. // GetBrowserCommandLineReturns return values.
  256. type GetBrowserCommandLineReturns struct {
  257. Arguments []string `json:"arguments,omitempty,omitzero"` // Commandline parameters
  258. }
  259. // Do executes Browser.getBrowserCommandLine against the provided context.
  260. //
  261. // returns:
  262. //
  263. // arguments - Commandline parameters
  264. func (p *GetBrowserCommandLineParams) Do(ctx context.Context) (arguments []string, err error) {
  265. // execute
  266. var res GetBrowserCommandLineReturns
  267. err = cdp.Execute(ctx, CommandGetBrowserCommandLine, nil, &res)
  268. if err != nil {
  269. return nil, err
  270. }
  271. return res.Arguments, nil
  272. }
  273. // GetHistogramsParams get Chrome histograms.
  274. type GetHistogramsParams struct {
  275. Query string `json:"query,omitempty,omitzero"` // Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
  276. Delta bool `json:"delta"` // If true, retrieve delta since last delta call.
  277. }
  278. // GetHistograms get Chrome histograms.
  279. //
  280. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getHistograms
  281. //
  282. // parameters:
  283. func GetHistograms() *GetHistogramsParams {
  284. return &GetHistogramsParams{
  285. Delta: false,
  286. }
  287. }
  288. // WithQuery requested substring in name. Only histograms which have query as
  289. // a substring in their name are extracted. An empty or absent query returns all
  290. // histograms.
  291. func (p GetHistogramsParams) WithQuery(query string) *GetHistogramsParams {
  292. p.Query = query
  293. return &p
  294. }
  295. // WithDelta if true, retrieve delta since last delta call.
  296. func (p GetHistogramsParams) WithDelta(delta bool) *GetHistogramsParams {
  297. p.Delta = delta
  298. return &p
  299. }
  300. // GetHistogramsReturns return values.
  301. type GetHistogramsReturns struct {
  302. Histograms []*Histogram `json:"histograms,omitempty,omitzero"` // Histograms.
  303. }
  304. // Do executes Browser.getHistograms against the provided context.
  305. //
  306. // returns:
  307. //
  308. // histograms - Histograms.
  309. func (p *GetHistogramsParams) Do(ctx context.Context) (histograms []*Histogram, err error) {
  310. // execute
  311. var res GetHistogramsReturns
  312. err = cdp.Execute(ctx, CommandGetHistograms, p, &res)
  313. if err != nil {
  314. return nil, err
  315. }
  316. return res.Histograms, nil
  317. }
  318. // GetHistogramParams get a Chrome histogram by name.
  319. type GetHistogramParams struct {
  320. Name string `json:"name"` // Requested histogram name.
  321. Delta bool `json:"delta"` // If true, retrieve delta since last delta call.
  322. }
  323. // GetHistogram get a Chrome histogram by name.
  324. //
  325. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getHistogram
  326. //
  327. // parameters:
  328. //
  329. // name - Requested histogram name.
  330. func GetHistogram(name string) *GetHistogramParams {
  331. return &GetHistogramParams{
  332. Name: name,
  333. Delta: false,
  334. }
  335. }
  336. // WithDelta if true, retrieve delta since last delta call.
  337. func (p GetHistogramParams) WithDelta(delta bool) *GetHistogramParams {
  338. p.Delta = delta
  339. return &p
  340. }
  341. // GetHistogramReturns return values.
  342. type GetHistogramReturns struct {
  343. Histogram *Histogram `json:"histogram,omitempty,omitzero"` // Histogram.
  344. }
  345. // Do executes Browser.getHistogram against the provided context.
  346. //
  347. // returns:
  348. //
  349. // histogram - Histogram.
  350. func (p *GetHistogramParams) Do(ctx context.Context) (histogram *Histogram, err error) {
  351. // execute
  352. var res GetHistogramReturns
  353. err = cdp.Execute(ctx, CommandGetHistogram, p, &res)
  354. if err != nil {
  355. return nil, err
  356. }
  357. return res.Histogram, nil
  358. }
  359. // GetWindowBoundsParams get position and size of the browser window.
  360. type GetWindowBoundsParams struct {
  361. WindowID WindowID `json:"windowId"` // Browser window id.
  362. }
  363. // GetWindowBounds get position and size of the browser window.
  364. //
  365. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getWindowBounds
  366. //
  367. // parameters:
  368. //
  369. // windowID - Browser window id.
  370. func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams {
  371. return &GetWindowBoundsParams{
  372. WindowID: windowID,
  373. }
  374. }
  375. // GetWindowBoundsReturns return values.
  376. type GetWindowBoundsReturns struct {
  377. Bounds *Bounds `json:"bounds,omitempty,omitzero"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  378. }
  379. // Do executes Browser.getWindowBounds against the provided context.
  380. //
  381. // returns:
  382. //
  383. // bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  384. func (p *GetWindowBoundsParams) Do(ctx context.Context) (bounds *Bounds, err error) {
  385. // execute
  386. var res GetWindowBoundsReturns
  387. err = cdp.Execute(ctx, CommandGetWindowBounds, p, &res)
  388. if err != nil {
  389. return nil, err
  390. }
  391. return res.Bounds, nil
  392. }
  393. // GetWindowForTargetParams get the browser window that contains the devtools
  394. // target.
  395. type GetWindowForTargetParams struct {
  396. TargetID target.ID `json:"targetId,omitempty,omitzero"` // Devtools agent host id. If called as a part of the session, associated targetId is used.
  397. }
  398. // GetWindowForTarget get the browser window that contains the devtools
  399. // target.
  400. //
  401. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getWindowForTarget
  402. //
  403. // parameters:
  404. func GetWindowForTarget() *GetWindowForTargetParams {
  405. return &GetWindowForTargetParams{}
  406. }
  407. // WithTargetID devtools agent host id. If called as a part of the session,
  408. // associated targetId is used.
  409. func (p GetWindowForTargetParams) WithTargetID(targetID target.ID) *GetWindowForTargetParams {
  410. p.TargetID = targetID
  411. return &p
  412. }
  413. // GetWindowForTargetReturns return values.
  414. type GetWindowForTargetReturns struct {
  415. WindowID WindowID `json:"windowId,omitempty,omitzero"` // Browser window id.
  416. Bounds *Bounds `json:"bounds,omitempty,omitzero"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  417. }
  418. // Do executes Browser.getWindowForTarget against the provided context.
  419. //
  420. // returns:
  421. //
  422. // windowID - Browser window id.
  423. // bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  424. func (p *GetWindowForTargetParams) Do(ctx context.Context) (windowID WindowID, bounds *Bounds, err error) {
  425. // execute
  426. var res GetWindowForTargetReturns
  427. err = cdp.Execute(ctx, CommandGetWindowForTarget, p, &res)
  428. if err != nil {
  429. return 0, nil, err
  430. }
  431. return res.WindowID, res.Bounds, nil
  432. }
  433. // SetWindowBoundsParams set position and/or size of the browser window.
  434. type SetWindowBoundsParams struct {
  435. WindowID WindowID `json:"windowId"` // Browser window id.
  436. Bounds *Bounds `json:"bounds"` // New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
  437. }
  438. // SetWindowBounds set position and/or size of the browser window.
  439. //
  440. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setWindowBounds
  441. //
  442. // parameters:
  443. //
  444. // windowID - Browser window id.
  445. // bounds - New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
  446. func SetWindowBounds(windowID WindowID, bounds *Bounds) *SetWindowBoundsParams {
  447. return &SetWindowBoundsParams{
  448. WindowID: windowID,
  449. Bounds: bounds,
  450. }
  451. }
  452. // Do executes Browser.setWindowBounds against the provided context.
  453. func (p *SetWindowBoundsParams) Do(ctx context.Context) (err error) {
  454. return cdp.Execute(ctx, CommandSetWindowBounds, p, nil)
  455. }
  456. // SetDockTileParams set dock tile details, platform-specific.
  457. type SetDockTileParams struct {
  458. BadgeLabel string `json:"badgeLabel,omitempty,omitzero"`
  459. Image string `json:"image,omitempty,omitzero"` // Png encoded image.
  460. }
  461. // SetDockTile set dock tile details, platform-specific.
  462. //
  463. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setDockTile
  464. //
  465. // parameters:
  466. func SetDockTile() *SetDockTileParams {
  467. return &SetDockTileParams{}
  468. }
  469. // WithBadgeLabel [no description].
  470. func (p SetDockTileParams) WithBadgeLabel(badgeLabel string) *SetDockTileParams {
  471. p.BadgeLabel = badgeLabel
  472. return &p
  473. }
  474. // WithImage png encoded image.
  475. func (p SetDockTileParams) WithImage(image string) *SetDockTileParams {
  476. p.Image = image
  477. return &p
  478. }
  479. // Do executes Browser.setDockTile against the provided context.
  480. func (p *SetDockTileParams) Do(ctx context.Context) (err error) {
  481. return cdp.Execute(ctx, CommandSetDockTile, p, nil)
  482. }
  483. // ExecuteBrowserCommandParams invoke custom browser commands used by
  484. // telemetry.
  485. type ExecuteBrowserCommandParams struct {
  486. CommandID CommandID `json:"commandId"`
  487. }
  488. // ExecuteBrowserCommand invoke custom browser commands used by telemetry.
  489. //
  490. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-executeBrowserCommand
  491. //
  492. // parameters:
  493. //
  494. // commandID
  495. func ExecuteBrowserCommand(commandID CommandID) *ExecuteBrowserCommandParams {
  496. return &ExecuteBrowserCommandParams{
  497. CommandID: commandID,
  498. }
  499. }
  500. // Do executes Browser.executeBrowserCommand against the provided context.
  501. func (p *ExecuteBrowserCommandParams) Do(ctx context.Context) (err error) {
  502. return cdp.Execute(ctx, CommandExecuteBrowserCommand, p, nil)
  503. }
  504. // AddPrivacySandboxEnrollmentOverrideParams allows a site to use privacy
  505. // sandbox features that require enrollment without the site actually being
  506. // enrolled. Only supported on page targets.
  507. type AddPrivacySandboxEnrollmentOverrideParams struct {
  508. URL string `json:"url"`
  509. }
  510. // AddPrivacySandboxEnrollmentOverride allows a site to use privacy sandbox
  511. // features that require enrollment without the site actually being enrolled.
  512. // Only supported on page targets.
  513. //
  514. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-addPrivacySandboxEnrollmentOverride
  515. //
  516. // parameters:
  517. //
  518. // url
  519. func AddPrivacySandboxEnrollmentOverride(url string) *AddPrivacySandboxEnrollmentOverrideParams {
  520. return &AddPrivacySandboxEnrollmentOverrideParams{
  521. URL: url,
  522. }
  523. }
  524. // Do executes Browser.addPrivacySandboxEnrollmentOverride against the provided context.
  525. func (p *AddPrivacySandboxEnrollmentOverrideParams) Do(ctx context.Context) (err error) {
  526. return cdp.Execute(ctx, CommandAddPrivacySandboxEnrollmentOverride, p, nil)
  527. }
  528. // AddPrivacySandboxCoordinatorKeyConfigParams configures encryption keys
  529. // used with a given privacy sandbox API to talk to a trusted coordinator. Since
  530. // this is intended for test automation only, coordinatorOrigin must be a .test
  531. // domain. No existing coordinator configuration for the origin may exist.
  532. type AddPrivacySandboxCoordinatorKeyConfigParams struct {
  533. API PrivacySandboxAPI `json:"api"`
  534. CoordinatorOrigin string `json:"coordinatorOrigin"`
  535. KeyConfig string `json:"keyConfig"`
  536. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // BrowserContext to perform the action in. When omitted, default browser context is used.
  537. }
  538. // AddPrivacySandboxCoordinatorKeyConfig configures encryption keys used with
  539. // a given privacy sandbox API to talk to a trusted coordinator. Since this is
  540. // intended for test automation only, coordinatorOrigin must be a .test domain.
  541. // No existing coordinator configuration for the origin may exist.
  542. //
  543. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-addPrivacySandboxCoordinatorKeyConfig
  544. //
  545. // parameters:
  546. //
  547. // api
  548. // coordinatorOrigin
  549. // keyConfig
  550. func AddPrivacySandboxCoordinatorKeyConfig(api PrivacySandboxAPI, coordinatorOrigin string, keyConfig string) *AddPrivacySandboxCoordinatorKeyConfigParams {
  551. return &AddPrivacySandboxCoordinatorKeyConfigParams{
  552. API: api,
  553. CoordinatorOrigin: coordinatorOrigin,
  554. KeyConfig: keyConfig,
  555. }
  556. }
  557. // WithBrowserContextID browserContext to perform the action in. When
  558. // omitted, default browser context is used.
  559. func (p AddPrivacySandboxCoordinatorKeyConfigParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *AddPrivacySandboxCoordinatorKeyConfigParams {
  560. p.BrowserContextID = browserContextID
  561. return &p
  562. }
  563. // Do executes Browser.addPrivacySandboxCoordinatorKeyConfig against the provided context.
  564. func (p *AddPrivacySandboxCoordinatorKeyConfigParams) Do(ctx context.Context) (err error) {
  565. return cdp.Execute(ctx, CommandAddPrivacySandboxCoordinatorKeyConfig, p, nil)
  566. }
  567. // Command names.
  568. const (
  569. CommandSetPermission = "Browser.setPermission"
  570. CommandGrantPermissions = "Browser.grantPermissions"
  571. CommandResetPermissions = "Browser.resetPermissions"
  572. CommandSetDownloadBehavior = "Browser.setDownloadBehavior"
  573. CommandCancelDownload = "Browser.cancelDownload"
  574. CommandClose = "Browser.close"
  575. CommandCrash = "Browser.crash"
  576. CommandCrashGPUProcess = "Browser.crashGpuProcess"
  577. CommandGetVersion = "Browser.getVersion"
  578. CommandGetBrowserCommandLine = "Browser.getBrowserCommandLine"
  579. CommandGetHistograms = "Browser.getHistograms"
  580. CommandGetHistogram = "Browser.getHistogram"
  581. CommandGetWindowBounds = "Browser.getWindowBounds"
  582. CommandGetWindowForTarget = "Browser.getWindowForTarget"
  583. CommandSetWindowBounds = "Browser.setWindowBounds"
  584. CommandSetDockTile = "Browser.setDockTile"
  585. CommandExecuteBrowserCommand = "Browser.executeBrowserCommand"
  586. CommandAddPrivacySandboxEnrollmentOverride = "Browser.addPrivacySandboxEnrollmentOverride"
  587. CommandAddPrivacySandboxCoordinatorKeyConfig = "Browser.addPrivacySandboxCoordinatorKeyConfig"
  588. )