feat: [extensions] implement a couple of tabs APIs (#21779)

This commit is contained in:
Jeremy Apthorp 2020-01-15 15:11:51 -08:00 committed by GitHub
parent 8278a64e00
commit b9eb68c0b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 568 additions and 17 deletions

View file

@ -361,6 +361,7 @@ WebContents::WebContents(v8::Isolate* isolate,
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
extensions::AtomExtensionWebContentsObserver::CreateForWebContents(
web_contents);
script_executor_.reset(new extensions::ScriptExecutor(web_contents));
#endif
registry_.AddInterface(base::BindRepeating(&WebContents::BindElectronBrowser,
base::Unretained(this)));
@ -521,6 +522,7 @@ void WebContents::InitWithSessionAndOptions(
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
extensions::AtomExtensionWebContentsObserver::CreateForWebContents(
web_contents());
script_executor_.reset(new extensions::ScriptExecutor(web_contents()));
#endif
registry_.AddInterface(base::BindRepeating(&WebContents::BindElectronBrowser,

View file

@ -36,6 +36,10 @@
#include "shell/browser/printing/print_preview_message_handler.h"
#endif
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
#include "extensions/browser/script_executor.h"
#endif
namespace blink {
struct WebDeviceEmulationParams;
}
@ -327,6 +331,12 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
WebContents* embedder() { return embedder_; }
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
extensions::ScriptExecutor* script_executor() {
return script_executor_.get();
}
#endif
protected:
// Does not manage lifetime of |web_contents|.
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
@ -537,6 +547,10 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
std::unique_ptr<FrameSubscriber> frame_subscriber_;
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
std::unique_ptr<extensions::ScriptExecutor> script_executor_;
#endif
// The host webcontents that may contain this webcontents.
WebContents* embedder_ = nullptr;