mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Move content::WebPreferences struct to Blink
https://chromium-review.googlesource.com/c/chromium/src/+/2397670
This commit is contained in:
committed by
Samuel Attard
parent
7774a04b1e
commit
5c98c5ebf4
@@ -47,7 +47,6 @@
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/service_names.mojom.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/grit/electron_resources.h"
|
||||
#include "mojo/public/cpp/bindings/binder_map.h"
|
||||
@@ -98,6 +97,7 @@
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
@@ -576,7 +576,7 @@ content::TtsPlatform* ElectronBrowserClient::GetTtsPlatform() {
|
||||
|
||||
void ElectronBrowserClient::OverrideWebkitPrefs(
|
||||
content::RenderViewHost* host,
|
||||
content::WebPreferences* prefs) {
|
||||
blink::web_pref::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled = true;
|
||||
prefs->web_security_enabled = true;
|
||||
prefs->plugins_enabled = true;
|
||||
|
||||
@@ -90,7 +90,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
|
||||
content::TtsPlatform* GetTtsPlatform() override;
|
||||
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
||||
content::WebPreferences* prefs) override;
|
||||
blink::web_pref::WebPreferences* prefs) override;
|
||||
SiteInstanceForNavigationType ShouldOverrideSiteInstanceForNavigation(
|
||||
content::RenderFrameHost* current_rfh,
|
||||
content::RenderFrameHost* speculative_rfh,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/grit/platform_locale_settings.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace {
|
||||
@@ -148,7 +148,7 @@ base::string16 FetchFont(const char* script, const char* map_name) {
|
||||
}
|
||||
|
||||
void FillFontFamilyMap(const char* map_name,
|
||||
content::ScriptFontFamilyMap* map) {
|
||||
blink::web_pref::ScriptFontFamilyMap* map) {
|
||||
for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
|
||||
const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
|
||||
base::string16 result = FetchFont(script, map_name);
|
||||
@@ -162,7 +162,7 @@ void FillFontFamilyMap(const char* map_name,
|
||||
|
||||
namespace electron {
|
||||
|
||||
void SetFontDefaults(content::WebPreferences* prefs) {
|
||||
void SetFontDefaults(blink::web_pref::WebPreferences* prefs) {
|
||||
FillFontFamilyMap(prefs::kWebKitStandardFontFamilyMap,
|
||||
&prefs->standard_font_family_map);
|
||||
FillFontFamilyMap(prefs::kWebKitFixedFontFamilyMap,
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
#ifndef SHELL_BROWSER_FONT_DEFAULTS_H_
|
||||
#define SHELL_BROWSER_FONT_DEFAULTS_H_
|
||||
|
||||
namespace content {
|
||||
namespace blink {
|
||||
namespace web_pref {
|
||||
struct WebPreferences;
|
||||
} // namespace content
|
||||
} // namespace web_pref
|
||||
} // namespace blink
|
||||
|
||||
namespace electron {
|
||||
|
||||
void SetFontDefaults(content::WebPreferences* prefs);
|
||||
void SetFontDefaults(blink::web_pref::WebPreferences* prefs);
|
||||
|
||||
} // namespace electron
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "sandbox/policy/switches.h"
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/process_util.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -76,17 +76,17 @@ bool GetAsInteger(const base::Value* val, base::StringPiece path, int* out) {
|
||||
|
||||
bool GetAsAutoplayPolicy(const base::Value* val,
|
||||
base::StringPiece path,
|
||||
content::AutoplayPolicy* out) {
|
||||
blink::web_pref::AutoplayPolicy* out) {
|
||||
std::string policy_str;
|
||||
if (GetAsString(val, path, &policy_str)) {
|
||||
if (policy_str == "no-user-gesture-required") {
|
||||
*out = content::AutoplayPolicy::kNoUserGestureRequired;
|
||||
*out = blink::web_pref::AutoplayPolicy::kNoUserGestureRequired;
|
||||
return true;
|
||||
} else if (policy_str == "user-gesture-required") {
|
||||
*out = content::AutoplayPolicy::kUserGestureRequired;
|
||||
*out = blink::web_pref::AutoplayPolicy::kUserGestureRequired;
|
||||
return true;
|
||||
} else if (policy_str == "document-user-activation-required") {
|
||||
*out = content::AutoplayPolicy::kDocumentUserActivationRequired;
|
||||
*out = blink::web_pref::AutoplayPolicy::kDocumentUserActivationRequired;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -450,7 +450,7 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
||||
}
|
||||
|
||||
void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
content::WebPreferences* prefs) {
|
||||
blink::web_pref::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled =
|
||||
IsEnabled(options::kJavaScript, true /* default_value */);
|
||||
prefs->images_enabled = IsEnabled(options::kImages, true /* default_value */);
|
||||
@@ -460,7 +460,8 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
IsEnabled(options::kNavigateOnDragDrop, false /* default_value */);
|
||||
if (!GetAsAutoplayPolicy(&preference_, "autoplayPolicy",
|
||||
&prefs->autoplay_policy)) {
|
||||
prefs->autoplay_policy = content::AutoplayPolicy::kNoUserGestureRequired;
|
||||
prefs->autoplay_policy =
|
||||
blink::web_pref::AutoplayPolicy::kNoUserGestureRequired;
|
||||
}
|
||||
|
||||
// Check if webgl should be enabled.
|
||||
@@ -481,17 +482,17 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
if (fonts_dict) {
|
||||
base::string16 font;
|
||||
if (GetAsString(fonts_dict, "standard", &font))
|
||||
prefs->standard_font_family_map[content::kCommonScript] = font;
|
||||
prefs->standard_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
if (GetAsString(fonts_dict, "serif", &font))
|
||||
prefs->serif_font_family_map[content::kCommonScript] = font;
|
||||
prefs->serif_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
if (GetAsString(fonts_dict, "sansSerif", &font))
|
||||
prefs->sans_serif_font_family_map[content::kCommonScript] = font;
|
||||
prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
if (GetAsString(fonts_dict, "monospace", &font))
|
||||
prefs->fixed_font_family_map[content::kCommonScript] = font;
|
||||
prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
if (GetAsString(fonts_dict, "cursive", &font))
|
||||
prefs->cursive_font_family_map[content::kCommonScript] = font;
|
||||
prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
if (GetAsString(fonts_dict, "fantasy", &font))
|
||||
prefs->fantasy_font_family_map[content::kCommonScript] = font;
|
||||
prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = font;
|
||||
}
|
||||
|
||||
int size;
|
||||
|
||||
@@ -50,7 +50,7 @@ class WebContentsPreferences
|
||||
bool is_subframe);
|
||||
|
||||
// Modify the WebPreferences according to preferences.
|
||||
void OverrideWebkitPrefs(content::WebPreferences* prefs);
|
||||
void OverrideWebkitPrefs(blink::web_pref::WebPreferences* prefs);
|
||||
|
||||
// Clear the current WebPreferences.
|
||||
void Clear();
|
||||
|
||||
Reference in New Issue
Block a user