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/browser/extensions/electron_extension_host_delegate.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "extensions/browser/media_capture_util.h"
|
2021-04-23 20:51:37 +00:00
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
2020-02-03 22:01:10 +00:00
|
|
|
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
2021-04-23 20:51:37 +00:00
|
|
|
#include "v8/include/v8.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
ElectronExtensionHostDelegate::ElectronExtensionHostDelegate() = default;
|
2019-07-24 23:01:08 +00:00
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
ElectronExtensionHostDelegate::~ElectronExtensionHostDelegate() = default;
|
2019-07-24 23:01:08 +00:00
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionHostDelegate::OnExtensionHostCreated(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::WebContents* web_contents) {
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
2021-04-23 20:51:37 +00:00
|
|
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
electron::api::WebContents::FromOrCreate(isolate, web_contents);
|
2019-07-24 23:01:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-04 17:27:05 +00:00
|
|
|
void ElectronExtensionHostDelegate::OnMainFrameCreatedForBackgroundPage(
|
2019-07-24 23:01:08 +00:00
|
|
|
ExtensionHost* host) {}
|
|
|
|
|
|
|
|
content::JavaScriptDialogManager*
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionHostDelegate::GetJavaScriptDialogManager() {
|
2019-07-24 23:01:08 +00:00
|
|
|
// TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from
|
|
|
|
// content_shell.
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionHostDelegate::CreateTab(
|
2019-07-24 23:01:08 +00:00
|
|
|
std::unique_ptr<content::WebContents> web_contents,
|
|
|
|
const std::string& extension_id,
|
|
|
|
WindowOpenDisposition disposition,
|
2023-03-10 16:07:42 +00:00
|
|
|
const blink::mojom::WindowFeatures& window_features,
|
2019-07-24 23:01:08 +00:00
|
|
|
bool user_gesture) {
|
|
|
|
// TODO(jamescook): Should app_shell support opening popup windows?
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionHostDelegate::ProcessMediaAccessRequest(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::MediaStreamRequest& request,
|
|
|
|
content::MediaResponseCallback callback,
|
|
|
|
const Extension* extension) {
|
|
|
|
// Allow access to the microphone and/or camera.
|
|
|
|
media_capture_util::GrantMediaStreamRequest(web_contents, request,
|
|
|
|
std::move(callback), extension);
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
bool ElectronExtensionHostDelegate::CheckMediaAccessPermission(
|
2019-07-24 23:01:08 +00:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2023-11-28 21:40:12 +00:00
|
|
|
const url::Origin& security_origin,
|
2019-07-24 23:01:08 +00:00
|
|
|
blink::mojom::MediaStreamType type,
|
|
|
|
const Extension* extension) {
|
|
|
|
media_capture_util::VerifyMediaAccessPermission(type, extension);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::PictureInPictureResult
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionHostDelegate::EnterPictureInPicture(
|
2022-02-25 18:17:35 +00:00
|
|
|
content::WebContents* web_contents) {
|
2019-07-24 23:01:08 +00:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionHostDelegate::ExitPictureInPicture() {
|
2019-07-24 23:01:08 +00:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|