Only reset preferences when conversion succeeds
This commit is contained in:
parent
3925bfde8e
commit
fdb1fddc26
1 changed files with 9 additions and 5 deletions
|
@ -102,14 +102,18 @@ Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (options.Get("webContents", &web_contents)) {
|
if (options.Get("webContents", &web_contents)) {
|
||||||
// Set webPreferences from options if using existing webContents
|
// Set webPreferences from options if using an existing webContents.
|
||||||
|
// These preferences will be used when the webContent launches new
|
||||||
|
// render processes.
|
||||||
auto* existing_preferences =
|
auto* existing_preferences =
|
||||||
WebContentsPreferences::FromWebContents(web_contents->web_contents());
|
WebContentsPreferences::FromWebContents(web_contents->web_contents());
|
||||||
base::DictionaryValue web_preferences_dict;
|
base::DictionaryValue web_preferences_dict;
|
||||||
mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
if (mate::ConvertFromV8(isolate, web_preferences.GetHandle(),
|
||||||
&web_preferences_dict);
|
&web_preferences_dict)) {
|
||||||
existing_preferences->web_preferences()->Clear();
|
existing_preferences->web_preferences()->Clear();
|
||||||
existing_preferences->Merge(web_preferences_dict);
|
existing_preferences->Merge(web_preferences_dict);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Creates the WebContents used by BrowserWindow.
|
// Creates the WebContents used by BrowserWindow.
|
||||||
web_contents = WebContents::Create(isolate, web_preferences);
|
web_contents = WebContents::Create(isolate, web_preferences);
|
||||||
|
|
Loading…
Add table
Reference in a new issue