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/lazy_instance.h"
|
|
|
|
#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();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
const gfx::Rect& initial_rect,
|
|
|
|
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,
|
|
|
|
const GURL& security_origin,
|
|
|
|
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();
|
|
|
|
return content::PictureInPictureResult();
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
void ElectronExtensionHostDelegate::ExitPictureInPicture() {
|
2019-07-24 23:01:08 +00:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|