allow_in-process_windows_to_have_different_web_prefs.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 2afa734a8f0d500f2dedf6db5703f1167669f566..33a013252d4de19206a92b2762329b7ca1514e87 100644
  10. --- a/third_party/blink/common/web_preferences/web_preferences.cc
  11. +++ b/third_party/blink/common/web_preferences/web_preferences.cc
  12. @@ -144,6 +144,19 @@ WebPreferences::WebPreferences()
  13. v8_cache_options(blink::mojom::V8CacheOptions::kDefault),
  14. record_whole_document(false),
  15. stylus_handwriting_enabled(false),
  16. + // Begin Electron-specific WebPreferences.
  17. + context_isolation(false),
  18. + is_webview(false),
  19. + hidden_page(false),
  20. + offscreen(false),
  21. + node_integration(false),
  22. + node_integration_in_worker(false),
  23. + node_integration_in_sub_frames(false),
  24. + enable_spellcheck(false),
  25. + enable_plugins(false),
  26. + enable_websql(false),
  27. + webview_tag(false),
  28. + // End Electron-specific WebPreferences.
  29. cookie_enabled(true),
  30. accelerated_video_decode_enabled(false),
  31. animation_policy(
  32. 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
  33. index 9909d43a76d8bf5bd8e9b3523fe5be5f8740ad54..69bc9db9304547b272393727432f81d3510dd9cd 100644
  34. --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  35. +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  36. @@ -148,6 +148,19 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  37. out->v8_cache_options = data.v8_cache_options();
  38. out->record_whole_document = data.record_whole_document();
  39. out->stylus_handwriting_enabled = data.stylus_handwriting_enabled();
  40. + // Begin Electron-specific WebPreferences.
  41. + out->context_isolation = data.context_isolation();
  42. + out->is_webview = data.is_webview();
  43. + out->hidden_page = data.hidden_page();
  44. + out->offscreen = data.offscreen();
  45. + out->node_integration = data.node_integration();
  46. + out->node_integration_in_worker = data.node_integration_in_worker();
  47. + out->node_integration_in_sub_frames = data.node_integration_in_sub_frames();
  48. + out->enable_spellcheck = data.enable_spellcheck();
  49. + out->enable_plugins = data.enable_plugins();
  50. + out->enable_websql = data.enable_websql();
  51. + out->webview_tag = data.webview_tag();
  52. + // End Electron-specific WebPreferences.
  53. out->cookie_enabled = data.cookie_enabled();
  54. out->accelerated_video_decode_enabled =
  55. data.accelerated_video_decode_enabled();
  56. diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h
  57. index 48134e1dd50c297ed987e4f8068612c420f038a3..a7902ae02436fe820feeb01a73ccd0a3e9b00946 100644
  58. --- a/third_party/blink/public/common/web_preferences/web_preferences.h
  59. +++ b/third_party/blink/public/common/web_preferences/web_preferences.h
  60. @@ -10,6 +10,7 @@
  61. #include <vector>
  62. #include "build/build_config.h"
  63. +#include "base/files/file_path.h"
  64. #include "net/nqe/effective_connection_type.h"
  65. #include "third_party/blink/public/common/common_export.h"
  66. #include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h"
  67. @@ -159,6 +160,19 @@ struct BLINK_COMMON_EXPORT WebPreferences {
  68. // If true, stylus handwriting recognition to text input will be available in
  69. // editable input fields which are non-password type.
  70. bool stylus_handwriting_enabled;
  71. + // Begin Electron-specific WebPreferences.
  72. + bool context_isolation;
  73. + bool is_webview;
  74. + bool hidden_page;
  75. + bool offscreen;
  76. + bool node_integration;
  77. + bool node_integration_in_worker;
  78. + bool node_integration_in_sub_frames;
  79. + bool enable_spellcheck;
  80. + bool enable_plugins;
  81. + bool enable_websql;
  82. + bool webview_tag;
  83. + // End Electron-specific WebPreferences.
  84. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  85. // only controls whether or not the "document.cookie" field is properly
  86. 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
  87. index 07d93df1824f4fb8d9b415f4cc1d6152d7f14355..c4fa257d9cbbe84065b8f092a78a91f52d64484e 100644
  88. --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  89. +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  90. @@ -6,6 +6,7 @@
  91. #define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
  92. #include "build/build_config.h"
  93. +#include "mojo/public/cpp/base/file_path_mojom_traits.h"
  94. #include "mojo/public/cpp/bindings/struct_traits.h"
  95. #include "net/nqe/effective_connection_type.h"
  96. #include "third_party/blink/public/common/common_export.h"
  97. @@ -439,6 +440,52 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
  98. return r.stylus_handwriting_enabled;
  99. }
  100. + // Begin Electron-specific WebPreferences.
  101. + static bool context_isolation(const blink::web_pref::WebPreferences& r) {
  102. + return r.context_isolation;
  103. + }
  104. +
  105. + static int is_webview(const blink::web_pref::WebPreferences& r) {
  106. + return r.is_webview;
  107. + }
  108. +
  109. + static bool hidden_page(const blink::web_pref::WebPreferences& r) {
  110. + return r.hidden_page;
  111. + }
  112. +
  113. + static bool offscreen(const blink::web_pref::WebPreferences& r) {
  114. + return r.offscreen;
  115. + }
  116. +
  117. + static bool node_integration(const blink::web_pref::WebPreferences& r) {
  118. + return r.node_integration;
  119. + }
  120. +
  121. + static bool node_integration_in_worker(const blink::web_pref::WebPreferences& r) {
  122. + return r.node_integration_in_worker;
  123. + }
  124. +
  125. + static bool node_integration_in_sub_frames(const blink::web_pref::WebPreferences& r) {
  126. + return r.node_integration_in_sub_frames;
  127. + }
  128. +
  129. + static bool enable_spellcheck(const blink::web_pref::WebPreferences& r) {
  130. + return r.enable_spellcheck;
  131. + }
  132. +
  133. + static bool enable_plugins(const blink::web_pref::WebPreferences& r) {
  134. + return r.enable_plugins;
  135. + }
  136. +
  137. + static bool enable_websql(const blink::web_pref::WebPreferences& r) {
  138. + return r.enable_websql;
  139. + }
  140. +
  141. + static bool webview_tag(const blink::web_pref::WebPreferences& r) {
  142. + return r.webview_tag;
  143. + }
  144. + // End Electron-specific WebPreferences.
  145. +
  146. static bool cookie_enabled(const blink::web_pref::WebPreferences& r) {
  147. return r.cookie_enabled;
  148. }
  149. diff --git a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  150. index e7c11ab3f46a12b860340f30dc09508c9e1af78b..e883537595b8b924faf121a4ce6866a4dc8b9567 100644
  151. --- a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  152. +++ b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  153. @@ -9,6 +9,7 @@ import "third_party/blink/public/mojom/css/preferred_contrast.mojom";
  154. import "third_party/blink/public/mojom/v8_cache_options.mojom";
  155. import "url/mojom/url.mojom";
  156. import "mojo/public/mojom/base/string16.mojom";
  157. +import "mojo/public/mojom/base/file_path.mojom";
  158. enum PointerType {
  159. kPointerNone = 1, // 1 << 0
  160. @@ -218,6 +219,19 @@ struct WebPreferences {
  161. // If true, stylus handwriting recognition to text input will be available in
  162. // editable input fields which are non-password type.
  163. bool stylus_handwriting_enabled;
  164. + // Begin Electron-specific WebPreferences.
  165. + bool context_isolation;
  166. + bool is_webview;
  167. + bool hidden_page;
  168. + bool offscreen;
  169. + bool node_integration;
  170. + bool node_integration_in_worker;
  171. + bool node_integration_in_sub_frames;
  172. + bool enable_spellcheck;
  173. + bool enable_plugins;
  174. + bool enable_websql;
  175. + bool webview_tag;
  176. + // End Electron-specific WebPreferences.
  177. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  178. // only controls whether or not the "document.cookie" field is properly