From fbbff0f46ffa1600980267b2b26083ae21f4d940 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 2 Sep 2020 18:29:17 -0700 Subject: [PATCH 1/2] fix: bind fake mojo service for badging --- shell/browser/electron_browser_client.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 7c531fc56b890..9ee0aeaaf584b 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -96,6 +96,7 @@ #include "shell/common/options_switches.h" #include "shell/common/platform_util.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h" +#include "third_party/blink/public/mojom/badging/badging.mojom.h" #include "ui/base/resource/resource_bundle.h" #include "ui/native_theme/native_theme.h" #include "v8/include/v8.h" @@ -1583,6 +1584,12 @@ void ElectronBrowserClient::BindHostReceiverForRenderer( #endif } +void BindBadgeManagerFrameReceiver( + content::RenderFrameHost* frame, + mojo::PendingReceiver receiver) { + LOG(WARNING) << "The Chromium Badging API is not available in Electron"; +} + #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) void BindMimeHandlerService( content::RenderFrameHost* frame_host, @@ -1619,6 +1626,8 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame( mojo::BinderMapWithContext* map) { map->Add( base::BindRepeating(&BindNetworkHintsHandler)); + map->Add( + base::BindRepeating(&BindBadgeManagerFrameReceiver)); #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) map->Add( base::BindRepeating(&BindMimeHandlerService)); From 694d595d9e98c432f96b24f6882c0cd76a981383 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 2 Sep 2020 21:50:12 -0700 Subject: [PATCH 2/2] Add a test --- spec/chromium-spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index ac77ebc3ab489..545fb4ccaca3c 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -17,6 +17,14 @@ const features = process.electronBinding('features'); describe('chromium feature', () => { const fixtures = path.resolve(__dirname, 'fixtures'); + describe('Badging API', () => { + it('does not crash', () => { + expect(() => { + navigator.setAppBadge(42); + }).to.not.throw(); + }); + }); + describe('heap snapshot', () => { it('does not crash', function () { process.electronBinding('v8_util').takeHeapSnapshot();