pepper_plugin_support.patch 7.6 KB

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