electron/shell/browser/api
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
..
views chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
electron_api_app.cc feat: add isMainFrame argument to 'certificate-error' event (#30879) 2021-09-21 15:49:15 +09:00
electron_api_app.h refactor: Convert ProcessSingleton changes to patch (#30594) 2021-09-03 14:16:33 -07:00
electron_api_app_mac.mm chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
electron_api_app_mas.mm fix: Resolve bookmarks without mounting network drives (#24708) 2020-08-20 15:01:08 -07:00
electron_api_auto_updater.cc refactor: ginify autoUpdater (#24678) 2020-07-28 11:04:34 -07:00
electron_api_auto_updater.h chore: use consistent parameter names (#29361) 2021-06-01 10:46:25 +09:00
electron_api_base_window.cc fix: child window alwaysOnTop level persistence (#29813) 2021-06-23 15:09:09 +09:00
electron_api_base_window.h fix: child window alwaysOnTop level persistence (#29813) 2021-06-23 15:09:09 +09:00
electron_api_browser_view.cc Merge branch 'master' into roller/chromium/master 2021-03-15 18:43:25 -04:00
electron_api_browser_view.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_browser_window.cc fix: transparency on child windows being lost (#31003) 2021-09-21 09:20:54 +09:00
electron_api_browser_window.h feat: enable window controls overlay on macOS (#29253) 2021-07-01 15:25:40 -04:00
electron_api_browser_window_mac.mm fix: draggable regions with devtools open (#29696) 2021-06-16 09:58:30 -07:00
electron_api_browser_window_views.cc fix: ensure web_contents() is alive before grabbing view (#30571) 2021-08-17 14:00:49 -07:00
electron_api_content_tracing.cc refactor: migrate AdaptCallbackForRepeating to SplitOnceCallback (#29825) 2021-06-21 18:04:31 -07:00
electron_api_cookies.cc chore: bump chromium to 95.0.4612.5 (main) (#30503) 2021-08-23 20:52:17 -04:00
electron_api_cookies.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_crash_reporter.cc feat: support crashpad on linux (#29719) 2021-07-19 10:11:10 -07:00
electron_api_crash_reporter.h fix: send guid with linux crashes (#24881) 2020-08-07 15:30:49 -07:00
electron_api_data_pipe_holder.cc chore: bump chromium to 90.0.4415.0 (master) (#27694) 2021-03-04 09:27:05 -08:00
electron_api_data_pipe_holder.h chore: rename atom -> electron (#21986) 2020-02-04 12:19:40 -08:00
electron_api_debugger.cc chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
electron_api_debugger.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_api_desktop_capturer.cc refactor: simplify desktop_capturer patch (#30685) 2021-09-03 16:37:36 -07:00
electron_api_desktop_capturer.h refactor: simplify desktop_capturer patch (#30685) 2021-09-03 16:37:36 -07:00
electron_api_dialog.cc feat: add signal option to dialog.showMessageBox (#26102) 2021-07-15 07:59:27 +09:00
electron_api_download_item.cc chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_download_item.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_event.cc chore: rename node bindings atom => electron (#22176) 2020-02-14 06:25:39 -05:00
electron_api_event_emitter.cc chore: stop leaking v8 environment (#22761) 2020-03-20 14:15:55 -07:00
electron_api_event_emitter.h refactor: EventEmitters without gin_helper (#22726) 2020-03-18 12:57:08 -07:00
electron_api_global_shortcut.cc chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
electron_api_global_shortcut.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_api_in_app_purchase.cc chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
electron_api_in_app_purchase.h refactor: ginify InAppPurchase (#24674) 2020-07-23 14:55:41 -07:00
electron_api_menu.cc feat: add MenuItem.userAccelerator property (#26682) 2021-06-29 16:28:16 -07:00
electron_api_menu.h feat: add MenuItem.userAccelerator property (#26682) 2021-06-29 16:28:16 -07:00
electron_api_menu_mac.h fix: check DCHECK_IS_ON() instead of #ifdef DCHECK_IS_ON (#29620) 2021-06-14 11:06:09 +09:00
electron_api_menu_mac.mm feat: add MenuItem.userAccelerator property (#26682) 2021-06-29 16:28:16 -07:00
electron_api_menu_views.cc refactor: use C++11 class member variable initialization (#27477) 2021-01-26 12:16:21 -06:00
electron_api_menu_views.h refactor: use C++11 class member variable initialization (#27477) 2021-01-26 12:16:21 -06:00
electron_api_native_theme.cc chore: bump chromium to a264339194bfa02f5ecb3b8cba449 (master) (#27111) 2021-01-12 15:31:23 -08:00
electron_api_native_theme.h chore: bump chromium to 0e4ca9c0a63d7a39bd910997ad4c6 (master) (#24687) 2020-08-12 11:33:58 -07:00
electron_api_native_theme_mac.mm chore: rename atom -> electron (#21986) 2020-02-04 12:19:40 -08:00
electron_api_net.cc feat: add net.online / net.isOnline() (#21004) 2020-10-20 19:55:06 -07:00
electron_api_net_log.cc chore: tune-up electron::api::NetLog (#29534) 2021-06-20 18:52:28 -07:00
electron_api_net_log.h chore: tune-up electron::api::NetLog (#29534) 2021-06-20 18:52:28 -07:00
electron_api_notification.cc 2757472: Reland "Reland "[LSC] Remove base::string16 alias"" 2021-03-16 12:18:45 -04:00
electron_api_notification.h chore: use consistent parameter names (#29361) 2021-06-01 10:46:25 +09:00
electron_api_power_monitor.cc chore: bump chromium to 92.0.4475.0 (master) (#28462) 2021-04-15 10:44:35 -07:00
electron_api_power_monitor.h chore: bump chromium to 92.0.4475.0 (master) (#28462) 2021-04-15 10:44:35 -07:00
electron_api_power_monitor_mac.mm feat: add macOS fast user switching evt (#25321) 2020-09-22 10:12:39 -07:00
electron_api_power_monitor_win.cc fix: delay emitting powerMonitor events on windows (#25836) 2020-10-27 10:25:23 +09:00
electron_api_power_save_blocker.cc refactor: use C++11 class member variable initialization (#27477) 2021-01-26 12:16:21 -06:00
electron_api_power_save_blocker.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_api_printing.cc build: fix build with enable_printing=false (#26597) 2020-11-19 10:05:49 -05:00
electron_api_protocol.cc chore: cleanup usages of const char* (#29906) 2021-07-02 09:51:52 +09:00
electron_api_protocol.h fix: add service worker schemes from command line in renderer (#29425) 2021-06-01 10:45:23 +09:00
electron_api_safe_storage.cc feat: add electron.safeStorage encryption API (#30020) 2021-08-05 15:12:54 -07:00
electron_api_safe_storage.h feat: add electron.safeStorage encryption API (#30020) 2021-08-05 15:12:54 -07:00
electron_api_screen.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_api_screen.h refactor: ginify Screen (#24677) 2020-07-28 11:04:01 -07:00
electron_api_service_worker_context.cc chore: bump chromium to 92.0.4496.0 (master) (#28907) 2021-05-03 20:13:46 -07:00
electron_api_service_worker_context.h chore: bump chromium to 92.0.4496.0 (master) (#28907) 2021-05-03 20:13:46 -07:00
electron_api_session.cc feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_api_session.h feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_api_system_preferences.cc chore: bump chromium to a264339194bfa02f5ecb3b8cba449 (master) (#27111) 2021-01-12 15:31:23 -08:00
electron_api_system_preferences.h refactor: use C++11 class member variable initialization (#27477) 2021-01-26 12:16:21 -06:00
electron_api_system_preferences_mac.mm fix: return RGBA values from getSystemColor (#30055) 2021-07-12 11:08:10 -07:00
electron_api_system_preferences_win.cc chore: use std::make_unique/base::MakeRefCounted when possible (#29510) 2021-06-08 11:00:05 +09:00
electron_api_tray.cc chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
electron_api_tray.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_url_loader.cc chore: follow-up to roll 95.0.4612.5 (#30835) 2021-09-06 09:33:10 +02:00
electron_api_url_loader.h chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
electron_api_view.cc chore: remove unused classes of views API (#22861) 2020-03-28 15:44:57 +09:00
electron_api_view.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
electron_api_web_contents.cc feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_api_web_contents.h feat: add support for WebHID (#30213) 2021-09-23 20:00:11 +09:00
electron_api_web_contents_impl.cc chore: bump chromium to ec5bc1743792d64724693eb357083 (master) (#24984) 2020-09-21 01:00:36 -07:00
electron_api_web_contents_mac.mm refactor: remove base::Value from WebContentsPreferences (#30193) 2021-07-26 09:04:09 -07:00
electron_api_web_contents_view.cc Merge branch 'master' into roller/chromium/master 2021-03-15 18:43:25 -04:00
electron_api_web_contents_view.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
electron_api_web_frame_main.cc feat: add 'dom-ready' event to WebFrameMain (#29290) 2021-09-01 15:21:15 -07:00
electron_api_web_frame_main.h feat: add 'dom-ready' event to WebFrameMain (#29290) 2021-09-01 15:21:15 -07:00
electron_api_web_request.cc refactor: use getter for frame in webrequest details (#30830) 2021-09-07 09:13:16 +09:00
electron_api_web_request.h refactor: convert more C++ enums to C++11 enum classes (#26850) 2020-12-08 13:39:33 +09:00
electron_api_web_view_manager.cc refactor: only create webContents after 'will-attach-webview' (#30311) 2021-08-03 10:08:49 -07:00
event.cc chore: use =default for default constructors/destructors (#29511) 2021-06-04 13:16:13 +09:00
event.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
frame_subscriber.cc chore: bump chromium to 93.0.4550.0 (main) (#29751) 2021-06-22 12:17:16 -07:00
frame_subscriber.h chore: clean up forward declarations (#29904) 2021-07-02 09:51:37 +09:00
gpu_info_enumerator.cc chore: bump chromium to 6d130075d378a64187360ba4e7820 (master) (#24256) 2020-07-13 21:13:34 -04:00
gpu_info_enumerator.h chore: cleanup usages of const char* (#29906) 2021-07-02 09:51:52 +09:00
gpuinfo_manager.cc refactor: remove dead code in NeedsCompleteGpuInfoCollection (#30855) 2021-09-08 08:42:03 +09:00
gpuinfo_manager.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
message_port.cc chore: prefer empty() check for readability (#29360) 2021-05-27 13:08:30 -07:00
message_port.h chore: use consistent parameter names (#26162) 2020-10-27 10:18:36 -05:00
process_metric.cc chore: bump chromium to 93.0.4530.0 (master) (#29256) 2021-06-03 01:05:04 -07:00
process_metric.h refactor: Chromium code style for enum classes (#26165) 2020-10-27 10:51:45 -07:00
save_page_handler.cc chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
save_page_handler.h chore: trim unused STL includes (#29414) 2021-06-01 10:34:44 +09:00
ui_event.cc refactor: remove uses of v8::Isolate::GetCurrent (#24179) 2020-06-22 09:35:24 -07:00
ui_event.h refactor: ginify Tray (#22822) 2020-03-30 10:32:02 +09:00