destroy WebContents when view is destroyed

This commit is contained in:
Cheng Zhao 2018-05-16 19:29:44 +09:00
parent 7c2303c758
commit fd4a0626c5
3 changed files with 28 additions and 20 deletions

View file

@ -6,11 +6,7 @@
#define ATOM_BROWSER_API_ATOM_API_WEB_CONTENTS_VIEW_H_
#include "atom/browser/api/atom_api_view.h"
#include "native_mate/handle.h"
namespace brightray {
class InspectableWebContents;
}
#include "atom/browser/api/atom_api_web_contents.h"
namespace atom {
@ -18,7 +14,7 @@ namespace api {
class WebContents;
class WebContentsView : public View {
class WebContentsView : public View, public ExtendedWebContentsObserver {
public:
static mate::WrappableBase* New(mate::Arguments* args,
mate::Handle<WebContents> web_contents);
@ -28,13 +24,17 @@ class WebContentsView : public View {
protected:
WebContentsView(v8::Isolate* isolate,
v8::Local<v8::Value> web_contents_wrapper,
brightray::InspectableWebContents* web_contents);
mate::Handle<WebContents> web_contents,
brightray::InspectableWebContents* iwc);
~WebContentsView() override;
// ExtendedWebContentsObserver:
void OnCloseContents() override;
private:
// Keep a reference to v8 wrapper.
v8::Global<v8::Value> web_contents_wrapper_;
v8::Global<v8::Value> web_contents_;
api::WebContents* api_web_contents_;
DISALLOW_COPY_AND_ASSIGN(WebContentsView);
};