[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / media_foundation_preferences.cc
1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/mojo/services/media_foundation_preferences.h"
6
7 #include <memory>
8
9 #include "base/functional/callback.h"
10 #include "base/logging.h"
11 #include "mojo/public/cpp/bindings/self_owned_receiver.h"
12
13 MediaFoundationPreferencesImpl::MediaFoundationPreferencesImpl(
14     const GURL& site,
15     IsHardwareSecureDecryptionAllowedCB cb)
16     : site_(site), is_hardware_secure_decryption_allowed_cb_(cb) {}
17 MediaFoundationPreferencesImpl::~MediaFoundationPreferencesImpl() = default;
18
19 // static
20 void MediaFoundationPreferencesImpl::Create(
21     const GURL& site,
22     IsHardwareSecureDecryptionAllowedCB cb,
23     mojo::PendingReceiver<media::mojom::MediaFoundationPreferences> receiver) {
24   DVLOG(2) << __func__;
25
26   mojo::MakeSelfOwnedReceiver(
27       std::make_unique<MediaFoundationPreferencesImpl>(site, cb),
28       std::move(receiver));
29 }
30
31 void MediaFoundationPreferencesImpl::IsHardwareSecureDecryptionAllowed(
32     IsHardwareSecureDecryptionAllowedCallback cb) {
33   DVLOG(2) << __func__;
34
35   if (!is_hardware_secure_decryption_allowed_cb_) {
36     std::move(cb).Run(true);
37     return;
38   }
39
40   std::move(cb).Run(is_hardware_secure_decryption_allowed_cb_.Run(site_));
41 }