From 1925b1afb30f119fa6c0733a36d83215b7bac8f7 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Wed, 5 Apr 2017 11:40:15 +0200
Subject: [PATCH] Fix pepper cdms feature

Is now also buildflag and not command line define.

Change-Id: I3c687981928239f669bd285797b5ceee4e994822
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
---
 src/core/browser_message_filter_qt.cpp           | 6 +++---
 src/core/browser_message_filter_qt.h             | 3 ++-
 src/core/common/qt_messages.h                    | 3 ++-
 src/core/content_browser_client_qt.cpp           | 2 +-
 src/core/content_client_qt.cpp                   | 4 ++--
 src/core/renderer/content_renderer_client_qt.cpp | 8 ++++----
 6 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp
index 7551e5616..446dcb38b 100644
--- a/src/core/browser_message_filter_qt.cpp
+++ b/src/core/browser_message_filter_qt.cpp
@@ -58,7 +58,7 @@ BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/)
 bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message)
 {
     IPC_BEGIN_MESSAGE_MAP(BrowserMessageFilterQt, message)
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
         IPC_MESSAGE_HANDLER(
             QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType,
             OnIsInternalPluginAvailableForMimeType)
@@ -68,7 +68,7 @@ bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message)
     return true;
 }
 
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
 void BrowserMessageFilterQt::OnIsInternalPluginAvailableForMimeType(
     const std::string& mime_type, bool* is_available,
     std::vector<base::string16>* additional_param_names,
@@ -93,6 +93,6 @@ void BrowserMessageFilterQt::OnIsInternalPluginAvailableForMimeType(
     *is_available = false;
 }
 
-#endif // defined(ENABLE_PEPPER_CDMS)
+#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
 
 } // namespace QtWebEngineCore
diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h
index 75ca9fd84..fe4897ece 100644
--- a/src/core/browser_message_filter_qt.h
+++ b/src/core/browser_message_filter_qt.h
@@ -41,6 +41,7 @@
 #define BROWSER_MESSAGE_FILTER_QT_H
 
 #include "content/public/browser/browser_message_filter.h"
+#include "ppapi/features/features.h"
 
 #include <QtGlobal>
 
@@ -53,7 +54,7 @@ public:
 
 private:
     bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE;
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
     // Returns whether any internal plugin supporting |mime_type| is registered
     // and enabled. Does not determine whether the plugin can actually be
     // instantiated (e.g. whether it has all its dependencies).
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index 2c971aab2..d998db20e 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -6,6 +6,7 @@
 
 #include "content/public/common/common_param_traits.h"
 #include "ipc/ipc_message_macros.h"
+#include "ppapi/features/features.h"
 
 #include "user_script_data.h"
 
@@ -72,7 +73,7 @@ IPC_MESSAGE_ROUTED1(WebChannelIPCTransportHost_SendMessage, std::vector<char> /*
 // Misc messages
 // These are messages sent from the renderer to the browser process.
 
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
 // Returns whether any internal plugin supporting |mime_type| is registered and
 // enabled. Does not determine whether the plugin can actually be instantiated
 // (e.g. whether it has all its dependencies).
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index b45463d73..b30c4dfa7 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -412,7 +412,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
     const int id = host->GetID();
     content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme);
     static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userResourceController()->renderProcessStartedWithHost(host);
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
     host->AddFilter(new BrowserMessageFilterQt(id));
 #endif
 #if BUILDFLAG(ENABLE_SPELLCHECK)
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 5d51f65aa..b10a02fbd 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -193,7 +193,7 @@ void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugi
 
 void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
 {
-#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && !defined(WIDEVINE_CDM_IS_COMPONENT)
+#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) && !defined(WIDEVINE_CDM_IS_COMPONENT)
     QStringList pluginPaths;
     const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiWidevinePath);
     if (!widevine_argument.empty())
@@ -263,7 +263,7 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
             plugins->push_back(widevine_cdm);
         }
     }
-#endif  // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
+#endif  // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) &&
         // !defined(WIDEVINE_CDM_IS_COMPONENT)
 }
 
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index 93badf853..a2c2a722e 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -222,7 +222,7 @@ bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash)
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
 static const char kExternalClearKeyPepperType[] = "application/x-ppapi-clearkey-cdm";
 
 static bool IsPepperCdmAvailable(const std::string& pepper_type,
@@ -400,17 +400,17 @@ static void AddPepperBasedWidevine(std::vector<std::unique_ptr<media::KeySystemP
         media::EmeFeatureSupport::NOT_SUPPORTED));    // Distinctive identifier.
 }
 #endif  // defined(WIDEVINE_CDM_AVAILABLE)
-#endif  // defined(ENABLE_PEPPER_CDMS)
+#endif  // BUILDFLAG(ENABLE_PEPPER_CDMS)
 
 void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems)
 {
-#if defined(ENABLE_PEPPER_CDMS)
+#if BUILDFLAG(ENABLE_PEPPER_CDMS)
     AddExternalClearKey(key_systems);
 
 #if defined(WIDEVINE_CDM_AVAILABLE)
     AddPepperBasedWidevine(key_systems);
 #endif  // defined(WIDEVINE_CDM_AVAILABLE)
-#endif  // defined(ENABLE_PEPPER_CDMS)
+#endif  // BUILDFLAG(ENABLE_PEPPER_CDMS)
 }
 
 } // namespace
-- 
GitLab