chore: remove experimental from navigator.serial implementation (#30237)
This commit is contained in:
parent
3ee6326b93
commit
9cc1b55663
4 changed files with 8 additions and 27 deletions
|
@ -180,7 +180,7 @@ Emitted when a hunspell dictionary file download fails. For details
|
||||||
on the failure you should collect a netlog and inspect the download
|
on the failure you should collect a netlog and inspect the download
|
||||||
request.
|
request.
|
||||||
|
|
||||||
#### Event: 'select-serial-port' _Experimental_
|
#### Event: 'select-serial-port'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
|
@ -197,14 +197,10 @@ cancel the request. Additionally, permissioning on `navigator.serial` can
|
||||||
be managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler)
|
be managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler)
|
||||||
with the `serial` permission.
|
with the `serial` permission.
|
||||||
|
|
||||||
Because this is an experimental feature it is disabled by default. To enable this feature, you
|
|
||||||
will need to use the `--enable-features=ElectronSerialChooser` command line switch.
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
let win = null
|
let win = null
|
||||||
app.commandLine.appendSwitch('enable-features', 'ElectronSerialChooser')
|
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
|
@ -225,7 +221,7 @@ app.whenReady().then(() => {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Event: 'serial-port-added' _Experimental_
|
#### Event: 'serial-port-added'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
|
@ -235,7 +231,7 @@ Returns:
|
||||||
|
|
||||||
Emitted after `navigator.serial.requestPort` has been called and `select-serial-port` has fired if a new serial port becomes available. For example, this event will fire when a new USB device is plugged in.
|
Emitted after `navigator.serial.requestPort` has been called and `select-serial-port` has fired if a new serial port becomes available. For example, this event will fire when a new USB device is plugged in.
|
||||||
|
|
||||||
#### Event: 'serial-port-removed' _Experimental_
|
#### Event: 'serial-port-removed'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,6 @@
|
||||||
#include "shell/browser/serial/serial_chooser_controller.h"
|
#include "shell/browser/serial/serial_chooser_controller.h"
|
||||||
#include "shell/browser/web_contents_permission_helper.h"
|
#include "shell/browser/web_contents_permission_helper.h"
|
||||||
|
|
||||||
namespace features {
|
|
||||||
|
|
||||||
const base::Feature kElectronSerialChooser{"ElectronSerialChooser",
|
|
||||||
base::FEATURE_DISABLED_BY_DEFAULT};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
SerialChooserContext* GetChooserContext(content::RenderFrameHost* frame) {
|
SerialChooserContext* GetChooserContext(content::RenderFrameHost* frame) {
|
||||||
|
@ -36,16 +30,11 @@ std::unique_ptr<content::SerialChooser> ElectronSerialDelegate::RunChooser(
|
||||||
content::RenderFrameHost* frame,
|
content::RenderFrameHost* frame,
|
||||||
std::vector<blink::mojom::SerialPortFilterPtr> filters,
|
std::vector<blink::mojom::SerialPortFilterPtr> filters,
|
||||||
content::SerialChooser::Callback callback) {
|
content::SerialChooser::Callback callback) {
|
||||||
if (base::FeatureList::IsEnabled(features::kElectronSerialChooser)) {
|
|
||||||
SerialChooserController* controller = ControllerForFrame(frame);
|
SerialChooserController* controller = ControllerForFrame(frame);
|
||||||
if (controller) {
|
if (controller) {
|
||||||
DeleteControllerForFrame(frame);
|
DeleteControllerForFrame(frame);
|
||||||
}
|
}
|
||||||
AddControllerForFrame(frame, std::move(filters), std::move(callback));
|
AddControllerForFrame(frame, std::move(filters), std::move(callback));
|
||||||
} else {
|
|
||||||
// If feature is disabled, immediately return back with no port selected.
|
|
||||||
std::move(callback).Run(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a nullptr because the return value isn't used for anything, eg
|
// Return a nullptr because the return value isn't used for anything, eg
|
||||||
// there is no mechanism to cancel navigator.serial.requestPort(). The return
|
// there is no mechanism to cancel navigator.serial.requestPort(). The return
|
||||||
|
|
|
@ -1643,10 +1643,7 @@ describe('navigator.serial', () => {
|
||||||
let w: BrowserWindow;
|
let w: BrowserWindow;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
show: false,
|
show: false
|
||||||
webPreferences: {
|
|
||||||
enableBlinkFeatures: 'Serial'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,6 @@ const { app, protocol } = require('electron');
|
||||||
|
|
||||||
v8.setFlagsFromString('--expose_gc');
|
v8.setFlagsFromString('--expose_gc');
|
||||||
app.commandLine.appendSwitch('js-flags', '--expose_gc');
|
app.commandLine.appendSwitch('js-flags', '--expose_gc');
|
||||||
app.commandLine.appendSwitch('enable-features', 'ElectronSerialChooser');
|
|
||||||
// Prevent the spec runner quiting when the first window closes
|
// Prevent the spec runner quiting when the first window closes
|
||||||
app.on('window-all-closed', () => null);
|
app.on('window-all-closed', () => null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue