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
|
|
|
|
2021-02-11 15:58:03 +00:00
|
|
|
#include <string>
|
|
|
|
|
2019-07-24 23:01:08 +00:00
|
|
|
#include "content/public/renderer/render_thread.h"
|
2021-02-11 15:58:03 +00:00
|
|
|
#include "extensions/common/constants.h"
|
|
|
|
#include "extensions/common/manifest_handlers/background_info.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
#include "extensions/renderer/dispatcher.h"
|
2020-02-24 04:33:58 +00:00
|
|
|
#include "shell/common/world_ids.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
2024-03-12 09:15:41 +00:00
|
|
|
ElectronExtensionsRendererClient::ElectronExtensionsRendererClient() {}
|
|
|
|
|
|
|
|
void ElectronExtensionsRendererClient::RenderThreadStarted() {
|
2024-04-15 22:10:32 +00:00
|
|
|
dispatcher_ =
|
|
|
|
std::make_unique<extensions::Dispatcher>(std::move(api_providers_));
|
2019-07-24 23:01:08 +00:00
|
|
|
dispatcher_->OnRenderThreadStarted(content::RenderThread::Get());
|
|
|
|
}
|
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
ElectronExtensionsRendererClient::~ElectronExtensionsRendererClient() = default;
|
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 {
|
2020-02-24 04:33:58 +00:00
|
|
|
return WorldIDs::ISOLATED_WORLD_ID_EXTENSIONS;
|
2019-07-24 23:01:08 +00:00
|
|
|
}
|
|
|
|
|
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::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
|