allow_in-process_windows_to_have_different_web_prefs.patch 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Andy Locascio <[email protected]>
  3. Date: Wed, 6 May 2020 16:37:54 -0700
  4. Subject: allow in-process windows to have different web prefs
  5. Allow earlier access to newly created WebContents so that we can change
  6. WebPreferences of in-process child windows, rather than relying on
  7. process-level command line switches, as before.
  8. diff --git a/third_party/blink/common/web_preferences/web_preferences.cc b/third_party/blink/common/web_preferences/web_preferences.cc
  9. index 8a1315f7f89588bb21c6d3c21a7de7c07fed9679..51cc790f7e1ba1440a6ffaa56c9e01687fc35c06 100644
  10. --- a/third_party/blink/common/web_preferences/web_preferences.cc
  11. +++ b/third_party/blink/common/web_preferences/web_preferences.cc
  12. @@ -148,6 +148,22 @@ WebPreferences::WebPreferences()
  13. fake_no_alloc_direct_call_for_testing_enabled(false),
  14. v8_cache_options(blink::mojom::V8CacheOptions::kDefault),
  15. record_whole_document(false),
  16. + // Begin Electron-specific WebPreferences.
  17. + opener_id(0),
  18. + context_isolation(false),
  19. + guest_instance_id(0),
  20. + hidden_page(false),
  21. + offscreen(false),
  22. + preload(base::FilePath::StringType()),
  23. + native_window_open(false),
  24. + node_integration(false),
  25. + node_integration_in_worker(false),
  26. + node_integration_in_sub_frames(false),
  27. + enable_spellcheck(false),
  28. + enable_plugins(false),
  29. + enable_websql(false),
  30. + webview_tag(false),
  31. + // End Electron-specific WebPreferences.
  32. cookie_enabled(true),
  33. accelerated_video_decode_enabled(false),
  34. animation_policy(
  35. diff --git a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  36. index a264ef99beb81dd6b1f55c1b0f57f6055b4ab771..ff4d5c5245ba0641b4ef02cdaf5d50be537b709e 100644
  37. --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  38. +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  39. @@ -23,6 +23,10 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  40. !data.ReadCursiveFontFamilyMap(&out->cursive_font_family_map) ||
  41. !data.ReadFantasyFontFamilyMap(&out->fantasy_font_family_map) ||
  42. !data.ReadPictographFontFamilyMap(&out->pictograph_font_family_map) ||
  43. + // Begin Electron-specific WebPreferences.
  44. + !data.ReadPreloads(&out->preloads) ||
  45. + !data.ReadPreload(&out->preload) ||
  46. + // End Electron-specific WebPreferences.
  47. !data.ReadLazyFrameLoadingDistanceThresholdsPx(
  48. &out->lazy_frame_loading_distance_thresholds_px) ||
  49. !data.ReadLazyImageLoadingDistanceThresholdsPx(
  50. @@ -156,6 +160,21 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  51. data.fake_no_alloc_direct_call_for_testing_enabled();
  52. out->v8_cache_options = data.v8_cache_options();
  53. out->record_whole_document = data.record_whole_document();
  54. + // Begin Electron-specific WebPreferences.
  55. + out->opener_id = data.opener_id();
  56. + out->context_isolation = data.context_isolation();
  57. + out->guest_instance_id = data.guest_instance_id();
  58. + out->hidden_page = data.hidden_page();
  59. + out->offscreen = data.offscreen();
  60. + out->native_window_open = data.native_window_open();
  61. + out->node_integration = data.node_integration();
  62. + out->node_integration_in_worker = data.node_integration_in_worker();
  63. + out->node_integration_in_sub_frames = data.node_integration_in_sub_frames();
  64. + out->enable_spellcheck = data.enable_spellcheck();
  65. + out->enable_plugins = data.enable_plugins();
  66. + out->enable_websql = data.enable_websql();
  67. + out->webview_tag = data.webview_tag();
  68. + // End Electron-specific WebPreferences.s
  69. out->cookie_enabled = data.cookie_enabled();
  70. out->accelerated_video_decode_enabled =
  71. data.accelerated_video_decode_enabled();
  72. diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h
  73. index 4517bf43c1b80f1aa0f3ba8e67e78b8b91e19f8a..492f6c948af74bb925826a1075e6343f147f0eb2 100644
  74. --- a/third_party/blink/public/common/web_preferences/web_preferences.h
  75. +++ b/third_party/blink/public/common/web_preferences/web_preferences.h
  76. @@ -10,6 +10,7 @@
  77. #include <vector>
  78. #include "build/build_config.h"
  79. +#include "base/files/file_path.h"
  80. #include "net/nqe/effective_connection_type.h"
  81. #include "third_party/blink/public/common/common_export.h"
  82. #include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h"
  83. @@ -162,6 +163,24 @@ struct BLINK_COMMON_EXPORT WebPreferences {
  84. blink::mojom::V8CacheOptions v8_cache_options;
  85. bool record_whole_document;
  86. + // Begin Electron-specific WebPreferences.
  87. + std::vector<base::FilePath> preloads;
  88. + int opener_id;
  89. + bool context_isolation;
  90. + int guest_instance_id;
  91. + bool hidden_page;
  92. + bool offscreen;
  93. + base::FilePath preload;
  94. + bool native_window_open;
  95. + bool node_integration;
  96. + bool node_integration_in_worker;
  97. + bool node_integration_in_sub_frames;
  98. + bool enable_spellcheck;
  99. + bool enable_plugins;
  100. + bool enable_websql;
  101. + bool webview_tag;
  102. + // End Electron-specific WebPreferences.
  103. +
  104. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  105. // only controls whether or not the "document.cookie" field is properly
  106. // connected to the backing store, for instance if you wanted to be able to
  107. diff --git a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  108. index 9dbbb581a8876430c3e0a39df1ff655d3ddc6d2d..fd6cbcfa1992a75bf660fb9eb47a9099acb3834f 100644
  109. --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  110. +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  111. @@ -6,6 +6,7 @@
  112. #define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
  113. #include "build/build_config.h"
  114. +#include "mojo/public/cpp/base/file_path_mojom_traits.h"
  115. #include "mojo/public/cpp/bindings/struct_traits.h"
  116. #include "net/nqe/effective_connection_type.h"
  117. #include "third_party/blink/public/common/common_export.h"
  118. @@ -451,6 +452,68 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
  119. return r.record_whole_document;
  120. }
  121. + // Begin Electron-specific WebPreferences.
  122. + static const std::vector<base::FilePath>& preloads(const blink::web_pref::WebPreferences& r) {
  123. + return r.preloads;
  124. + }
  125. +
  126. + static int opener_id(const blink::web_pref::WebPreferences& r) {
  127. + return r.opener_id;
  128. + }
  129. +
  130. + static bool context_isolation(const blink::web_pref::WebPreferences& r) {
  131. + return r.context_isolation;
  132. + }
  133. +
  134. + static int guest_instance_id(const blink::web_pref::WebPreferences& r) {
  135. + return r.guest_instance_id;
  136. + }
  137. +
  138. + static bool hidden_page(const blink::web_pref::WebPreferences& r) {
  139. + return r.hidden_page;
  140. + }
  141. +
  142. + static bool offscreen(const blink::web_pref::WebPreferences& r) {
  143. + return r.offscreen;
  144. + }
  145. +
  146. + static const base::FilePath& preload(const blink::web_pref::WebPreferences& r) {
  147. + return r.preload;
  148. + }
  149. +
  150. + static bool native_window_open(const blink::web_pref::WebPreferences& r) {
  151. + return r.native_window_open;
  152. + }
  153. +
  154. + static bool node_integration(const blink::web_pref::WebPreferences& r) {
  155. + return r.node_integration;
  156. + }
  157. +
  158. + static bool node_integration_in_worker(const blink::web_pref::WebPreferences& r) {
  159. + return r.node_integration_in_worker;
  160. + }
  161. +
  162. + static bool node_integration_in_sub_frames(const blink::web_pref::WebPreferences& r) {
  163. + return r.node_integration_in_sub_frames;
  164. + }
  165. +
  166. + static bool enable_spellcheck(const blink::web_pref::WebPreferences& r) {
  167. + return r.enable_spellcheck;
  168. + }
  169. +
  170. + static bool enable_plugins(const blink::web_pref::WebPreferences& r) {
  171. + return r.enable_plugins;
  172. + }
  173. +
  174. + static bool enable_websql(const blink::web_pref::WebPreferences& r) {
  175. + return r.enable_websql;
  176. + }
  177. +
  178. + static bool webview_tag(const blink::web_pref::WebPreferences& r) {
  179. + return r.webview_tag;
  180. + }
  181. + // End Electron-specific WebPreferences.
  182. +
  183. static bool cookie_enabled(const blink::web_pref::WebPreferences& r) {
  184. return r.cookie_enabled;
  185. }
  186. diff --git a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  187. index eaecb8c2b7dadaf7650bc8ac85cbad4383035e67..7863c865df17fa95965b5a4e543579bac22af90b 100644
  188. --- a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  189. +++ b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  190. @@ -10,6 +10,7 @@ import "third_party/blink/public/mojom/v8_cache_options.mojom";
  191. import "url/mojom/url.mojom";
  192. import "url/mojom/origin.mojom";
  193. import "mojo/public/mojom/base/string16.mojom";
  194. +import "mojo/public/mojom/base/file_path.mojom";
  195. enum PointerType {
  196. kPointerNone = 1, // 1 << 0
  197. @@ -214,6 +215,24 @@ struct WebPreferences {
  198. V8CacheOptions v8_cache_options;
  199. bool record_whole_document;
  200. + // Begin Electron-specific WebPreferences.
  201. + array<mojo_base.mojom.FilePath> preloads;
  202. + int32 opener_id;
  203. + bool context_isolation;
  204. + int32 guest_instance_id;
  205. + bool hidden_page;
  206. + bool offscreen;
  207. + mojo_base.mojom.FilePath preload;
  208. + bool native_window_open;
  209. + bool node_integration;
  210. + bool node_integration_in_worker;
  211. + bool node_integration_in_sub_frames;
  212. + bool enable_spellcheck;
  213. + bool enable_plugins;
  214. + bool enable_websql;
  215. + bool webview_tag;
  216. + // End Electron-specific WebPreferences.
  217. +
  218. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  219. // only controls whether or not the "document.cookie" field is properly
  220. // connected to the backing store, for instance if you wanted to be able to