systeminfo.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Package systeminfo provides the Chrome DevTools Protocol
  2. // commands, types, and events for the SystemInfo domain.
  3. //
  4. // The SystemInfo domain defines methods and events for querying low-level
  5. // system information.
  6. //
  7. // Generated by the cdproto-gen command.
  8. package systeminfo
  9. // Code generated by cdproto-gen. DO NOT EDIT.
  10. import (
  11. "context"
  12. "github.com/chromedp/cdproto/cdp"
  13. )
  14. // GetInfoParams returns information about the system.
  15. type GetInfoParams struct{}
  16. // GetInfo returns information about the system.
  17. //
  18. // See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getInfo
  19. func GetInfo() *GetInfoParams {
  20. return &GetInfoParams{}
  21. }
  22. // GetInfoReturns return values.
  23. type GetInfoReturns struct {
  24. Gpu *GPUInfo `json:"gpu,omitempty"` // Information about the GPUs on the system.
  25. ModelName string `json:"modelName,omitempty"` // A platform-dependent description of the model of the machine. On Mac OS, this is, for example, 'MacBookPro'. Will be the empty string if not supported.
  26. ModelVersion string `json:"modelVersion,omitempty"` // A platform-dependent description of the version of the machine. On Mac OS, this is, for example, '10.1'. Will be the empty string if not supported.
  27. CommandLine string `json:"commandLine,omitempty"` // The command line string used to launch the browser. Will be the empty string if not supported.
  28. }
  29. // Do executes SystemInfo.getInfo against the provided context.
  30. //
  31. // returns:
  32. //
  33. // gpu - Information about the GPUs on the system.
  34. // modelName - A platform-dependent description of the model of the machine. On Mac OS, this is, for example, 'MacBookPro'. Will be the empty string if not supported.
  35. // modelVersion - A platform-dependent description of the version of the machine. On Mac OS, this is, for example, '10.1'. Will be the empty string if not supported.
  36. // commandLine - The command line string used to launch the browser. Will be the empty string if not supported.
  37. func (p *GetInfoParams) Do(ctx context.Context) (gpu *GPUInfo, modelName string, modelVersion string, commandLine string, err error) {
  38. // execute
  39. var res GetInfoReturns
  40. err = cdp.Execute(ctx, CommandGetInfo, nil, &res)
  41. if err != nil {
  42. return nil, "", "", "", err
  43. }
  44. return res.Gpu, res.ModelName, res.ModelVersion, res.CommandLine, nil
  45. }
  46. // GetFeatureStateParams returns information about the feature state.
  47. type GetFeatureStateParams struct {
  48. FeatureState string `json:"featureState"`
  49. }
  50. // GetFeatureState returns information about the feature state.
  51. //
  52. // See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getFeatureState
  53. //
  54. // parameters:
  55. //
  56. // featureState
  57. func GetFeatureState(featureState string) *GetFeatureStateParams {
  58. return &GetFeatureStateParams{
  59. FeatureState: featureState,
  60. }
  61. }
  62. // GetFeatureStateReturns return values.
  63. type GetFeatureStateReturns struct {
  64. FeatureEnabled bool `json:"featureEnabled,omitempty"`
  65. }
  66. // Do executes SystemInfo.getFeatureState against the provided context.
  67. //
  68. // returns:
  69. //
  70. // featureEnabled
  71. func (p *GetFeatureStateParams) Do(ctx context.Context) (featureEnabled bool, err error) {
  72. // execute
  73. var res GetFeatureStateReturns
  74. err = cdp.Execute(ctx, CommandGetFeatureState, p, &res)
  75. if err != nil {
  76. return false, err
  77. }
  78. return res.FeatureEnabled, nil
  79. }
  80. // GetProcessInfoParams returns information about all running processes.
  81. type GetProcessInfoParams struct{}
  82. // GetProcessInfo returns information about all running processes.
  83. //
  84. // See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getProcessInfo
  85. func GetProcessInfo() *GetProcessInfoParams {
  86. return &GetProcessInfoParams{}
  87. }
  88. // GetProcessInfoReturns return values.
  89. type GetProcessInfoReturns struct {
  90. ProcessInfo []*ProcessInfo `json:"processInfo,omitempty"` // An array of process info blocks.
  91. }
  92. // Do executes SystemInfo.getProcessInfo against the provided context.
  93. //
  94. // returns:
  95. //
  96. // processInfo - An array of process info blocks.
  97. func (p *GetProcessInfoParams) Do(ctx context.Context) (processInfo []*ProcessInfo, err error) {
  98. // execute
  99. var res GetProcessInfoReturns
  100. err = cdp.Execute(ctx, CommandGetProcessInfo, nil, &res)
  101. if err != nil {
  102. return nil, err
  103. }
  104. return res.ProcessInfo, nil
  105. }
  106. // Command names.
  107. const (
  108. CommandGetInfo = "SystemInfo.getInfo"
  109. CommandGetFeatureState = "SystemInfo.getFeatureState"
  110. CommandGetProcessInfo = "SystemInfo.getProcessInfo"
  111. )