Skip to content

Commit

Permalink
Use override technique for cdm_registry_impl.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Feb 1, 2019
1 parent f93c3aa commit 9a814a0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 40 deletions.
39 changes: 39 additions & 0 deletions chromium_src/content/browser/media/cdm_registry_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* 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/. */

#include "content/browser/media/cdm_registry_impl.h"

#if defined(OS_LINUX)
#include <algorithm>
#endif

#define Init Init_ChromiumImpl
#include "../../../../../content/browser/media/cdm_registry_impl.cc"
#undef Init

namespace content {
void CdmRegistryImpl::Init() {
Init_ChromiumImpl();

#if defined(OS_LINUX)
// On linux, we want to register widevine cdm to CdmRegistry when users opt
// in. Otherwise, widevine is initialized by default w/o user accept.
// So, widevine cdm is erased from |cdms_| and it is registered when users opt
// in. Also, we try to register it during the startup in
// BraveBrowserMainExtraParts::PreMainMessageLoopRun() by checking opted in
// prefs.
cdms_.erase(
std::remove_if(cdms_.begin(), cdms_.end(), [](const CdmInfo& info) {
// It would be better to use |kWidevineKeySystem| constant instead of
// using "com.widevine.alpha". To use constant, it requires adding
// widevine dependency to content module.
// However, using this string directly seems fine because it would not
// be changed and can avoid addtional patching for this.
return info.supported_key_system == "com.widevine.alpha";
}),
cdms_.end());
#endif
}
} // namespace content
40 changes: 0 additions & 40 deletions patches/content-browser-media-cdm_registry_impl.cc.patch

This file was deleted.

15 changes: 15 additions & 0 deletions patches/content-browser-media-cdm_registry_impl.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/content/browser/media/cdm_registry_impl.h b/content/browser/media/cdm_registry_impl.h
index 303f3c59b3201ab78c84ae3803b48b37d9f8c998..3eac8905fb8ec6a4f4c050bc290f92065894b4f0 100644
--- a/content/browser/media/cdm_registry_impl.h
+++ b/content/browser/media/cdm_registry_impl.h
@@ -32,6 +32,10 @@ class CONTENT_EXPORT CdmRegistryImpl : public CdmRegistry {
CdmRegistryImpl();
~CdmRegistryImpl() override;

+#if defined(BRAVE_CHROMIUM_BUILD)
+ void Init_ChromiumImpl();
+#endif
+
std::vector<CdmInfo> cdms_;

DISALLOW_COPY_AND_ASSIGN(CdmRegistryImpl);

0 comments on commit 9a814a0

Please sign in to comment.