File: systeminfo.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (130 lines) | stat: -rw-r--r-- 4,456 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Package systeminfo provides the Chrome DevTools Protocol
// commands, types, and events for the SystemInfo domain.
//
// The SystemInfo domain defines methods and events for querying low-level
// system information.
//
// Generated by the cdproto-gen command.
package systeminfo

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"context"

	"github.com/chromedp/cdproto/cdp"
)

// GetInfoParams returns information about the system.
type GetInfoParams struct{}

// GetInfo returns information about the system.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getInfo
func GetInfo() *GetInfoParams {
	return &GetInfoParams{}
}

// GetInfoReturns return values.
type GetInfoReturns struct {
	Gpu          *GPUInfo `json:"gpu,omitempty"`          // Information about the GPUs on the system.
	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.
	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.
	CommandLine  string   `json:"commandLine,omitempty"`  // The command line string used to launch the browser. Will be the empty string if not supported.
}

// Do executes SystemInfo.getInfo against the provided context.
//
// returns:
//
//	gpu - Information about the GPUs on the system.
//	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.
//	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.
//	commandLine - The command line string used to launch the browser. Will be the empty string if not supported.
func (p *GetInfoParams) Do(ctx context.Context) (gpu *GPUInfo, modelName string, modelVersion string, commandLine string, err error) {
	// execute
	var res GetInfoReturns
	err = cdp.Execute(ctx, CommandGetInfo, nil, &res)
	if err != nil {
		return nil, "", "", "", err
	}

	return res.Gpu, res.ModelName, res.ModelVersion, res.CommandLine, nil
}

// GetFeatureStateParams returns information about the feature state.
type GetFeatureStateParams struct {
	FeatureState string `json:"featureState"`
}

// GetFeatureState returns information about the feature state.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getFeatureState
//
// parameters:
//
//	featureState
func GetFeatureState(featureState string) *GetFeatureStateParams {
	return &GetFeatureStateParams{
		FeatureState: featureState,
	}
}

// GetFeatureStateReturns return values.
type GetFeatureStateReturns struct {
	FeatureEnabled bool `json:"featureEnabled,omitempty"`
}

// Do executes SystemInfo.getFeatureState against the provided context.
//
// returns:
//
//	featureEnabled
func (p *GetFeatureStateParams) Do(ctx context.Context) (featureEnabled bool, err error) {
	// execute
	var res GetFeatureStateReturns
	err = cdp.Execute(ctx, CommandGetFeatureState, p, &res)
	if err != nil {
		return false, err
	}

	return res.FeatureEnabled, nil
}

// GetProcessInfoParams returns information about all running processes.
type GetProcessInfoParams struct{}

// GetProcessInfo returns information about all running processes.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/SystemInfo#method-getProcessInfo
func GetProcessInfo() *GetProcessInfoParams {
	return &GetProcessInfoParams{}
}

// GetProcessInfoReturns return values.
type GetProcessInfoReturns struct {
	ProcessInfo []*ProcessInfo `json:"processInfo,omitempty"` // An array of process info blocks.
}

// Do executes SystemInfo.getProcessInfo against the provided context.
//
// returns:
//
//	processInfo - An array of process info blocks.
func (p *GetProcessInfoParams) Do(ctx context.Context) (processInfo []*ProcessInfo, err error) {
	// execute
	var res GetProcessInfoReturns
	err = cdp.Execute(ctx, CommandGetProcessInfo, nil, &res)
	if err != nil {
		return nil, err
	}

	return res.ProcessInfo, nil
}

// Command names.
const (
	CommandGetInfo         = "SystemInfo.getInfo"
	CommandGetFeatureState = "SystemInfo.getFeatureState"
	CommandGetProcessInfo  = "SystemInfo.getProcessInfo"
)