autofill.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Package autofill provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Autofill domain.
  3. //
  4. // Defines commands and events for Autofill.
  5. //
  6. // Generated by the cdproto-gen command.
  7. package autofill
  8. // Code generated by cdproto-gen. DO NOT EDIT.
  9. import (
  10. "context"
  11. "github.com/chromedp/cdproto/cdp"
  12. )
  13. // TriggerParams trigger autofill on a form identified by the fieldId. If the
  14. // field and related form cannot be autofilled, returns an error.
  15. type TriggerParams struct {
  16. FieldID cdp.BackendNodeID `json:"fieldId"` // Identifies a field that serves as an anchor for autofill.
  17. FrameID cdp.FrameID `json:"frameId,omitempty"` // Identifies the frame that field belongs to.
  18. Card *CreditCard `json:"card"` // Credit card information to fill out the form. Credit card data is not saved.
  19. }
  20. // Trigger trigger autofill on a form identified by the fieldId. If the field
  21. // and related form cannot be autofilled, returns an error.
  22. //
  23. // See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-trigger
  24. //
  25. // parameters:
  26. //
  27. // fieldID - Identifies a field that serves as an anchor for autofill.
  28. // card - Credit card information to fill out the form. Credit card data is not saved.
  29. func Trigger(fieldID cdp.BackendNodeID, card *CreditCard) *TriggerParams {
  30. return &TriggerParams{
  31. FieldID: fieldID,
  32. Card: card,
  33. }
  34. }
  35. // WithFrameID identifies the frame that field belongs to.
  36. func (p TriggerParams) WithFrameID(frameID cdp.FrameID) *TriggerParams {
  37. p.FrameID = frameID
  38. return &p
  39. }
  40. // Do executes Autofill.trigger against the provided context.
  41. func (p *TriggerParams) Do(ctx context.Context) (err error) {
  42. return cdp.Execute(ctx, CommandTrigger, p, nil)
  43. }
  44. // SetAddressesParams set addresses so that developers can verify their forms
  45. // implementation.
  46. type SetAddressesParams struct {
  47. Addresses []*Address `json:"addresses"`
  48. }
  49. // SetAddresses set addresses so that developers can verify their forms
  50. // implementation.
  51. //
  52. // See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-setAddresses
  53. //
  54. // parameters:
  55. //
  56. // addresses
  57. func SetAddresses(addresses []*Address) *SetAddressesParams {
  58. return &SetAddressesParams{
  59. Addresses: addresses,
  60. }
  61. }
  62. // Do executes Autofill.setAddresses against the provided context.
  63. func (p *SetAddressesParams) Do(ctx context.Context) (err error) {
  64. return cdp.Execute(ctx, CommandSetAddresses, p, nil)
  65. }
  66. // DisableParams disables autofill domain notifications.
  67. type DisableParams struct{}
  68. // Disable disables autofill domain notifications.
  69. //
  70. // See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-disable
  71. func Disable() *DisableParams {
  72. return &DisableParams{}
  73. }
  74. // Do executes Autofill.disable against the provided context.
  75. func (p *DisableParams) Do(ctx context.Context) (err error) {
  76. return cdp.Execute(ctx, CommandDisable, nil, nil)
  77. }
  78. // EnableParams enables autofill domain notifications.
  79. type EnableParams struct{}
  80. // Enable enables autofill domain notifications.
  81. //
  82. // See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-enable
  83. func Enable() *EnableParams {
  84. return &EnableParams{}
  85. }
  86. // Do executes Autofill.enable against the provided context.
  87. func (p *EnableParams) Do(ctx context.Context) (err error) {
  88. return cdp.Execute(ctx, CommandEnable, nil, nil)
  89. }
  90. // Command names.
  91. const (
  92. CommandTrigger = "Autofill.trigger"
  93. CommandSetAddresses = "Autofill.setAddresses"
  94. CommandDisable = "Autofill.disable"
  95. CommandEnable = "Autofill.enable"
  96. )