04df5ce492
* chore: bump chromium in DEPS to 124.0.6315.0 * chore: update patches * 5279678: Stream AIDA responses https://chromium-review.googlesource.com/c/chromium/src/+/5279678 * 5276439: Remove non_network_url_loader_factory_remotes_ https://chromium-review.googlesource.com/c/chromium/src/+/5276439 * 5310165: Add DevTools API to show search results https://chromium-review.googlesource.com/c/chromium/src/+/5310165 * chore: bump chromium in DEPS to 124.0.6317.0 * chore: update patches * Remove Setup.Install.CumulativeDiskUsage2 and supporting code https://chromium-review.googlesource.com/c/chromium/src/+/5314269 * browser: Make cmd line non-const in process singleton callback https://chromium-review.googlesource.com/c/chromium/src/+/5311256 * chore: bump chromium in DEPS to 124.0.6319.0 * chore: bump chromium in DEPS to 124.0.6321.0 * chore: bump chromium in DEPS to 124.0.6323.0 * 5318335: Roll src/third_party/boringssl/src 23824fa0f..4fe29ebc7 https://chromium-review.googlesource.com/c/chromium/src/+/5318335 * 5318051: [CBE Watermarking] Hoist `watermark_view` to a member variable. https://chromium-review.googlesource.com/c/chromium/src/+/5318051 * chore: fixup patch indices * 4946553: Delegate HID permission to Chrome App in webview https://chromium-review.googlesource.com/c/chromium/src/+/4946553 * 5310001: DevTools UI binding for reporting client events to AIDA https://chromium-review.googlesource.com/c/chromium/src/+/5310001 * [libc++] Refactor the predicate taking variant of `__cxx_atomic_wait` * chore: fix browser_view patch harder * 5293937: Reland "[gUM] Use preferred device if more than one is eligible" https://chromium-review.googlesource.com/c/chromium/src/+/5293937 * fix: filter {video|audio} devices by eligible device id * 5267921: enable speak content under the pointer on PWA and WV2 https://chromium-review.googlesource.com/c/chromium/src/+/5267921 * 5310195: heap: Remove Blink's GCTaskRunner https://chromium-review.googlesource.com/c/chromium/src/+/5310195 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
100 lines
4 KiB
C++
100 lines
4 KiB
C++
// Copyright 2019 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_HID_ELECTRON_HID_DELEGATE_H_
|
|
#define ELECTRON_SHELL_BROWSER_HID_ELECTRON_HID_DELEGATE_H_
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "base/containers/flat_map.h"
|
|
#include "content/public/browser/hid_chooser.h"
|
|
#include "content/public/browser/hid_delegate.h"
|
|
#include "services/device/public/mojom/hid.mojom-forward.h"
|
|
#include "shell/browser/hid/hid_chooser_context.h"
|
|
#include "third_party/blink/public/mojom/hid/hid.mojom-forward.h"
|
|
#include "url/origin.h"
|
|
|
|
namespace content {
|
|
class BrowserContext;
|
|
class RenderFrameHost;
|
|
} // namespace content
|
|
|
|
namespace electron {
|
|
|
|
class HidChooserController;
|
|
|
|
class ElectronHidDelegate : public content::HidDelegate {
|
|
public:
|
|
ElectronHidDelegate();
|
|
ElectronHidDelegate(ElectronHidDelegate&) = delete;
|
|
ElectronHidDelegate& operator=(ElectronHidDelegate&) = delete;
|
|
~ElectronHidDelegate() override;
|
|
|
|
// content::HidDelegate:
|
|
std::unique_ptr<content::HidChooser> RunChooser(
|
|
content::RenderFrameHost* render_frame_host,
|
|
std::vector<blink::mojom::HidDeviceFilterPtr> filters,
|
|
std::vector<blink::mojom::HidDeviceFilterPtr> exclusion_filters,
|
|
content::HidChooser::Callback callback) override;
|
|
bool CanRequestDevicePermission(content::BrowserContext* browser_context,
|
|
const url::Origin& origin) override;
|
|
bool HasDevicePermission(content::BrowserContext* browser_context,
|
|
content::RenderFrameHost* render_frame_host,
|
|
const url::Origin& origin,
|
|
const device::mojom::HidDeviceInfo& device) override;
|
|
void RevokeDevicePermission(
|
|
content::BrowserContext* browser_context,
|
|
content::RenderFrameHost* render_frame_host,
|
|
const url::Origin& origin,
|
|
const device::mojom::HidDeviceInfo& device) override;
|
|
device::mojom::HidManager* GetHidManager(
|
|
content::BrowserContext* browser_context) override;
|
|
void AddObserver(content::BrowserContext* browser_context,
|
|
content::HidDelegate::Observer* observer) override;
|
|
void RemoveObserver(content::BrowserContext* browser_context,
|
|
content::HidDelegate::Observer* observer) override;
|
|
const device::mojom::HidDeviceInfo* GetDeviceInfo(
|
|
content::BrowserContext* browser_context,
|
|
const std::string& guid) override;
|
|
bool IsFidoAllowedForOrigin(content::BrowserContext* browser_context,
|
|
const url::Origin& origin) override;
|
|
bool IsServiceWorkerAllowedForOrigin(const url::Origin& origin) override;
|
|
void IncrementConnectionCount(content::BrowserContext* browser_context,
|
|
const url::Origin& origin) override {}
|
|
void DecrementConnectionCount(content::BrowserContext* browser_context,
|
|
const url::Origin& origin) override {}
|
|
|
|
void DeleteControllerForFrame(content::RenderFrameHost* render_frame_host);
|
|
|
|
private:
|
|
class ContextObservation;
|
|
|
|
ContextObservation* GetContextObserver(
|
|
content::BrowserContext* browser_context);
|
|
|
|
base::flat_map<content::BrowserContext*, std::unique_ptr<ContextObservation>>
|
|
observations_;
|
|
|
|
HidChooserController* ControllerForFrame(
|
|
content::RenderFrameHost* render_frame_host);
|
|
|
|
HidChooserController* AddControllerForFrame(
|
|
content::RenderFrameHost* render_frame_host,
|
|
std::vector<blink::mojom::HidDeviceFilterPtr> filters,
|
|
std::vector<blink::mojom::HidDeviceFilterPtr> exclusion_filters,
|
|
content::HidChooser::Callback callback);
|
|
|
|
std::unordered_map<content::RenderFrameHost*,
|
|
std::unique_ptr<HidChooserController>>
|
|
controller_map_;
|
|
|
|
base::WeakPtrFactory<ElectronHidDelegate> weak_factory_{this};
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_HID_ELECTRON_HID_DELEGATE_H_
|