From 79bd35ff4f30c0251d7b447044759f7ed70acc71 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 26 Sep 2018 09:42:47 -0400 Subject: [PATCH] Force Widevine to do its own independent check so it goes to Google Fix https://github.com/brave/brave-browser/issues/1123 Our newer component update server will try to handle any requests for extension updates that gets bundled with other extensions in the same request. i.e. len(extensions_to_update) == 1 and unrecognized then go to google server. The old way this worked was batched with other extnesion update checks at the same time so we would just not return an update from our own server which handled it. Note that other extensions use the newer component installer which we set as a batch size of 1 so general extension updates are not affected by this. --- .../widevine_cdm_component_installer.cc | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/chromium_src/chrome/browser/component_updater/widevine_cdm_component_installer.cc b/chromium_src/chrome/browser/component_updater/widevine_cdm_component_installer.cc index 1fce8fd177f8..daa62f049384 100644 --- a/chromium_src/chrome/browser/component_updater/widevine_cdm_component_installer.cc +++ b/chromium_src/chrome/browser/component_updater/widevine_cdm_component_installer.cc @@ -7,23 +7,42 @@ #undef RegisterWidevineCdmComponent #include "brave/browser/brave_browser_process_impl.h" +#include "brave/browser/extensions/brave_component_extension.h" #include "brave/common/pref_names.h" #include "chrome/browser/profiles/profile_manager.h" +#include "brave/common/extensions/extension_constants.h" +#include "components/component_updater/component_updater_service.h" #include "components/prefs/pref_service.h" namespace component_updater { -// Do nothing, we will register if the user opts in! -void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { +void OnWidevineRegistered() { + ComponentsUI demand_updater; + // This weird looking call is ok, it is just like this to not need + // to patch for friend access. + demand_updater.OnDemandUpdate(g_browser_process->component_updater(), + widevine_extension_id); +} + +void RegisterAndInstallWidevine() { + // This code is similar to RegisterWidevineCdmComponent_ChromiumImpl + // but that ignores the callback, and we handle it so we can force + // an on demand update. + auto installer = base::MakeRefCounted( + std::make_unique()); + installer->Register(g_browser_process->component_updater(), + base::Bind(&OnWidevineRegistered)); +} +// Do nothing unless the user opts in! +void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); bool widevine_opted_in = prefs->GetBoolean(kWidevineOptedIn); if (widevine_opted_in) { - RegisterWidevineCdmComponent_ChromiumImpl( - g_brave_browser_process->component_updater()); + RegisterAndInstallWidevine(); } } } // namespace component_updater -