allow_in-process_windows_to_have_different_web_prefs.patch 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 30e237f886b41bdf528b2a0e81054d15fb323f1f..43f7920cf6ff12d8a48ddef5440814a42266e8c5 100644
  10. --- a/third_party/blink/common/web_preferences/web_preferences.cc
  11. +++ b/third_party/blink/common/web_preferences/web_preferences.cc
  12. @@ -145,6 +145,20 @@ 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. + context_isolation(false),
  18. + is_webview(false),
  19. + hidden_page(false),
  20. + offscreen(false),
  21. + preload(base::FilePath::StringType()),
  22. + node_integration(false),
  23. + node_integration_in_worker(false),
  24. + node_integration_in_sub_frames(false),
  25. + enable_spellcheck(false),
  26. + enable_plugins(false),
  27. + enable_websql(false),
  28. + webview_tag(false),
  29. + // End Electron-specific WebPreferences.
  30. cookie_enabled(true),
  31. accelerated_video_decode_enabled(false),
  32. animation_policy(
  33. 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
  34. index b9a65b0aa8771602f6659f5ffe79b6cdfd04f6e4..f1aab825f8aabc023f6405e6f4b5c843374d43a0 100644
  35. --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  36. +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  37. @@ -22,6 +22,10 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  38. !data.ReadSansSerifFontFamilyMap(&out->sans_serif_font_family_map) ||
  39. !data.ReadCursiveFontFamilyMap(&out->cursive_font_family_map) ||
  40. !data.ReadFantasyFontFamilyMap(&out->fantasy_font_family_map) ||
  41. + // Begin Electron-specific WebPreferences.
  42. + !data.ReadPreloads(&out->preloads) ||
  43. + !data.ReadPreload(&out->preload) ||
  44. + // End Electron-specific WebPreferences.
  45. !data.ReadLazyFrameLoadingDistanceThresholdsPx(
  46. &out->lazy_frame_loading_distance_thresholds_px) ||
  47. !data.ReadLazyImageLoadingDistanceThresholdsPx(
  48. @@ -154,6 +158,19 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  49. data.fake_no_alloc_direct_call_for_testing_enabled();
  50. out->v8_cache_options = data.v8_cache_options();
  51. out->record_whole_document = data.record_whole_document();
  52. + // Begin Electron-specific WebPreferences.
  53. + out->context_isolation = data.context_isolation();
  54. + out->is_webview = data.is_webview();
  55. + out->hidden_page = data.hidden_page();
  56. + out->offscreen = data.offscreen();
  57. + out->node_integration = data.node_integration();
  58. + out->node_integration_in_worker = data.node_integration_in_worker();
  59. + out->node_integration_in_sub_frames = data.node_integration_in_sub_frames();
  60. + out->enable_spellcheck = data.enable_spellcheck();
  61. + out->enable_plugins = data.enable_plugins();
  62. + out->enable_websql = data.enable_websql();
  63. + out->webview_tag = data.webview_tag();
  64. + // End Electron-specific WebPreferences.s
  65. out->cookie_enabled = data.cookie_enabled();
  66. out->accelerated_video_decode_enabled =
  67. data.accelerated_video_decode_enabled();
  68. diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h
  69. index a8d4f1905dc3f48dbbde440e4ec50fe95744e365..4ec23ebc2b09b00c849eb762fa371a8cf2925869 100644
  70. --- a/third_party/blink/public/common/web_preferences/web_preferences.h
  71. +++ b/third_party/blink/public/common/web_preferences/web_preferences.h
  72. @@ -10,6 +10,7 @@
  73. #include <vector>
  74. #include "build/build_config.h"
  75. +#include "base/files/file_path.h"
  76. #include "net/nqe/effective_connection_type.h"
  77. #include "third_party/blink/public/common/common_export.h"
  78. #include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h"
  79. @@ -161,6 +162,22 @@ struct BLINK_COMMON_EXPORT WebPreferences {
  80. blink::mojom::V8CacheOptions v8_cache_options;
  81. bool record_whole_document;
  82. + // Begin Electron-specific WebPreferences.
  83. + std::vector<base::FilePath> preloads;
  84. + bool context_isolation;
  85. + bool is_webview;
  86. + bool hidden_page;
  87. + bool offscreen;
  88. + base::FilePath preload;
  89. + bool node_integration;
  90. + bool node_integration_in_worker;
  91. + bool node_integration_in_sub_frames;
  92. + bool enable_spellcheck;
  93. + bool enable_plugins;
  94. + bool enable_websql;
  95. + bool webview_tag;
  96. + // End Electron-specific WebPreferences.
  97. +
  98. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  99. // only controls whether or not the "document.cookie" field is properly
  100. // connected to the backing store, for instance if you wanted to be able to
  101. 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
  102. index dc84e6f516492b72cf513c9786f17b472961dddb..72eb72cde86f0ef9c94123a104e8f30d12952391 100644
  103. --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  104. +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  105. @@ -6,6 +6,7 @@
  106. #define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
  107. #include "build/build_config.h"
  108. +#include "mojo/public/cpp/base/file_path_mojom_traits.h"
  109. #include "mojo/public/cpp/bindings/struct_traits.h"
  110. #include "net/nqe/effective_connection_type.h"
  111. #include "third_party/blink/public/common/common_export.h"
  112. @@ -446,6 +447,60 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
  113. return r.record_whole_document;
  114. }
  115. + // Begin Electron-specific WebPreferences.
  116. + static const std::vector<base::FilePath>& preloads(const blink::web_pref::WebPreferences& r) {
  117. + return r.preloads;
  118. + }
  119. +
  120. + static bool context_isolation(const blink::web_pref::WebPreferences& r) {
  121. + return r.context_isolation;
  122. + }
  123. +
  124. + static int is_webview(const blink::web_pref::WebPreferences& r) {
  125. + return r.is_webview;
  126. + }
  127. +
  128. + static bool hidden_page(const blink::web_pref::WebPreferences& r) {
  129. + return r.hidden_page;
  130. + }
  131. +
  132. + static bool offscreen(const blink::web_pref::WebPreferences& r) {
  133. + return r.offscreen;
  134. + }
  135. +
  136. + static const base::FilePath& preload(const blink::web_pref::WebPreferences& r) {
  137. + return r.preload;
  138. + }
  139. +
  140. + static bool node_integration(const blink::web_pref::WebPreferences& r) {
  141. + return r.node_integration;
  142. + }
  143. +
  144. + static bool node_integration_in_worker(const blink::web_pref::WebPreferences& r) {
  145. + return r.node_integration_in_worker;
  146. + }
  147. +
  148. + static bool node_integration_in_sub_frames(const blink::web_pref::WebPreferences& r) {
  149. + return r.node_integration_in_sub_frames;
  150. + }
  151. +
  152. + static bool enable_spellcheck(const blink::web_pref::WebPreferences& r) {
  153. + return r.enable_spellcheck;
  154. + }
  155. +
  156. + static bool enable_plugins(const blink::web_pref::WebPreferences& r) {
  157. + return r.enable_plugins;
  158. + }
  159. +
  160. + static bool enable_websql(const blink::web_pref::WebPreferences& r) {
  161. + return r.enable_websql;
  162. + }
  163. +
  164. + static bool webview_tag(const blink::web_pref::WebPreferences& r) {
  165. + return r.webview_tag;
  166. + }
  167. + // End Electron-specific WebPreferences.
  168. +
  169. static bool cookie_enabled(const blink::web_pref::WebPreferences& r) {
  170. return r.cookie_enabled;
  171. }
  172. diff --git a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  173. index 067bb3bf74874f3106f4b68c3c3f13039439c526..8cd0710557eacb77f2bfd5a43074c983f956122c 100644
  174. --- a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  175. +++ b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  176. @@ -10,6 +10,7 @@ import "third_party/blink/public/mojom/v8_cache_options.mojom";
  177. import "url/mojom/url.mojom";
  178. import "url/mojom/origin.mojom";
  179. import "mojo/public/mojom/base/string16.mojom";
  180. +import "mojo/public/mojom/base/file_path.mojom";
  181. enum PointerType {
  182. kPointerNone = 1, // 1 << 0
  183. @@ -213,6 +214,22 @@ struct WebPreferences {
  184. V8CacheOptions v8_cache_options;
  185. bool record_whole_document;
  186. + // Begin Electron-specific WebPreferences.
  187. + array<mojo_base.mojom.FilePath> preloads;
  188. + bool context_isolation;
  189. + bool is_webview;
  190. + bool hidden_page;
  191. + bool offscreen;
  192. + mojo_base.mojom.FilePath preload;
  193. + bool node_integration;
  194. + bool node_integration_in_worker;
  195. + bool node_integration_in_sub_frames;
  196. + bool enable_spellcheck;
  197. + bool enable_plugins;
  198. + bool enable_websql;
  199. + bool webview_tag;
  200. + // End Electron-specific WebPreferences.
  201. +
  202. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  203. // only controls whether or not the "document.cookie" field is properly
  204. // connected to the backing store, for instance if you wanted to be able to