Revert "refactor: only create webContents after 'will-attach-webview' (#30311)" (#31785)

This reverts commit 6e43b0bcbf.
This commit is contained in:
Charles Kerr 2021-11-11 14:04:06 -06:00 committed by GitHub
parent 09d160f406
commit cac871c027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 17 deletions

View file

@ -28,6 +28,10 @@ void AddGuest(int guest_instance_id,
electron::WebContentsZoomController::FromWebContents(guest_web_contents)
->SetDefaultZoomFactor(zoom_factor);
}
WebContentsPreferences::From(guest_web_contents)->Merge(options);
// Trigger re-calculation of webkit prefs.
guest_web_contents->NotifyPreferencesChanged();
}
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {

View file

@ -176,7 +176,11 @@ void WebContentsPreferences::Clear() {
void WebContentsPreferences::SetFromDictionary(
const gin_helper::Dictionary& web_preferences) {
Clear();
Merge(web_preferences);
}
void WebContentsPreferences::Merge(
const gin_helper::Dictionary& web_preferences) {
web_preferences.Get(options::kPlugins, &plugins_);
web_preferences.Get(options::kExperimentalFeatures, &experimental_features_);
web_preferences.Get(options::kNodeIntegration, &node_integration_);

View file

@ -40,6 +40,8 @@ class WebContentsPreferences
WebContentsPreferences(const WebContentsPreferences&) = delete;
WebContentsPreferences& operator=(const WebContentsPreferences&) = delete;
void Merge(const gin_helper::Dictionary& new_web_preferences);
void SetFromDictionary(const gin_helper::Dictionary& new_web_preferences);
// Append command paramters according to preferences.