electron/shell/browser
John Kleinschmidt 6aece4a83d
feat: add support for WebHID (#30213)
* feat: add support for WebHID

* Apply suggestions from code review

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

* Address review feedback

* Address review feedback

* chore: clear granted_devices on navigation

Also added test to verify devices get cleared

* fixup testing for device clear

* make sure navigator.hid.getDevices is run on correct frame

* clear granted devices on RenderFrameHost deletion/change

* manage device permissions per RenderFrameHost

This change makes sure we don't clear device permission prematurely due to child frame navigation

* Update shell/browser/api/electron_api_web_contents.cc

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

* apply review feedback from @zcbenz

* Match upstream ObjectMap

This change matches what ObjectPermissionContextBase uses to cache object permissions: https://source.chromium.org/chromium/chromium/src/+/main:components/permissions/object_permission_context_base.h;l=52;drc=8f95b5eab2797a3e26bba299f3b0df85bfc98bf5;bpv=1;bpt=0

The main reason for this was to resolve this crash on Win x64:
ok 2 WebContentsView doesn't crash when GCed during allocation
Received fatal exception EXCEPTION_ACCESS_VIOLATION
Backtrace:
        gin::WrappableBase::SecondWeakCallback [0x00007FF6F2AFA005+133] (o:\gin\wrappable.cc:53)
        v8::internal::GlobalHandles::InvokeSecondPassPhantomCallbacks [0x00007FF6F028F9AB+171] (o:\v8\src\handles\global-handles.cc:1400)
        v8::internal::GlobalHandles::InvokeSecondPassPhantomCallbacksFromTask [0x00007FF6F028F867+391] (o:\v8\src\handles\global-handles.cc:1387)
        node::PerIsolatePlatformData::RunForegroundTask [0x00007FF6F3B4D065+317] (o:\third_party\electron_node\src\node_platform.cc:415)
        node::PerIsolatePlatformData::FlushForegroundTasksInternal [0x00007FF6F3B4C424+776] (o:\third_party\electron_node\src\node_platform.cc:479)
        uv_run [0x00007FF6F2DDD07C+492] (o:\third_party\electron_node\deps\uv\src\win\core.c:609)
        electron::NodeBindings::UvRunOnce [0x00007FF6EEE1E036+294] (o:\electron\shell\common\node_bindings.cc:631)
        base::TaskAnnotator::RunTask [0x00007FF6F2318A19+457] (o:\base\task\common\task_annotator.cc:178)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl [0x00007FF6F2E6F553+963] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:361)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork [0x00007FF6F2E6EC69+137] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:266)
        base::MessagePumpForUI::DoRunLoop [0x00007FF6F235AA58+216] (o:\base\message_loop\message_pump_win.cc:221)
        base::MessagePumpWin::Run [0x00007FF6F235A01A+106] (o:\base\message_loop\message_pump_win.cc:79)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run [0x00007FF6F2E702DA+682] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:470)
        base::RunLoop::Run [0x00007FF6F22F95BA+842] (o:\base\run_loop.cc:136)
        content::BrowserMainLoop::RunMainMessageLoop [0x00007FF6F14423CC+208] (o:\content\browser\browser_main_loop.cc:990)
        content::BrowserMainRunnerImpl::Run [0x00007FF6F144402F+143] (o:\content\browser\browser_main_runner_impl.cc:153)
        content::BrowserMain [0x00007FF6F143F911+257] (o:\content\browser\browser_main.cc:49)
        content::RunBrowserProcessMain [0x00007FF6EFFA7D18+112] (o:\content\app\content_main_runner_impl.cc:608)
        content::ContentMainRunnerImpl::RunBrowser [0x00007FF6EFFA8CF4+1220] (o:\content\app\content_main_runner_impl.cc:1104)
        content::ContentMainRunnerImpl::Run [0x00007FF6EFFA87C9+393] (o:\content\app\content_main_runner_impl.cc:971)
        content::RunContentProcess [0x00007FF6EFFA73BD+733] (o:\content\app\content_main.cc:394)
        content::ContentMain [0x00007FF6EFFA79E1+54] (o:\content\app\content_main.cc:422)
        wWinMain [0x00007FF6EECA1535+889] (o:\electron\shell\app\electron_main.cc:291)
        __scrt_common_main_seh [0x00007FF6F6F88482+262] (d:\A01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
        BaseThreadInitThunk [0x00007FFEC0087034+20]
        RtlUserThreadStart [0x00007FFEC1F02651+33]
✗ Electron tests failed with code 0xc0000005.

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-09-23 20:00:11 +09:00
..
api feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
badging chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
bluetooth chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
extensions fix: remove extension warning that do not have any impact (#29695) 2021-09-01 15:36:21 -07:00
font fix: prevent navigator.fonts.query() from crashing (#30930) 2021-09-15 09:56:38 -04:00
hid feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
lib fix: select-bluetooth-device on Windows (#29591) 2021-06-09 10:48:18 -04:00
linux refactor: use auto env = base::Environment::Create(); everywhere (#29502) 2021-06-04 09:23:06 +09:00
mac feat: continue-activity event is extended to support webpageURL property (#30042) 2021-07-13 13:21:33 -07:00
media refactor: use C++11 class member variable initialization (#27477) 2021-01-26 12:16:21 -06:00
net chore: fix compile errors (#30903) 2021-09-09 19:52:23 -07:00
notifications chore: remove unneeded conversions between wstring and u16string (#30047) 2021-07-12 13:33:26 +09:00
osr chore: bump chromium to 95.0.4629.0 (main) (#30676) 2021-09-01 15:55:07 -04:00
plugins chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
printing chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
resources Bump v16.0.0-nightly.20210922 2021-09-22 06:01:20 -07:00
serial chore: remove experimental from navigator.serial implementation (#30237) 2021-07-30 08:57:22 +09:00
ui feat: add width option to dialog.showMessageBox() (#30474) 2021-09-23 19:56:14 +09:00
win chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
auto_updater.cc chore: bump chromium to 0e4ca9c0a63d7a39bd910997ad4c6 (master) (#24687) 2020-08-12 11:33:58 -07:00
auto_updater.h chore: use consistent parameter names (#29361) 2021-06-01 10:46:25 +09:00
auto_updater_mac.mm refactor: ginify autoUpdater (#24678) 2020-07-28 11:04:34 -07:00
browser.cc fix: use correct userData path when unbundled (#30113) 2021-07-14 13:10:37 -07:00
browser.h feat: continue-activity event is extended to support webpageURL property (#30042) 2021-07-13 13:21:33 -07:00
browser_linux.cc refactor: use auto env = base::Environment::Create(); everywhere (#29502) 2021-06-04 09:23:06 +09:00
browser_mac.mm chore: bump chromium to 94.0.4584.0 (main) (#30030) 2021-07-26 09:02:16 -07:00
browser_observer.h feat: continue-activity event is extended to support webpageURL property (#30042) 2021-07-13 13:21:33 -07:00
browser_process_impl.cc chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
browser_process_impl.h chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
browser_win.cc chore: bump chromium to 94.0.4584.0 (main) (#30030) 2021-07-26 09:02:16 -07:00
child_web_contents_tracker.cc chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
child_web_contents_tracker.h feat: enhance native window.open to match the custom implementation's behavior (#19703) 2020-03-26 11:05:45 -07:00
cookie_change_notifier.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
cookie_change_notifier.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_autofill_driver.cc Revert "chore: bump chromium to 91.0.4448.0 (master) (#28009)" 2021-03-30 21:28:40 -05:00
electron_autofill_driver.h Revert "chore: bump chromium to 91.0.4448.0 (master) (#28009)" 2021-03-30 21:28:40 -05:00
electron_autofill_driver_factory.cc Bump v12.0.0-nightly.20200827 2020-08-27 07:31:51 -07:00
electron_autofill_driver_factory.h Bump v12.0.0-nightly.20200827 2020-08-27 07:31:51 -07:00
electron_browser_client.cc feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_browser_client.h feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_browser_context.cc fix: persist permission granted to serial ports (#30209) 2021-07-26 13:10:57 -04:00
electron_browser_context.h chore: bump chromium to 94.0.4590.2 (main) (#30274) 2021-08-11 17:04:56 -04:00
electron_browser_handler_impl.cc chore: remove unused and broken ipcRendererInternal.sendTo() (#29743) 2021-06-17 23:26:18 -05:00
electron_browser_handler_impl.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_browser_main_parts.cc feat: add electron.safeStorage encryption API (#30020) 2021-08-05 15:12:54 -07:00
electron_browser_main_parts.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_browser_main_parts_mac.mm fix: geolocation crashes electron on macOS (#29343) (#29913) 2021-06-28 20:26:57 -07:00
electron_browser_main_parts_posix.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_download_manager_delegate.cc refactor: remove base::Value from WebContentsPreferences (#30193) 2021-07-26 09:04:09 -07:00
electron_download_manager_delegate.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_gpu_client.cc chore: rename atom -> electron (#21986) 2020-02-04 12:19:40 -08:00
electron_gpu_client.h chore: rename atom -> electron (#21986) 2020-02-04 12:19:40 -08:00
electron_javascript_dialog_manager.cc refactor: remove base::Value from WebContentsPreferences (#30193) 2021-07-26 09:04:09 -07:00
electron_javascript_dialog_manager.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_navigation_throttle.cc refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25065) 2020-08-21 12:34:09 -07:00
electron_navigation_throttle.h refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25065) 2020-08-21 12:34:09 -07:00
electron_pdf_web_contents_helper_client.cc chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
electron_pdf_web_contents_helper_client.h refactor: remove references to non-existent webui (#20867) 2019-11-04 09:50:31 -08:00
electron_permission_manager.cc feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_permission_manager.h feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_quota_permission_context.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_quota_permission_context.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_speech_recognition_manager_delegate.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_speech_recognition_manager_delegate.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_web_ui_controller_factory.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_web_ui_controller_factory.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
event_emitter_mixin.cc refactor: EventEmitters without gin_helper (#22726) 2020-03-18 12:57:08 -07:00
event_emitter_mixin.h feat: add webContents.setWindowOpenHandler API (#24517) 2020-11-10 09:06:03 -08:00
extended_web_contents_observer.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
fake_location_provider.cc refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
fake_location_provider.h refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
feature_list.cc chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
feature_list.h feat: initialize field trials from command line arguments (#28305) 2021-03-26 09:49:00 +09:00
file_select_helper.cc refactor: reuse upstream //shell_dialogs (#30663) 2021-09-14 12:16:34 +02:00
file_select_helper.h refactor: reuse upstream //shell_dialogs (#30663) 2021-09-14 12:16:34 +02:00
file_select_helper_mac.mm fix: transparently package bundles as zip archives (#25030) 2020-10-27 17:05:28 -07:00
font_defaults.cc Revert "chore: bump chromium to 91.0.4448.0 (master) (#28009)" 2021-03-30 21:28:40 -05:00
font_defaults.h chore: bump chromium to ec5bc1743792d64724693eb357083 (master) (#24984) 2020-09-21 01:00:36 -07:00
javascript_environment.cc chore: bump chromium to 95.0.4629.0 (main) (#30676) 2021-09-01 15:55:07 -04:00
javascript_environment.h chore: bump chromium to 95.0.4629.0 (main) (#30676) 2021-09-01 15:55:07 -04:00
login_handler.cc fix: crash when invoking login callback synchronously (#30068) 2021-07-12 12:33:41 -07:00
login_handler.h fix: implement 'login' event for net.ClientRequest (#21096) 2019-11-14 10:01:18 -08:00
microtasks_runner.cc refactor: use public node::CallbackScope where possible (#27001) 2020-12-15 11:39:25 -08:00
microtasks_runner.h chore: bump chromium to f755b70e34659441e72c1a928a406 (master) (#21000) 2019-12-10 16:22:35 -08:00
native_browser_view.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
native_browser_view.h fix: draggable regions calculation in BrowserWindow/BrowserView (#26690) 2020-11-30 21:02:04 -08:00
native_browser_view_mac.h fix: draggable regions calculation in BrowserWindow/BrowserView (#26690) 2020-11-30 21:02:04 -08:00
native_browser_view_mac.mm chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
native_browser_view_views.cc fix: BrowserViews not painting their WebContents (#29919) 2021-07-30 08:59:24 +09:00
native_browser_view_views.h fix: BrowserViews not painting their WebContents (#29919) 2021-07-30 08:59:24 +09:00
native_window.cc feat: enable windows control overlay on Windows (#29600) 2021-08-11 14:07:36 -04:00
native_window.h feat: enable windows control overlay on Windows (#29600) 2021-08-11 14:07:36 -04:00
native_window_mac.h fix: maximized state calculation for non-resizable windows (#30989) 2021-09-21 12:04:32 +02:00
native_window_mac.mm fix: maximized state calculation for non-resizable windows (#30989) 2021-09-21 12:04:32 +02:00
native_window_observer.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
native_window_views.cc fix: update Windows' cache after changing window's style (#31021) 2021-09-23 16:33:41 +09:00
native_window_views.h feat: enable windows control overlay on Windows (#29600) 2021-08-11 14:07:36 -04:00
native_window_views_win.cc feat: include resize edge with will-resize event (#29199) 2021-06-02 11:37:10 +09:00
network_hints_handler_impl.cc refactor: ginify Session (#23569) 2020-05-19 10:18:12 -07:00
network_hints_handler_impl.h fix: hold browser_context instead of render_frame_host to fix lifetime issues (#23271) 2020-05-01 16:37:01 +09:00
pref_store_delegate.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
pref_store_delegate.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
protocol_registry.cc chore: bump chromium to 94.0.4584.0 (main) (#30030) 2021-07-26 09:02:16 -07:00
protocol_registry.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
relauncher.cc chore: bump chromium to 94.0.4584.0 (main) (#30030) 2021-07-26 09:02:16 -07:00
relauncher.h chore: use consistent parameter names (#29361) 2021-06-01 10:46:25 +09:00
relauncher_linux.cc refactor: apply some 'clang-tidy -fix' changes (#20172) 2019-09-13 10:26:59 -04:00
relauncher_mac.cc
relauncher_win.cc chore: bump chromium to 94.0.4584.0 (main) (#30030) 2021-07-26 09:02:16 -07:00
session_preferences.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
session_preferences.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
special_storage_policy.cc chore: bump chromium to 6d130075d378a64187360ba4e7820 (master) (#24256) 2020-07-13 21:13:34 -04:00
special_storage_policy.h chore: bump chromium to 6d130075d378a64187360ba4e7820 (master) (#24256) 2020-07-13 21:13:34 -04:00
unresponsive_suppressor.cc refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
unresponsive_suppressor.h refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
web_contents_permission_helper.cc feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
web_contents_permission_helper.h feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
web_contents_preferences.cc fix: BrowserWindow backgroundColor (#30778) 2021-09-06 16:59:09 +09:00
web_contents_preferences.h fix: BrowserWindow backgroundColor (#30778) 2021-09-06 16:59:09 +09:00
web_contents_zoom_controller.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
web_contents_zoom_controller.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
web_view_guest_delegate.cc fix: crash when clicking links with target=_blank from webview (#29874) 2021-06-29 18:10:18 -07:00
web_view_guest_delegate.h chore: bump chromium to 6b9fa6b352d824d052222e1abe541 (master) (#25558) 2020-10-15 18:30:41 -07:00
web_view_manager.cc refactor: remove guestInstanceId from WebPreferences (#30280) 2021-07-28 15:32:53 -07:00
web_view_manager.h refactor: remove guestInstanceId from WebPreferences (#30280) 2021-07-28 15:32:53 -07:00
window_list.cc chore: bump chromium to 0e4ca9c0a63d7a39bd910997ad4c6 (master) (#24687) 2020-08-12 11:33:58 -07:00
window_list.h refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
window_list_observer.h refactor: rename the atom namespace to electron 2019-06-19 17:33:28 -07:00
zoom_level_delegate.cc chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
zoom_level_delegate.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00