Electron crashes if user clicks Dev Tools & Zoom options #10697
This commit is contained in:
parent
4ffb6c5f75
commit
463260b249
2 changed files with 15 additions and 6 deletions
|
@ -286,12 +286,13 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
request_id_(0),
|
request_id_(0),
|
||||||
background_throttling_(true),
|
background_throttling_(true),
|
||||||
enable_devtools_(true) {
|
enable_devtools_(true) {
|
||||||
|
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
|
||||||
if (type == REMOTE) {
|
if (type == REMOTE) {
|
||||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
AttachAsUserData(web_contents);
|
AttachAsUserData(web_contents);
|
||||||
|
InitZoomController(web_contents, options);
|
||||||
} else {
|
} else {
|
||||||
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
|
|
||||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||||
session_.Reset(isolate, session.ToV8());
|
session_.Reset(isolate, session.ToV8());
|
||||||
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
||||||
|
@ -392,6 +393,15 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||||
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
InitWithSessionAndOptions(isolate, web_contents, session, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::InitZoomController(content::WebContents* web_contents,
|
||||||
|
const mate::Dictionary& options) {
|
||||||
|
WebContentsZoomController::CreateForWebContents(web_contents);
|
||||||
|
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
|
||||||
|
double zoom_factor;
|
||||||
|
if (options.Get(options::kZoomFactor, &zoom_factor))
|
||||||
|
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
|
||||||
|
}
|
||||||
|
|
||||||
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||||
content::WebContents *web_contents,
|
content::WebContents *web_contents,
|
||||||
mate::Handle<api::Session> session,
|
mate::Handle<api::Session> session,
|
||||||
|
@ -409,11 +419,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||||
// Initialize security state client.
|
// Initialize security state client.
|
||||||
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
||||||
// Initialize zoom controller.
|
// Initialize zoom controller.
|
||||||
WebContentsZoomController::CreateForWebContents(web_contents);
|
InitZoomController(web_contents, options);
|
||||||
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
|
|
||||||
double zoom_factor;
|
|
||||||
if (options.Get(options::kZoomFactor, &zoom_factor))
|
|
||||||
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
|
|
||||||
|
|
||||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
// get the zoom level.
|
// get the zoom level.
|
||||||
void OnGetZoomLevel(IPC::Message* reply_msg);
|
void OnGetZoomLevel(IPC::Message* reply_msg);
|
||||||
|
|
||||||
|
void InitZoomController(content::WebContents* web_contents,
|
||||||
|
const mate::Dictionary& options);
|
||||||
|
|
||||||
v8::Global<v8::Value> session_;
|
v8::Global<v8::Value> session_;
|
||||||
v8::Global<v8::Value> devtools_web_contents_;
|
v8::Global<v8::Value> devtools_web_contents_;
|
||||||
v8::Global<v8::Value> debugger_;
|
v8::Global<v8::Value> debugger_;
|
||||||
|
|
Loading…
Add table
Reference in a new issue