pepper_plugin_support.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: deepak1556 <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:46:17 -0700
  4. Subject: pepper plugin support
  5. This tweaks Chrome's pepper flash and PDF plugin support to make it
  6. usable from Electron.
  7. diff --git a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
  8. index 46513bf122445f822917a1a80d5d9079f288e1b4..7becf2e72ca677335dbd241fa0fef30768a3fc28 100644
  9. --- a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
  10. +++ b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
  11. @@ -12,17 +12,21 @@
  12. #include <stddef.h>
  13. #include "base/task/sequenced_task_runner.h"
  14. +#if 0
  15. #include "chrome/browser/browser_process.h"
  16. #include "chrome/browser/profiles/profile.h"
  17. #include "chrome/browser/profiles/profile_manager.h"
  18. #include "chrome/common/chrome_switches.h"
  19. #include "chrome/common/pepper_permission_util.h"
  20. +#endif
  21. #include "content/public/browser/browser_ppapi_host.h"
  22. #include "content/public/browser/browser_task_traits.h"
  23. #include "content/public/browser/browser_thread.h"
  24. #include "content/public/browser/child_process_security_policy.h"
  25. #include "content/public/browser/render_view_host.h"
  26. +#if 0
  27. #include "extensions/buildflags/buildflags.h"
  28. +#endif
  29. #include "ppapi/c/pp_errors.h"
  30. #include "ppapi/host/dispatch_host_message.h"
  31. #include "ppapi/host/host_message_context.h"
  32. @@ -31,12 +35,11 @@
  33. #include "ppapi/shared_impl/file_system_util.h"
  34. #include "storage/browser/file_system/isolated_context.h"
  35. -#if BUILDFLAG(ENABLE_EXTENSIONS)
  36. +#if 0
  37. #include "extensions/browser/extension_registry.h"
  38. #include "extensions/common/constants.h"
  39. #include "extensions/common/extension.h"
  40. #include "extensions/common/extension_set.h"
  41. -#endif
  42. namespace {
  43. @@ -46,6 +49,7 @@ const char* kPredefinedAllowedCrxFsOrigins[] = {
  44. };
  45. } // namespace
  46. +#endif
  47. // static
  48. PepperIsolatedFileSystemMessageFilter*
  49. @@ -69,11 +73,16 @@ PepperIsolatedFileSystemMessageFilter::PepperIsolatedFileSystemMessageFilter(
  50. const base::FilePath& profile_directory,
  51. const GURL& document_url,
  52. ppapi::host::PpapiHost* ppapi_host)
  53. +#if 0
  54. : render_process_id_(render_process_id),
  55. profile_directory_(profile_directory),
  56. document_url_(document_url) {
  57. for (size_t i = 0; i < std::size(kPredefinedAllowedCrxFsOrigins); ++i)
  58. allowed_crxfs_origins_.insert(kPredefinedAllowedCrxFsOrigins[i]);
  59. +#else
  60. + : profile_directory_(profile_directory),
  61. + document_url_(document_url) {
  62. +#endif
  63. }
  64. PepperIsolatedFileSystemMessageFilter::
  65. @@ -98,6 +107,7 @@ int32_t PepperIsolatedFileSystemMessageFilter::OnResourceMessageReceived(
  66. return PP_ERROR_FAILED;
  67. }
  68. +#if 0
  69. Profile* PepperIsolatedFileSystemMessageFilter::GetProfile() {
  70. DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
  71. ProfileManager* profile_manager = g_browser_process->profile_manager();
  72. @@ -122,6 +132,7 @@ PepperIsolatedFileSystemMessageFilter::CreateCrxFileSystem(Profile* profile) {
  73. return storage::IsolatedContext::ScopedFSHandle();
  74. #endif
  75. }
  76. +#endif
  77. int32_t PepperIsolatedFileSystemMessageFilter::OnOpenFileSystem(
  78. ppapi::host::HostMessageContext* context,
  79. @@ -130,7 +141,7 @@ int32_t PepperIsolatedFileSystemMessageFilter::OnOpenFileSystem(
  80. case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID:
  81. break;
  82. case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX:
  83. - return OpenCrxFileSystem(context);
  84. + return PP_ERROR_NOTSUPPORTED;
  85. }
  86. NOTREACHED_IN_MIGRATION();
  87. context->reply_msg =
  88. @@ -138,6 +149,7 @@ int32_t PepperIsolatedFileSystemMessageFilter::OnOpenFileSystem(
  89. return PP_ERROR_FAILED;
  90. }
  91. +#if 0
  92. int32_t PepperIsolatedFileSystemMessageFilter::OpenCrxFileSystem(
  93. ppapi::host::HostMessageContext* context) {
  94. #if BUILDFLAG(ENABLE_EXTENSIONS)
  95. @@ -178,3 +190,4 @@ int32_t PepperIsolatedFileSystemMessageFilter::OpenCrxFileSystem(
  96. return PP_ERROR_NOTSUPPORTED;
  97. #endif
  98. }
  99. +#endif
  100. diff --git a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
  101. index 716f5f9abe27a4411f7cc47c37d80d9a72099369..77a5cd69317db2c02a4ca75b91cea9405ea99de5 100644
  102. --- a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
  103. +++ b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
  104. @@ -20,7 +20,9 @@
  105. #include "storage/browser/file_system/isolated_context.h"
  106. #include "url/gurl.h"
  107. +#if 0
  108. class Profile;
  109. +#endif
  110. namespace content {
  111. class BrowserPpapiHost;
  112. @@ -59,6 +61,7 @@ class PepperIsolatedFileSystemMessageFilter
  113. ~PepperIsolatedFileSystemMessageFilter() override;
  114. +#if 0
  115. Profile* GetProfile();
  116. // Returns filesystem id of isolated filesystem if valid, or empty string
  117. @@ -66,18 +69,23 @@ class PepperIsolatedFileSystemMessageFilter
  118. // allows access on that thread.
  119. storage::IsolatedContext::ScopedFSHandle CreateCrxFileSystem(
  120. Profile* profile);
  121. +#endif
  122. int32_t OnOpenFileSystem(ppapi::host::HostMessageContext* context,
  123. PP_IsolatedFileSystemType_Private type);
  124. +#if 0
  125. int32_t OpenCrxFileSystem(ppapi::host::HostMessageContext* context);
  126. const int render_process_id_;
  127. +#endif
  128. // Keep a copy from original thread.
  129. const base::FilePath profile_directory_;
  130. const GURL document_url_;
  131. +#if 0
  132. // Set of origins that can use CrxFs private APIs from NaCl.
  133. std::set<std::string> allowed_crxfs_origins_;
  134. +#endif
  135. };
  136. #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
  137. diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
  138. index 8687c49c7b8b96b1d51eae1a482154c21bb7e20c..983ef9a013184344514b69e8ef2a48a75e67ed01 100644
  139. --- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
  140. +++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
  141. @@ -5,7 +5,9 @@
  142. #include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
  143. #include "base/check_op.h"
  144. +#if 0
  145. #include "chrome/renderer/pepper/pepper_uma_host.h"
  146. +#endif
  147. #include "content/public/renderer/renderer_ppapi_host.h"
  148. #include "ppapi/host/ppapi_host.h"
  149. #include "ppapi/host/resource_host.h"
  150. @@ -33,6 +35,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
  151. if (!host_->IsValidInstance(instance))
  152. return nullptr;
  153. +#if 0
  154. // Permissions for the following interfaces will be checked at the
  155. // time of the corresponding instance's method calls. Currently these
  156. // interfaces are available only for whitelisted apps which may not have
  157. @@ -42,6 +45,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
  158. return std::make_unique<PepperUMAHost>(host_, instance, resource);
  159. }
  160. }
  161. +#endif
  162. return nullptr;
  163. }
  164. diff --git a/chrome/renderer/pepper/pepper_helper.h b/chrome/renderer/pepper/pepper_helper.h
  165. index 3270fecaeae81ff98995268613cbe4f834195b53..9b8156a8e188f97647288c96d664a2d733e02afd 100644
  166. --- a/chrome/renderer/pepper/pepper_helper.h
  167. +++ b/chrome/renderer/pepper/pepper_helper.h
  168. @@ -5,11 +5,13 @@
  169. #ifndef CHROME_RENDERER_PEPPER_PEPPER_HELPER_H_
  170. #define CHROME_RENDERER_PEPPER_PEPPER_HELPER_H_
  171. +#include "base/component_export.h"
  172. #include "content/public/renderer/render_frame_observer.h"
  173. // This class listens for Pepper creation events from the RenderFrame and
  174. // attaches the parts required for Chrome-specific plugin support.
  175. -class PepperHelper : public content::RenderFrameObserver {
  176. +class COMPONENT_EXPORT(PEPPER_FLASH) PepperHelper
  177. + : public content::RenderFrameObserver {
  178. public:
  179. explicit PepperHelper(content::RenderFrame* render_frame);
  180. diff --git a/ppapi/buildflags/buildflags.gni b/ppapi/buildflags/buildflags.gni
  181. index 0bc0e153dff7ef5c093dce4f73b709ac36024d63..fba1a83be000ed58170ff800be1b43862f7d3359 100644
  182. --- a/ppapi/buildflags/buildflags.gni
  183. +++ b/ppapi/buildflags/buildflags.gni
  184. @@ -19,7 +19,7 @@ declare_args() {
  185. # Enables Pepper API (PPAPI) plugin support.
  186. # The only remaining PPAPI plugin supported is NaCl and if is disabled
  187. # we can disable PPAPI.
  188. - enable_ppapi = enable_plugins && enable_nacl && !is_fuchsia
  189. + enable_ppapi = enable_plugins && !is_fuchsia
  190. }
  191. assert(enable_plugins || !enable_ppapi)