fix: crash in BrowserWindow destructor after win.webContents.destroy() (#18686)

This commit is contained in:
Milan Burda 2019-06-14 04:44:36 +02:00 committed by Cheng Zhao
parent da58ac7c20
commit 6e327184bd
4 changed files with 17 additions and 7 deletions

View file

@ -253,7 +253,9 @@ void OnCapturePageDone(util::Promise promise, const SkBitmap& bitmap) {
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), type_(Type::REMOTE) {
: content::WebContentsObserver(web_contents),
type_(Type::REMOTE),
weak_factory_(this) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(),
false);
Init(isolate);
@ -268,7 +270,9 @@ WebContents::WebContents(v8::Isolate* isolate,
WebContents::WebContents(v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents,
Type type)
: content::WebContentsObserver(web_contents.get()), type_(type) {
: content::WebContentsObserver(web_contents.get()),
type_(type),
weak_factory_(this) {
DCHECK(type != Type::REMOTE)
<< "Can't take ownership of a remote WebContents";
auto session = Session::CreateFrom(isolate, GetBrowserContext());
@ -277,8 +281,8 @@ WebContents::WebContents(v8::Isolate* isolate,
mate::Dictionary::CreateEmpty(isolate));
}
WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options) {
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
: weak_factory_(this) {
// Read options.
options.Get("backgroundThrottling", &background_throttling_);