extensions.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Package extensions provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Extensions domain.
  3. //
  4. // Defines commands and events for browser extensions. Available if the
  5. // client is connected using the --remote-debugging-pipe flag and the
  6. // --enable-unsafe-extension-debugging flag is set.
  7. //
  8. // Generated by the cdproto-gen command.
  9. package extensions
  10. // Code generated by cdproto-gen. DO NOT EDIT.
  11. import (
  12. "context"
  13. "github.com/chromedp/cdproto/cdp"
  14. )
  15. // LoadUnpackedParams installs an unpacked extension from the filesystem
  16. // similar to --load-extension CLI flags. Returns extension ID once the
  17. // extension has been installed.
  18. type LoadUnpackedParams struct {
  19. Path string `json:"path"` // Absolute file path.
  20. }
  21. // LoadUnpacked installs an unpacked extension from the filesystem similar to
  22. // --load-extension CLI flags. Returns extension ID once the extension has been
  23. // installed.
  24. //
  25. // See: https://chromedevtools.github.io/devtools-protocol/tot/Extensions#method-loadUnpacked
  26. //
  27. // parameters:
  28. //
  29. // path - Absolute file path.
  30. func LoadUnpacked(path string) *LoadUnpackedParams {
  31. return &LoadUnpackedParams{
  32. Path: path,
  33. }
  34. }
  35. // LoadUnpackedReturns return values.
  36. type LoadUnpackedReturns struct {
  37. ID string `json:"id,omitempty"` // Extension id.
  38. }
  39. // Do executes Extensions.loadUnpacked against the provided context.
  40. //
  41. // returns:
  42. //
  43. // id - Extension id.
  44. func (p *LoadUnpackedParams) Do(ctx context.Context) (id string, err error) {
  45. // execute
  46. var res LoadUnpackedReturns
  47. err = cdp.Execute(ctx, CommandLoadUnpacked, p, &res)
  48. if err != nil {
  49. return "", err
  50. }
  51. return res.ID, nil
  52. }
  53. // Command names.
  54. const (
  55. CommandLoadUnpacked = "Extensions.loadUnpacked"
  56. )