fd5e6fbc14
* chore: bump chromium in DEPS to 116.0.5793.3 * chore: update patches * chore: bump chromium in DEPS to 116.0.5795.0 * chore: update patches * chore: bump chromium in DEPS to 116.0.5797.0 * chore: update patches * chore: bump chromium in DEPS to 116.0.5799.0 * 4522192: [serial] Allow Bluetooth ports to be requested by service class ID. | https://chromium-review.googlesource.com/c/chromium/src/+/4522192 * 4545385: Create base:🍎:Owned[frameworktype], use it for gfx::NativeEvent | https://chromium-review.googlesource.com/c/chromium/src/+/4545385 * chore: bump chromium in DEPS to 116.0.5801.0 * chore: update patches * 4562796: Use base:🍎:Owned[frameworktype] for ui::PlatformEvent | https://chromium-review.googlesource.com/c/chromium/src/+/4562796 * 4559790: Manual raw_ptr rewrite: //base | https://chromium-review.googlesource.com/c/chromium/src/+/4559790 * chore: bump chromium in DEPS to 116.0.5803.0 * chore: update patches * chore: bump chromium in DEPS to 116.0.5805.2 * chore: update patches * 4547630: Move content/public/common/network_service_util.h to c/p/browser/ | https://chromium-review.googlesource.com/c/chromium/src/+/4547630 * 4510075: Adding extensions to network response experiment | https://chromium-review.googlesource.com/c/chromium/src/+/4510075 * 4566552: Auto-generate grd file for chrome://accessibility. | https://chromium-review.googlesource.com/c/chromium/src/+/4566552 * chore: bump chromium in DEPS to 116.0.5807.0 * chore: update patches * 4533536: [Privacy Hub] Geolocation manager used directly | https://chromium-review.googlesource.com/c/chromium/src/+/4533536 * chore: patch out ARC support from /chrome/browser 4571955: Convert /chrome/browser to use ARC | https://chromium-review.googlesource.com/c/chromium/src/+/4571955 * chore: bump chromium in DEPS to 116.0.5809.2 * chore: bump chromium in DEPS to 116.0.5811.0 * chore: update patches * 4573627: Adopt base::NoDestructor for KeyedService factories | https://chromium-review.googlesource.com/c/chromium/src/+/4573627 * 4576878: Reland "Shared Storage: Add mojo method for observing response headers" | https://chromium-review.googlesource.com/c/chromium/src/+/4576878 * chore: bump chromium in DEPS to 116.0.5813.0 * chore: update patches * fixup! 4566552: Auto-generate grd file for chrome://accessibility. | https://chromium-review.googlesource.com/c/chromium/src/+/4566552 * chore: fix up lint * test: (debug) use Promise.all in asan tests * chore: manually roll DEPS to 116.0.5815.0 * chore: update patches * 4585150: Convert /printing to use ARC | https://chromium-review.googlesource.com/c/chromium/src/+/4585150 * test: (asan) extend timeout, clean up debugging * chore: remove ARC chromium patch * chore: update patches after main sync * 4546398: Convert /chrome/browser to use ARC | https://chromium-review.googlesource.com/c/chromium/src/+/4546398 * build: add chrome_lib_arc for chromium_src/BUILD.gn sources * fixup! 4559790: Manual raw_ptr rewrite: //base | https://chromium-review.googlesource.com/c/chromium/src/+/4559790 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: VerteDinde <keeleymhammond@gmail.com>
103 lines
3.9 KiB
C++
103 lines
3.9 KiB
C++
// Copyright (c) 2020 Microsoft, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_SERIAL_ELECTRON_SERIAL_DELEGATE_H_
|
|
#define ELECTRON_SHELL_BROWSER_SERIAL_ELECTRON_SERIAL_DELEGATE_H_
|
|
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "base/scoped_observation.h"
|
|
#include "content/public/browser/serial_delegate.h"
|
|
#include "shell/browser/serial/serial_chooser_context.h"
|
|
#include "shell/browser/serial/serial_chooser_controller.h"
|
|
|
|
namespace electron {
|
|
|
|
class SerialChooserController;
|
|
|
|
class ElectronSerialDelegate : public content::SerialDelegate,
|
|
public SerialChooserContext::PortObserver {
|
|
public:
|
|
ElectronSerialDelegate();
|
|
~ElectronSerialDelegate() override;
|
|
|
|
// disable copy
|
|
ElectronSerialDelegate(const ElectronSerialDelegate&) = delete;
|
|
ElectronSerialDelegate& operator=(const ElectronSerialDelegate&) = delete;
|
|
|
|
std::unique_ptr<content::SerialChooser> RunChooser(
|
|
content::RenderFrameHost* frame,
|
|
std::vector<blink::mojom::SerialPortFilterPtr> filters,
|
|
std::vector<device::BluetoothUUID> allowed_bluetooth_service_class_ids,
|
|
content::SerialChooser::Callback callback) override;
|
|
bool CanRequestPortPermission(content::RenderFrameHost* frame) override;
|
|
bool HasPortPermission(content::RenderFrameHost* frame,
|
|
const device::mojom::SerialPortInfo& port) override;
|
|
void RevokePortPermissionWebInitiated(
|
|
content::RenderFrameHost* frame,
|
|
const base::UnguessableToken& token) override;
|
|
const device::mojom::SerialPortInfo* GetPortInfo(
|
|
content::RenderFrameHost* frame,
|
|
const base::UnguessableToken& token) override;
|
|
device::mojom::SerialPortManager* GetPortManager(
|
|
content::RenderFrameHost* frame) override;
|
|
void AddObserver(content::RenderFrameHost* frame,
|
|
content::SerialDelegate::Observer* observer) override;
|
|
void RemoveObserver(content::RenderFrameHost* frame,
|
|
content::SerialDelegate::Observer* observer) override;
|
|
|
|
void DeleteControllerForFrame(content::RenderFrameHost* render_frame_host);
|
|
|
|
// SerialChooserContext::PortObserver:
|
|
void OnPortAdded(const device::mojom::SerialPortInfo& port) override;
|
|
void OnPortRemoved(const device::mojom::SerialPortInfo& port) override;
|
|
void OnPortManagerConnectionError() override;
|
|
void OnPermissionRevoked(const url::Origin& origin) override {}
|
|
void OnSerialChooserContextShutdown() override;
|
|
|
|
private:
|
|
SerialChooserController* ControllerForFrame(
|
|
content::RenderFrameHost* render_frame_host);
|
|
SerialChooserController* AddControllerForFrame(
|
|
content::RenderFrameHost* render_frame_host,
|
|
std::vector<blink::mojom::SerialPortFilterPtr> filters,
|
|
content::SerialChooser::Callback callback);
|
|
|
|
base::ScopedObservation<SerialChooserContext,
|
|
SerialChooserContext::PortObserver>
|
|
port_observation_{this};
|
|
base::ObserverList<content::SerialDelegate::Observer> observer_list_;
|
|
|
|
std::unordered_map<content::RenderFrameHost*,
|
|
std::unique_ptr<SerialChooserController>>
|
|
controller_map_;
|
|
|
|
base::WeakPtrFactory<ElectronSerialDelegate> weak_factory_{this};
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
namespace base {
|
|
|
|
template <>
|
|
struct ScopedObservationTraits<electron::SerialChooserContext,
|
|
electron::SerialChooserContext::PortObserver> {
|
|
static void AddObserver(
|
|
electron::SerialChooserContext* source,
|
|
electron::SerialChooserContext::PortObserver* observer) {
|
|
source->AddPortObserver(observer);
|
|
}
|
|
static void RemoveObserver(
|
|
electron::SerialChooserContext* source,
|
|
electron::SerialChooserContext::PortObserver* observer) {
|
|
source->RemovePortObserver(observer);
|
|
}
|
|
};
|
|
|
|
} // namespace base
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_SERIAL_ELECTRON_SERIAL_DELEGATE_H_
|