![electron-roller[bot]](/assets/img/avatar_default.png)
* chore: bump chromium in DEPS to 133.0.6902.0 * chore: bump chromium in DEPS to 133.0.6903.0 * chore: update patches * Update PdfViewer Save File Picker to use showSaveFilePicker. Refs https://chromium-review.googlesource.com/c/chromium/src/+/6074308 * Code Health: Clean up stale MacWebContentsOcclusion Refs https://chromium-review.googlesource.com/c/chromium/src/+/6078344 * Change RenderProcessHost::GetID to RenderProcessHost::GetDeprecatedID Refs https://chromium-review.googlesource.com/c/chromium/src/+/6065543 * [WebRTC] Make WebRTC IP Handling policy a mojo enum Refs https://chromium-review.googlesource.com/c/chromium/src/+/6063620 * chore: gen filenames.libcxx.gni * Remove allow_unsafe_buffers pragma in //printing Refs https://chromium-review.googlesource.com/c/chromium/src/+/6092280 * refactor: to use ChildProcessId where possible Refs https://issues.chromium.org/issues/379869738 * [Win] Update TabletMode detection code Refs https://chromium-review.googlesource.com/c/chromium/src/+/6003486 * chore: bump chromium in DEPS to 133.0.6905.0 * chore: update patches * Reland "Move global shortcut listener to //ui/base" Refs https://chromium-review.googlesource.com/c/chromium/src/+/6099035 * [shared storage] Implement the batch `with_lock` option for response header Refs https://chromium-review.googlesource.com/c/chromium/src/+/6072742 * chore: bump chromium in DEPS to 133.0.6907.0 * chore: bump chromium in DEPS to 133.0.6909.0 * chore: bump chromium in DEPS to 133.0.6911.0 * chore: bump chromium in DEPS to 133.0.6912.0 * chore: update patches * WebUI: Reveal hidden deps to ui/webui/resources. Refs https://chromium-review.googlesource.com/c/chromium/src/+/6096291 * chore: bump chromium in DEPS to 133.0.6913.0 * chore: bump chromium in DEPS to 133.0.6915.0 * Code Health: Clean up stale base::Feature "AccessibilityTreeForViews" Refs https://chromium-review.googlesource.com/c/chromium/src/+/6104174 Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * fix: remove fastapitypedarray usage * chore: update patches * chore: script/gen-libc++-filenames.js * Code Health: Clean up stale base::Feature "WinRetrieveSuggestionsOnlyOnDemand" Refs https://chromium-review.googlesource.com/c/chromium/src/+/6109477 * fix: empty suggestions with windows platform checker Amends the fix from https://github.com/electron/electron/pull/29690 since the feature flag is no longer available. We follow the same pattern as //chrome/browser/renderer_context_menu/spelling_menu_observer.cc to generate the suggestion list on demand when context menu action is invoked. Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * fixup! fix: empty suggestions with windows platform checker * fixup! fix: empty suggestions with windows platform checker * revert: 6078344: Code Health: Clean up stale MacWebContentsOcclusion | https://chromium-review.googlesource.com/c/chromium/src/+/6078344 * Revert "revert: 6078344: Code Health: Clean up stale MacWebContentsOcclusion | https://chromium-review.googlesource.com/c/chromium/src/+/6078344" This reverts commit 9cacda452ed5a072351e8f5a35b009d91843a08c. * chore: bump to 133.0.6920.0, update patches * Revert "6078344: Code Health: Clean up stale MacWebContentsOcclusion" Refs: https://chromium-review.googlesource.com/c/chromium/src/+/6078344 * fixup! Update PdfViewer Save File Picker to use showSaveFilePicker. --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
110 lines
3.8 KiB
C++
110 lines
3.8 KiB
C++
// Copyright 2018 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_BADGING_BADGE_MANAGER_H_
|
|
#define ELECTRON_SHELL_BROWSER_BADGING_BADGE_MANAGER_H_
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "components/keyed_service/core/keyed_service.h"
|
|
#include "content/public/browser/child_process_id.h"
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
|
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
|
|
#include "url/gurl.h"
|
|
|
|
namespace content {
|
|
class RenderFrameHost;
|
|
class RenderProcessHost;
|
|
} // namespace content
|
|
|
|
namespace badging {
|
|
|
|
// The maximum value of badge contents before saturation occurs.
|
|
constexpr int kMaxBadgeContent = 99;
|
|
|
|
// Maintains a record of badge contents and dispatches badge changes to a
|
|
// delegate.
|
|
class BadgeManager : public KeyedService, public blink::mojom::BadgeService {
|
|
public:
|
|
BadgeManager();
|
|
~BadgeManager() override;
|
|
|
|
// disable copy
|
|
BadgeManager(const BadgeManager&) = delete;
|
|
BadgeManager& operator=(const BadgeManager&) = delete;
|
|
|
|
static void BindFrameReceiver(
|
|
content::RenderFrameHost* frame,
|
|
mojo::PendingReceiver<blink::mojom::BadgeService> receiver);
|
|
static void BindServiceWorkerReceiver(
|
|
content::RenderProcessHost* service_worker_process_host,
|
|
const GURL& service_worker_scope,
|
|
mojo::PendingReceiver<blink::mojom::BadgeService> receiver);
|
|
|
|
// Determines the text to put on the badge based on some badge_content.
|
|
static std::string GetBadgeString(std::optional<int> badge_content);
|
|
|
|
private:
|
|
// The BindingContext of a mojo request. Allows mojo calls to be tied back
|
|
// to the execution context they belong to without trusting the renderer for
|
|
// that information. This is an abstract base class that different types of
|
|
// execution contexts derive.
|
|
class BindingContext {
|
|
public:
|
|
virtual ~BindingContext() = default;
|
|
};
|
|
|
|
// The BindingContext for Window execution contexts.
|
|
class FrameBindingContext final : public BindingContext {
|
|
public:
|
|
FrameBindingContext(content::ChildProcessId process_id, int frame_id)
|
|
: process_id_(process_id), frame_id_(frame_id) {}
|
|
~FrameBindingContext() override = default;
|
|
|
|
content::ChildProcessId GetProcessId() { return process_id_; }
|
|
int GetFrameId() { return frame_id_; }
|
|
|
|
private:
|
|
content::ChildProcessId process_id_;
|
|
int frame_id_;
|
|
};
|
|
|
|
// The BindingContext for ServiceWorkerGlobalScope execution contexts.
|
|
class ServiceWorkerBindingContext final : public BindingContext {
|
|
public:
|
|
ServiceWorkerBindingContext(content::ChildProcessId process_id,
|
|
const GURL& scope)
|
|
: process_id_(process_id), scope_(scope) {}
|
|
~ServiceWorkerBindingContext() override = default;
|
|
|
|
content::ChildProcessId GetProcessId() { return process_id_; }
|
|
GURL GetScope() { return scope_; }
|
|
|
|
private:
|
|
content::ChildProcessId process_id_;
|
|
GURL scope_;
|
|
};
|
|
|
|
// blink::mojom::BadgeService:
|
|
// Note: These are private to stop them being called outside of mojo as they
|
|
// require a mojo binding context.
|
|
void SetBadge(blink::mojom::BadgeValuePtr value) override;
|
|
void ClearBadge() override;
|
|
|
|
// All the mojo receivers for the BadgeManager. Keeps track of the
|
|
// render_frame the binding is associated with, so as to not have to rely
|
|
// on the renderer passing it in.
|
|
mojo::ReceiverSet<blink::mojom::BadgeService, std::unique_ptr<BindingContext>>
|
|
receivers_;
|
|
|
|
// Delegate which handles actual setting and clearing of the badge.
|
|
// Note: This is currently only set on Windows and MacOS.
|
|
// std::unique_ptr<BadgeManagerDelegate> delegate_;
|
|
};
|
|
|
|
} // namespace badging
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_BADGING_BADGE_MANAGER_H_
|