refactor: be more precise when creating api::WebContents (#23128)

This commit is contained in:
Jeremy Rose 2021-04-23 13:51:37 -07:00 committed by GitHub
parent 1c57e078aa
commit dc7fa1d9f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 15 deletions

View file

@ -11,7 +11,9 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "extensions/browser/media_capture_util.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
#include "v8/include/v8.h"
namespace extensions {
@ -22,6 +24,9 @@ ElectronExtensionHostDelegate::~ElectronExtensionHostDelegate() {}
void ElectronExtensionHostDelegate::OnExtensionHostCreated(
content::WebContents* web_contents) {
ElectronExtensionWebContentsObserver::CreateForWebContents(web_contents);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
electron::api::WebContents::FromOrCreate(isolate, web_contents);
}
void ElectronExtensionHostDelegate::OnMainFrameCreatedForBackgroundPage(