Be safe on lifetime of webContents.
This commit is contained in:
parent
b02bcc0016
commit
9eeec9aa0b
3 changed files with 31 additions and 13 deletions
|
@ -17,11 +17,20 @@ namespace api {
|
|||
|
||||
WebContents::WebContents(content::WebContents* web_contents)
|
||||
: web_contents_(web_contents) {
|
||||
Observe(web_contents_);
|
||||
}
|
||||
|
||||
WebContents::~WebContents() {
|
||||
}
|
||||
|
||||
void WebContents::WebContentsDestroyed(content::WebContents*) {
|
||||
web_contents_ = NULL;
|
||||
}
|
||||
|
||||
bool WebContents::IsAlive() const {
|
||||
return web_contents_ != NULL;
|
||||
}
|
||||
|
||||
GURL WebContents::GetURL() const {
|
||||
return web_contents_->GetURL();
|
||||
}
|
||||
|
@ -62,6 +71,7 @@ void WebContents::ExecuteJavaScript(const string16& code) {
|
|||
mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return mate::ObjectTemplateBuilder(isolate)
|
||||
.SetMethod("isAlive", &WebContents::IsAlive)
|
||||
.SetMethod("getUrl", &WebContents::GetURL)
|
||||
.SetMethod("getTitle", &WebContents::GetTitle)
|
||||
.SetMethod("isLoading", &WebContents::IsLoading)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue