Fix double freeing WebContents
This commit is contained in:
parent
cf9f249f07
commit
1731d609b7
2 changed files with 8 additions and 24 deletions
|
@ -58,12 +58,9 @@ WebContents::WebContents(const mate::Dictionary& options)
|
||||||
if (options.Get("isGuest", &is_guest) && is_guest)
|
if (options.Get("isGuest", &is_guest) && is_guest)
|
||||||
params.guest_delegate = this;
|
params.guest_delegate = this;
|
||||||
|
|
||||||
storage_.reset(content::WebContents::Create(params));
|
storage_.reset(brightray::InspectableWebContents::Create(params));
|
||||||
storage_->SetDelegate(this);
|
Observe(storage_->GetWebContents());
|
||||||
Observe(storage_.get());
|
web_contents()->SetDelegate(this);
|
||||||
|
|
||||||
inspectable_web_contents_.reset(
|
|
||||||
brightray::InspectableWebContents::Create(storage_.get()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebContents::~WebContents() {
|
WebContents::~WebContents() {
|
||||||
|
@ -375,10 +372,10 @@ void WebContents::ExecuteJavaScript(const base::string16& code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OpenDevTools() {
|
void WebContents::OpenDevTools() {
|
||||||
inspectable_web_contents()->ShowDevTools();
|
storage_->ShowDevTools();
|
||||||
|
|
||||||
// force the inspectable web contents to be undocked when it is opened.
|
// Force the inspectable web contents to be undocked when it is opened.
|
||||||
inspectable_web_contents()->GetView()->SetIsDocked(false);
|
storage_->GetView()->SetIsDocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::SendIPCMessage(const base::string16& channel,
|
bool WebContents::SendIPCMessage(const base::string16& channel,
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "brightray/browser/default_web_contents_delegate.h"
|
#include "brightray/browser/default_web_contents_delegate.h"
|
||||||
#include "brightray/browser/inspectable_web_contents_delegate.h"
|
|
||||||
#include "brightray/browser/inspectable_web_contents_impl.h"
|
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
@ -22,7 +20,6 @@ class Dictionary;
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
class InspectableWebContents;
|
class InspectableWebContents;
|
||||||
class InspectableWebContentsImpl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -92,11 +89,6 @@ class WebContents : public mate::EventEmitter,
|
||||||
explicit WebContents(const mate::Dictionary& options);
|
explicit WebContents(const mate::Dictionary& options);
|
||||||
~WebContents();
|
~WebContents();
|
||||||
|
|
||||||
brightray::InspectableWebContentsImpl* inspectable_web_contents() const {
|
|
||||||
return static_cast<brightray::InspectableWebContentsImpl*>(
|
|
||||||
inspectable_web_contents_.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// mate::Wrappable:
|
// mate::Wrappable:
|
||||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||||
v8::Isolate* isolate) override;
|
v8::Isolate* isolate) override;
|
||||||
|
@ -189,16 +181,11 @@ class WebContents : public mate::EventEmitter,
|
||||||
scoped_ptr<base::DictionaryValue> extra_params_;
|
scoped_ptr<base::DictionaryValue> extra_params_;
|
||||||
|
|
||||||
// Stores the WebContents that managed by this class.
|
// Stores the WebContents that managed by this class.
|
||||||
scoped_ptr<content::WebContents> storage_;
|
scoped_ptr<brightray::InspectableWebContents> storage_;
|
||||||
|
|
||||||
// The WebContents that attaches this guest view.
|
// The WebContents that attaches this guest view.
|
||||||
content::WebContents* embedder_web_contents_;
|
content::WebContents* embedder_web_contents_;
|
||||||
|
|
||||||
// Notice that inspectable_web_contents_ must be placed after dialog_manager_,
|
|
||||||
// so we can make sure inspectable_web_contents_ is destroyed before
|
|
||||||
// dialog_manager_, otherwise a crash would happen.
|
|
||||||
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
|
||||||
|
|
||||||
// The size of the container element.
|
// The size of the container element.
|
||||||
gfx::Size element_size_;
|
gfx::Size element_size_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue