2019-07-24 23:01:08 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
#include "shell/renderer/extensions/electron_extensions_renderer_client.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
#include "content/public/renderer/render_thread.h"
|
|
|
|
#include "extensions/renderer/dispatcher.h"
|
2020-01-15 23:11:51 +00:00
|
|
|
#include "shell/renderer/extensions/electron_extensions_dispatcher_delegate.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionsRendererClient::ElectronExtensionsRendererClient()
|
2019-07-24 23:01:08 +00:00
|
|
|
: dispatcher_(std::make_unique<extensions::Dispatcher>(
|
2020-01-15 23:11:51 +00:00
|
|
|
std::make_unique<ElectronExtensionsDispatcherDelegate>())) {
|
2019-07-24 23:01:08 +00:00
|
|
|
dispatcher_->OnRenderThreadStarted(content::RenderThread::Get());
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionsRendererClient::~ElectronExtensionsRendererClient() {}
|
2019-07-24 23:01:08 +00:00
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
bool ElectronExtensionsRendererClient::IsIncognitoProcess() const {
|
2019-07-24 23:01:08 +00:00
|
|
|
// app_shell doesn't support off-the-record contexts.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
int ElectronExtensionsRendererClient::GetLowestIsolatedWorldId() const {
|
2019-07-24 23:01:08 +00:00
|
|
|
// app_shell doesn't need to reserve world IDs for anything other than
|
|
|
|
// extensions, so we always return 1. Note that 0 is reserved for the global
|
|
|
|
// world.
|
|
|
|
// TODO(samuelmaddock): skip electron worlds
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
extensions::Dispatcher* ElectronExtensionsRendererClient::GetDispatcher() {
|
2019-07-24 23:01:08 +00:00
|
|
|
return dispatcher_.get();
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
bool ElectronExtensionsRendererClient::
|
|
|
|
ExtensionAPIEnabledForServiceWorkerScript(const GURL& scope,
|
|
|
|
const GURL& script_url) const {
|
2019-07-24 23:01:08 +00:00
|
|
|
// TODO(nornagon): adapt logic from chrome's version
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
bool ElectronExtensionsRendererClient::AllowPopup() {
|
2019-07-24 23:01:08 +00:00
|
|
|
// TODO(samuelmaddock):
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionsRendererClient::RunScriptsAtDocumentStart(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
dispatcher_->RunScriptsAtDocumentStart(render_frame);
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionsRendererClient::RunScriptsAtDocumentEnd(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
dispatcher_->RunScriptsAtDocumentEnd(render_frame);
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionsRendererClient::RunScriptsAtDocumentIdle(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
dispatcher_->RunScriptsAtDocumentIdle(render_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace electron
|