browser.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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"` // Origin the permission applies to, all origins if not specified.
  19. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty"` // 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"` // Origin the permission applies to, all origins if not specified.
  55. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty"` // 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"` // 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"` // BrowserContext to set download behavior. When omitted, default browser context is used.
  111. DownloadPath string `json:"downloadPath,omitempty"` // The default path to save downloaded files to. This is required if behavior is set to 'allow' or 'allowAndName'.
  112. EventsEnabled bool `json:"eventsEnabled,omitempty"` // 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. }
  125. }
  126. // WithBrowserContextID browserContext to set download behavior. When
  127. // omitted, default browser context is used.
  128. func (p SetDownloadBehaviorParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *SetDownloadBehaviorParams {
  129. p.BrowserContextID = browserContextID
  130. return &p
  131. }
  132. // WithDownloadPath the default path to save downloaded files to. This is
  133. // required if behavior is set to 'allow' or 'allowAndName'.
  134. func (p SetDownloadBehaviorParams) WithDownloadPath(downloadPath string) *SetDownloadBehaviorParams {
  135. p.DownloadPath = downloadPath
  136. return &p
  137. }
  138. // WithEventsEnabled whether to emit download events (defaults to false).
  139. func (p SetDownloadBehaviorParams) WithEventsEnabled(eventsEnabled bool) *SetDownloadBehaviorParams {
  140. p.EventsEnabled = eventsEnabled
  141. return &p
  142. }
  143. // Do executes Browser.setDownloadBehavior against the provided context.
  144. func (p *SetDownloadBehaviorParams) Do(ctx context.Context) (err error) {
  145. return cdp.Execute(ctx, CommandSetDownloadBehavior, p, nil)
  146. }
  147. // CancelDownloadParams cancel a download if in progress.
  148. type CancelDownloadParams struct {
  149. GUID string `json:"guid"` // Global unique identifier of the download.
  150. BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty"` // BrowserContext to perform the action in. When omitted, default browser context is used.
  151. }
  152. // CancelDownload cancel a download if in progress.
  153. //
  154. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-cancelDownload
  155. //
  156. // parameters:
  157. //
  158. // guid - Global unique identifier of the download.
  159. func CancelDownload(guid string) *CancelDownloadParams {
  160. return &CancelDownloadParams{
  161. GUID: guid,
  162. }
  163. }
  164. // WithBrowserContextID browserContext to perform the action in. When
  165. // omitted, default browser context is used.
  166. func (p CancelDownloadParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *CancelDownloadParams {
  167. p.BrowserContextID = browserContextID
  168. return &p
  169. }
  170. // Do executes Browser.cancelDownload against the provided context.
  171. func (p *CancelDownloadParams) Do(ctx context.Context) (err error) {
  172. return cdp.Execute(ctx, CommandCancelDownload, p, nil)
  173. }
  174. // CloseParams close browser gracefully.
  175. type CloseParams struct{}
  176. // Close close browser gracefully.
  177. //
  178. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-close
  179. func Close() *CloseParams {
  180. return &CloseParams{}
  181. }
  182. // Do executes Browser.close against the provided context.
  183. func (p *CloseParams) Do(ctx context.Context) (err error) {
  184. return cdp.Execute(ctx, CommandClose, nil, nil)
  185. }
  186. // CrashParams crashes browser on the main thread.
  187. type CrashParams struct{}
  188. // Crash crashes browser on the main thread.
  189. //
  190. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-crash
  191. func Crash() *CrashParams {
  192. return &CrashParams{}
  193. }
  194. // Do executes Browser.crash against the provided context.
  195. func (p *CrashParams) Do(ctx context.Context) (err error) {
  196. return cdp.Execute(ctx, CommandCrash, nil, nil)
  197. }
  198. // CrashGpuProcessParams crashes GPU process.
  199. type CrashGpuProcessParams struct{}
  200. // CrashGpuProcess crashes GPU process.
  201. //
  202. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-crashGpuProcess
  203. func CrashGpuProcess() *CrashGpuProcessParams {
  204. return &CrashGpuProcessParams{}
  205. }
  206. // Do executes Browser.crashGpuProcess against the provided context.
  207. func (p *CrashGpuProcessParams) Do(ctx context.Context) (err error) {
  208. return cdp.Execute(ctx, CommandCrashGpuProcess, nil, nil)
  209. }
  210. // GetVersionParams returns version information.
  211. type GetVersionParams struct{}
  212. // GetVersion returns version information.
  213. //
  214. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getVersion
  215. func GetVersion() *GetVersionParams {
  216. return &GetVersionParams{}
  217. }
  218. // GetVersionReturns return values.
  219. type GetVersionReturns struct {
  220. ProtocolVersion string `json:"protocolVersion,omitempty"` // Protocol version.
  221. Product string `json:"product,omitempty"` // Product name.
  222. Revision string `json:"revision,omitempty"` // Product revision.
  223. UserAgent string `json:"userAgent,omitempty"` // User-Agent.
  224. JsVersion string `json:"jsVersion,omitempty"` // V8 version.
  225. }
  226. // Do executes Browser.getVersion against the provided context.
  227. //
  228. // returns:
  229. //
  230. // protocolVersion - Protocol version.
  231. // product - Product name.
  232. // revision - Product revision.
  233. // userAgent - User-Agent.
  234. // jsVersion - V8 version.
  235. func (p *GetVersionParams) Do(ctx context.Context) (protocolVersion string, product string, revision string, userAgent string, jsVersion string, err error) {
  236. // execute
  237. var res GetVersionReturns
  238. err = cdp.Execute(ctx, CommandGetVersion, nil, &res)
  239. if err != nil {
  240. return "", "", "", "", "", err
  241. }
  242. return res.ProtocolVersion, res.Product, res.Revision, res.UserAgent, res.JsVersion, nil
  243. }
  244. // GetBrowserCommandLineParams returns the command line switches for the
  245. // browser process if, and only if --enable-automation is on the commandline.
  246. type GetBrowserCommandLineParams struct{}
  247. // GetBrowserCommandLine returns the command line switches for the browser
  248. // process if, and only if --enable-automation is on the commandline.
  249. //
  250. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getBrowserCommandLine
  251. func GetBrowserCommandLine() *GetBrowserCommandLineParams {
  252. return &GetBrowserCommandLineParams{}
  253. }
  254. // GetBrowserCommandLineReturns return values.
  255. type GetBrowserCommandLineReturns struct {
  256. Arguments []string `json:"arguments,omitempty"` // Commandline parameters
  257. }
  258. // Do executes Browser.getBrowserCommandLine against the provided context.
  259. //
  260. // returns:
  261. //
  262. // arguments - Commandline parameters
  263. func (p *GetBrowserCommandLineParams) Do(ctx context.Context) (arguments []string, err error) {
  264. // execute
  265. var res GetBrowserCommandLineReturns
  266. err = cdp.Execute(ctx, CommandGetBrowserCommandLine, nil, &res)
  267. if err != nil {
  268. return nil, err
  269. }
  270. return res.Arguments, nil
  271. }
  272. // GetHistogramsParams get Chrome histograms.
  273. type GetHistogramsParams struct {
  274. Query string `json:"query,omitempty"` // 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.
  275. Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last delta call.
  276. }
  277. // GetHistograms get Chrome histograms.
  278. //
  279. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getHistograms
  280. //
  281. // parameters:
  282. func GetHistograms() *GetHistogramsParams {
  283. return &GetHistogramsParams{}
  284. }
  285. // WithQuery requested substring in name. Only histograms which have query as
  286. // a substring in their name are extracted. An empty or absent query returns all
  287. // histograms.
  288. func (p GetHistogramsParams) WithQuery(query string) *GetHistogramsParams {
  289. p.Query = query
  290. return &p
  291. }
  292. // WithDelta if true, retrieve delta since last delta call.
  293. func (p GetHistogramsParams) WithDelta(delta bool) *GetHistogramsParams {
  294. p.Delta = delta
  295. return &p
  296. }
  297. // GetHistogramsReturns return values.
  298. type GetHistogramsReturns struct {
  299. Histograms []*Histogram `json:"histograms,omitempty"` // Histograms.
  300. }
  301. // Do executes Browser.getHistograms against the provided context.
  302. //
  303. // returns:
  304. //
  305. // histograms - Histograms.
  306. func (p *GetHistogramsParams) Do(ctx context.Context) (histograms []*Histogram, err error) {
  307. // execute
  308. var res GetHistogramsReturns
  309. err = cdp.Execute(ctx, CommandGetHistograms, p, &res)
  310. if err != nil {
  311. return nil, err
  312. }
  313. return res.Histograms, nil
  314. }
  315. // GetHistogramParams get a Chrome histogram by name.
  316. type GetHistogramParams struct {
  317. Name string `json:"name"` // Requested histogram name.
  318. Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last delta call.
  319. }
  320. // GetHistogram get a Chrome histogram by name.
  321. //
  322. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getHistogram
  323. //
  324. // parameters:
  325. //
  326. // name - Requested histogram name.
  327. func GetHistogram(name string) *GetHistogramParams {
  328. return &GetHistogramParams{
  329. Name: name,
  330. }
  331. }
  332. // WithDelta if true, retrieve delta since last delta call.
  333. func (p GetHistogramParams) WithDelta(delta bool) *GetHistogramParams {
  334. p.Delta = delta
  335. return &p
  336. }
  337. // GetHistogramReturns return values.
  338. type GetHistogramReturns struct {
  339. Histogram *Histogram `json:"histogram,omitempty"` // Histogram.
  340. }
  341. // Do executes Browser.getHistogram against the provided context.
  342. //
  343. // returns:
  344. //
  345. // histogram - Histogram.
  346. func (p *GetHistogramParams) Do(ctx context.Context) (histogram *Histogram, err error) {
  347. // execute
  348. var res GetHistogramReturns
  349. err = cdp.Execute(ctx, CommandGetHistogram, p, &res)
  350. if err != nil {
  351. return nil, err
  352. }
  353. return res.Histogram, nil
  354. }
  355. // GetWindowBoundsParams get position and size of the browser window.
  356. type GetWindowBoundsParams struct {
  357. WindowID WindowID `json:"windowId"` // Browser window id.
  358. }
  359. // GetWindowBounds get position and size of the browser window.
  360. //
  361. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getWindowBounds
  362. //
  363. // parameters:
  364. //
  365. // windowID - Browser window id.
  366. func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams {
  367. return &GetWindowBoundsParams{
  368. WindowID: windowID,
  369. }
  370. }
  371. // GetWindowBoundsReturns return values.
  372. type GetWindowBoundsReturns struct {
  373. Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  374. }
  375. // Do executes Browser.getWindowBounds against the provided context.
  376. //
  377. // returns:
  378. //
  379. // bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  380. func (p *GetWindowBoundsParams) Do(ctx context.Context) (bounds *Bounds, err error) {
  381. // execute
  382. var res GetWindowBoundsReturns
  383. err = cdp.Execute(ctx, CommandGetWindowBounds, p, &res)
  384. if err != nil {
  385. return nil, err
  386. }
  387. return res.Bounds, nil
  388. }
  389. // GetWindowForTargetParams get the browser window that contains the devtools
  390. // target.
  391. type GetWindowForTargetParams struct {
  392. TargetID target.ID `json:"targetId,omitempty"` // Devtools agent host id. If called as a part of the session, associated targetId is used.
  393. }
  394. // GetWindowForTarget get the browser window that contains the devtools
  395. // target.
  396. //
  397. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getWindowForTarget
  398. //
  399. // parameters:
  400. func GetWindowForTarget() *GetWindowForTargetParams {
  401. return &GetWindowForTargetParams{}
  402. }
  403. // WithTargetID devtools agent host id. If called as a part of the session,
  404. // associated targetId is used.
  405. func (p GetWindowForTargetParams) WithTargetID(targetID target.ID) *GetWindowForTargetParams {
  406. p.TargetID = targetID
  407. return &p
  408. }
  409. // GetWindowForTargetReturns return values.
  410. type GetWindowForTargetReturns struct {
  411. WindowID WindowID `json:"windowId,omitempty"` // Browser window id.
  412. Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  413. }
  414. // Do executes Browser.getWindowForTarget against the provided context.
  415. //
  416. // returns:
  417. //
  418. // windowID - Browser window id.
  419. // bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
  420. func (p *GetWindowForTargetParams) Do(ctx context.Context) (windowID WindowID, bounds *Bounds, err error) {
  421. // execute
  422. var res GetWindowForTargetReturns
  423. err = cdp.Execute(ctx, CommandGetWindowForTarget, p, &res)
  424. if err != nil {
  425. return 0, nil, err
  426. }
  427. return res.WindowID, res.Bounds, nil
  428. }
  429. // SetWindowBoundsParams set position and/or size of the browser window.
  430. type SetWindowBoundsParams struct {
  431. WindowID WindowID `json:"windowId"` // Browser window id.
  432. 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.
  433. }
  434. // SetWindowBounds set position and/or size of the browser window.
  435. //
  436. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setWindowBounds
  437. //
  438. // parameters:
  439. //
  440. // windowID - Browser window id.
  441. // bounds - New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
  442. func SetWindowBounds(windowID WindowID, bounds *Bounds) *SetWindowBoundsParams {
  443. return &SetWindowBoundsParams{
  444. WindowID: windowID,
  445. Bounds: bounds,
  446. }
  447. }
  448. // Do executes Browser.setWindowBounds against the provided context.
  449. func (p *SetWindowBoundsParams) Do(ctx context.Context) (err error) {
  450. return cdp.Execute(ctx, CommandSetWindowBounds, p, nil)
  451. }
  452. // SetDockTileParams set dock tile details, platform-specific.
  453. type SetDockTileParams struct {
  454. BadgeLabel string `json:"badgeLabel,omitempty"`
  455. Image string `json:"image,omitempty"` // Png encoded image.
  456. }
  457. // SetDockTile set dock tile details, platform-specific.
  458. //
  459. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-setDockTile
  460. //
  461. // parameters:
  462. func SetDockTile() *SetDockTileParams {
  463. return &SetDockTileParams{}
  464. }
  465. // WithBadgeLabel [no description].
  466. func (p SetDockTileParams) WithBadgeLabel(badgeLabel string) *SetDockTileParams {
  467. p.BadgeLabel = badgeLabel
  468. return &p
  469. }
  470. // WithImage png encoded image.
  471. func (p SetDockTileParams) WithImage(image string) *SetDockTileParams {
  472. p.Image = image
  473. return &p
  474. }
  475. // Do executes Browser.setDockTile against the provided context.
  476. func (p *SetDockTileParams) Do(ctx context.Context) (err error) {
  477. return cdp.Execute(ctx, CommandSetDockTile, p, nil)
  478. }
  479. // ExecuteBrowserCommandParams invoke custom browser commands used by
  480. // telemetry.
  481. type ExecuteBrowserCommandParams struct {
  482. CommandID CommandID `json:"commandId"`
  483. }
  484. // ExecuteBrowserCommand invoke custom browser commands used by telemetry.
  485. //
  486. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-executeBrowserCommand
  487. //
  488. // parameters:
  489. //
  490. // commandID
  491. func ExecuteBrowserCommand(commandID CommandID) *ExecuteBrowserCommandParams {
  492. return &ExecuteBrowserCommandParams{
  493. CommandID: commandID,
  494. }
  495. }
  496. // Do executes Browser.executeBrowserCommand against the provided context.
  497. func (p *ExecuteBrowserCommandParams) Do(ctx context.Context) (err error) {
  498. return cdp.Execute(ctx, CommandExecuteBrowserCommand, p, nil)
  499. }
  500. // AddPrivacySandboxEnrollmentOverrideParams allows a site to use privacy
  501. // sandbox features that require enrollment without the site actually being
  502. // enrolled. Only supported on page targets.
  503. type AddPrivacySandboxEnrollmentOverrideParams struct {
  504. URL string `json:"url"`
  505. }
  506. // AddPrivacySandboxEnrollmentOverride allows a site to use privacy sandbox
  507. // features that require enrollment without the site actually being enrolled.
  508. // Only supported on page targets.
  509. //
  510. // See: https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-addPrivacySandboxEnrollmentOverride
  511. //
  512. // parameters:
  513. //
  514. // url
  515. func AddPrivacySandboxEnrollmentOverride(url string) *AddPrivacySandboxEnrollmentOverrideParams {
  516. return &AddPrivacySandboxEnrollmentOverrideParams{
  517. URL: url,
  518. }
  519. }
  520. // Do executes Browser.addPrivacySandboxEnrollmentOverride against the provided context.
  521. func (p *AddPrivacySandboxEnrollmentOverrideParams) Do(ctx context.Context) (err error) {
  522. return cdp.Execute(ctx, CommandAddPrivacySandboxEnrollmentOverride, p, nil)
  523. }
  524. // Command names.
  525. const (
  526. CommandSetPermission = "Browser.setPermission"
  527. CommandGrantPermissions = "Browser.grantPermissions"
  528. CommandResetPermissions = "Browser.resetPermissions"
  529. CommandSetDownloadBehavior = "Browser.setDownloadBehavior"
  530. CommandCancelDownload = "Browser.cancelDownload"
  531. CommandClose = "Browser.close"
  532. CommandCrash = "Browser.crash"
  533. CommandCrashGpuProcess = "Browser.crashGpuProcess"
  534. CommandGetVersion = "Browser.getVersion"
  535. CommandGetBrowserCommandLine = "Browser.getBrowserCommandLine"
  536. CommandGetHistograms = "Browser.getHistograms"
  537. CommandGetHistogram = "Browser.getHistogram"
  538. CommandGetWindowBounds = "Browser.getWindowBounds"
  539. CommandGetWindowForTarget = "Browser.getWindowForTarget"
  540. CommandSetWindowBounds = "Browser.setWindowBounds"
  541. CommandSetDockTile = "Browser.setDockTile"
  542. CommandExecuteBrowserCommand = "Browser.executeBrowserCommand"
  543. CommandAddPrivacySandboxEnrollmentOverride = "Browser.addPrivacySandboxEnrollmentOverride"
  544. )