allow_in-process_windows_to_have_different_web_prefs.patch 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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_mojom_traits.cc b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  9. index 31c4d7c5d17763a38fd8a814efbc599663e6c816..c7e705030b39a961cd98610908e231cc71158002 100644
  10. --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  11. +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
  12. @@ -149,6 +149,19 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
  13. out->v8_cache_options = data.v8_cache_options();
  14. out->record_whole_document = data.record_whole_document();
  15. out->stylus_handwriting_enabled = data.stylus_handwriting_enabled();
  16. + // Begin Electron-specific WebPreferences.
  17. + out->context_isolation = data.context_isolation();
  18. + out->is_webview = data.is_webview();
  19. + out->hidden_page = data.hidden_page();
  20. + out->offscreen = data.offscreen();
  21. + out->node_integration = data.node_integration();
  22. + out->node_integration_in_worker = data.node_integration_in_worker();
  23. + out->node_integration_in_sub_frames = data.node_integration_in_sub_frames();
  24. + out->enable_spellcheck = data.enable_spellcheck();
  25. + out->enable_plugins = data.enable_plugins();
  26. + out->enable_websql = data.enable_websql();
  27. + out->webview_tag = data.webview_tag();
  28. + // End Electron-specific WebPreferences.
  29. out->cookie_enabled = data.cookie_enabled();
  30. out->accelerated_video_decode_enabled =
  31. data.accelerated_video_decode_enabled();
  32. diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h
  33. index 5c33a83513e528ada518751899a7c640c14dacf7..4b14c0fa75e65fca91e100969fb9707120d199ca 100644
  34. --- a/third_party/blink/public/common/web_preferences/web_preferences.h
  35. +++ b/third_party/blink/public/common/web_preferences/web_preferences.h
  36. @@ -10,6 +10,7 @@
  37. #include <vector>
  38. #include "build/build_config.h"
  39. +#include "base/files/file_path.h"
  40. #include "net/nqe/effective_connection_type.h"
  41. #include "third_party/blink/public/common/common_export.h"
  42. #include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h"
  43. @@ -420,6 +421,20 @@ struct BLINK_COMMON_EXPORT WebPreferences {
  44. // blocking user's access to the background web content.
  45. bool modal_context_menu = true;
  46. + // Begin Electron-specific WebPreferences.
  47. + bool context_isolation = false;
  48. + bool is_webview = false;
  49. + bool hidden_page = false;
  50. + bool offscreen = false;
  51. + bool node_integration = false;
  52. + bool node_integration_in_worker = false;
  53. + bool node_integration_in_sub_frames = false;
  54. + bool enable_spellcheck = false;
  55. + bool enable_plugins = false;
  56. + bool enable_websql = false;
  57. + bool webview_tag = false;
  58. + // End Electron-specific WebPreferences.
  59. +
  60. // We try to keep the default values the same as the default values in
  61. // chrome, except for the cases where it would require lots of extra work for
  62. // the embedder to use the same default value.
  63. 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
  64. index f54089ad64fa5a3c19d084821d188be1a623d548..7129aa8c9c63d31b6eede9e57fa37e2ec3efd257 100644
  65. --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  66. +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
  67. @@ -6,6 +6,7 @@
  68. #define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
  69. #include "build/build_config.h"
  70. +#include "mojo/public/cpp/base/file_path_mojom_traits.h"
  71. #include "mojo/public/cpp/bindings/struct_traits.h"
  72. #include "net/nqe/effective_connection_type.h"
  73. #include "third_party/blink/public/common/common_export.h"
  74. @@ -439,6 +440,52 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
  75. return r.stylus_handwriting_enabled;
  76. }
  77. + // Begin Electron-specific WebPreferences.
  78. + static bool context_isolation(const blink::web_pref::WebPreferences& r) {
  79. + return r.context_isolation;
  80. + }
  81. +
  82. + static int is_webview(const blink::web_pref::WebPreferences& r) {
  83. + return r.is_webview;
  84. + }
  85. +
  86. + static bool hidden_page(const blink::web_pref::WebPreferences& r) {
  87. + return r.hidden_page;
  88. + }
  89. +
  90. + static bool offscreen(const blink::web_pref::WebPreferences& r) {
  91. + return r.offscreen;
  92. + }
  93. +
  94. + static bool node_integration(const blink::web_pref::WebPreferences& r) {
  95. + return r.node_integration;
  96. + }
  97. +
  98. + static bool node_integration_in_worker(const blink::web_pref::WebPreferences& r) {
  99. + return r.node_integration_in_worker;
  100. + }
  101. +
  102. + static bool node_integration_in_sub_frames(const blink::web_pref::WebPreferences& r) {
  103. + return r.node_integration_in_sub_frames;
  104. + }
  105. +
  106. + static bool enable_spellcheck(const blink::web_pref::WebPreferences& r) {
  107. + return r.enable_spellcheck;
  108. + }
  109. +
  110. + static bool enable_plugins(const blink::web_pref::WebPreferences& r) {
  111. + return r.enable_plugins;
  112. + }
  113. +
  114. + static bool enable_websql(const blink::web_pref::WebPreferences& r) {
  115. + return r.enable_websql;
  116. + }
  117. +
  118. + static bool webview_tag(const blink::web_pref::WebPreferences& r) {
  119. + return r.webview_tag;
  120. + }
  121. + // End Electron-specific WebPreferences.
  122. +
  123. static bool cookie_enabled(const blink::web_pref::WebPreferences& r) {
  124. return r.cookie_enabled;
  125. }
  126. diff --git a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  127. index 54f3a206c8ab571563a5ac70ea32edbe844d2057..8376c8f8d5f56adea2ffce3d8d66a6dbc16a6ee6 100644
  128. --- a/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  129. +++ b/third_party/blink/public/mojom/webpreferences/web_preferences.mojom
  130. @@ -9,6 +9,7 @@ import "third_party/blink/public/mojom/css/preferred_contrast.mojom";
  131. import "third_party/blink/public/mojom/v8_cache_options.mojom";
  132. import "url/mojom/url.mojom";
  133. import "mojo/public/mojom/base/string16.mojom";
  134. +import "mojo/public/mojom/base/file_path.mojom";
  135. enum PointerType {
  136. kPointerNone = 1, // 1 << 0
  137. @@ -218,6 +219,19 @@ struct WebPreferences {
  138. // If true, stylus handwriting recognition to text input will be available in
  139. // editable input fields which are non-password type.
  140. bool stylus_handwriting_enabled;
  141. + // Begin Electron-specific WebPreferences.
  142. + bool context_isolation;
  143. + bool is_webview;
  144. + bool hidden_page;
  145. + bool offscreen;
  146. + bool node_integration;
  147. + bool node_integration_in_worker;
  148. + bool node_integration_in_sub_frames;
  149. + bool enable_spellcheck;
  150. + bool enable_plugins;
  151. + bool enable_websql;
  152. + bool webview_tag;
  153. + // End Electron-specific WebPreferences.
  154. // This flags corresponds to a Page's Settings' setCookieEnabled state. It
  155. // only controls whether or not the "document.cookie" field is properly