Don't load URL if web contents is destroyed
This commit is contained in:
parent
095f304d7d
commit
1308f790ad
2 changed files with 11 additions and 0 deletions
|
@ -439,6 +439,11 @@ content::WebContents* WebContents::OpenURLFromTab(
|
|||
if (Emit("will-navigate", params.url))
|
||||
return nullptr;
|
||||
|
||||
// Don't load the URL if the web contents was marked as destroyed from a
|
||||
// will-navigate event listener
|
||||
if (IsDestroyed())
|
||||
return nullptr;
|
||||
|
||||
return CommonWebContentsDelegate::OpenURLFromTab(source, params);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,12 @@ class TrackableObject : public TrackableObjectBase,
|
|||
Wrappable<T>::GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
}
|
||||
|
||||
bool IsDestroyed() {
|
||||
v8::Local<v8::Object> wrapper = Wrappable<T>::GetWrapper();
|
||||
return wrapper->InternalFieldCount() == 0 ||
|
||||
wrapper->GetAlignedPointerFromInternalField(0) == nullptr;
|
||||
}
|
||||
|
||||
// Finds out the TrackableObject from its ID in weak map.
|
||||
static T* FromWeakMapID(v8::Isolate* isolate, int32_t id) {
|
||||
if (!weak_map_)
|
||||
|
|
Loading…
Reference in a new issue