Files
brave-core/browser/brave_drm_tab_helper.h
T
Claudio DeSouza 4aed2591b5 [update_client] Observers events simplified
This change does unifies the id/status pair data sent during `OnEvent`
under a single structure, which affects quite a few places where this
event is used.

Another place affected by these changes involves instantiating
`UpdateContext`, which doesn't require to pass along a
`notify_observers_callback` argument.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/2c20c79dfeff629b1867c5e0a8837149e8a5f668

commit 2c20c79dfeff629b1867c5e0a8837149e8a5f668
Author: Joshua Pawlicki <waffles@chromium.org>
Date:   Fri Sep 27 13:28:14 2024 +0000

    update_client: Simplify observer mechanisms.

    Prior to this CL, there were multiple observer mechanisms that used
    different types, but all of which mapped to the same underlying
    concepts. After this CL, there are still multiple mechanisms (depending
    on whether the observer wants their observations scoped to a single
    updater operation or whether they want to observe the updater as a
    whole), but the types are now consistent, and observers get a constref
    snapshot of the observed item.

    Bug: 353249967
2024-10-24 12:14:29 +01:00

62 lines
2.3 KiB
C++

/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_BROWSER_BRAVE_DRM_TAB_HELPER_H_
#define BRAVE_BROWSER_BRAVE_DRM_TAB_HELPER_H_
#include "base/scoped_observation.h"
#include "brave/components/brave_drm/brave_drm.mojom.h"
#include "components/component_updater/component_updater_service.h"
#include "content/public/browser/render_frame_host_receiver_set.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
// Reacts to DRM content detected on the renderer side.
class BraveDrmTabHelper final
: public content::WebContentsObserver,
public content::WebContentsUserData<BraveDrmTabHelper>,
public brave_drm::mojom::BraveDRM,
public component_updater::ComponentUpdateService::Observer {
public:
explicit BraveDrmTabHelper(content::WebContents* contents);
~BraveDrmTabHelper() override;
static void BindBraveDRM(
mojo::PendingAssociatedReceiver<brave_drm::mojom::BraveDRM> receiver,
content::RenderFrameHost* rfh);
bool ShouldShowWidevineOptIn() const;
// content::WebContentsObserver
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
// blink::mojom::BraveDRM
void OnWidevineKeySystemAccessRequest() override;
// component_updater::ComponentUpdateService::Observer
void OnEvent(const update_client::CrxUpdateItem& item) override;
WEB_CONTENTS_USER_DATA_KEY_DECL();
private:
content::RenderFrameHostReceiverSet<brave_drm::mojom::BraveDRM>
brave_drm_receivers_;
// Permission request is done only once during the navigation. If user
// chooses dismiss/deny, additional request is added again only when new
// main frame navigation is started.
bool is_permission_requested_ = false;
// True if we are notified that a page requested widevine availability.
bool is_widevine_requested_ = false;
base::ScopedObservation<component_updater::ComponentUpdateService,
component_updater::ComponentUpdateService::Observer>
observer_{this};
};
#endif // BRAVE_BROWSER_BRAVE_DRM_TAB_HELPER_H_