2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions 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.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
|
|
#include "cef/libcef/browser/osr/web_contents_view_osr.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate(
|
|
|
|
MimeHandlerViewGuest* guest)
|
2024-04-24 23:23:47 +02:00
|
|
|
: owner_web_contents_(guest->owner_web_contents()) {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() = default;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
|
|
|
|
content::WebContents::CreateParams* params) {
|
|
|
|
DCHECK(params->guest_delegate);
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
|
|
|
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
2020-01-23 22:58:01 +01:00
|
|
|
DCHECK(owner_browser);
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (owner_browser->IsWindowless()) {
|
2018-07-03 02:46:03 +02:00
|
|
|
CefWebContentsViewOSR* view_osr = new CefWebContentsViewOSR(
|
|
|
|
owner_browser->GetBackgroundColor(), false, false);
|
2015-07-16 23:40:01 +02:00
|
|
|
params->view = view_osr;
|
|
|
|
params->delegate_view = view_osr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
|
2021-11-10 22:57:31 +01:00
|
|
|
content::RenderFrameHost& render_frame_host,
|
2015-07-16 23:40:01 +02:00
|
|
|
const content::ContextMenuParams& params) {
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
|
|
|
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
2020-01-23 22:58:01 +01:00
|
|
|
DCHECK(owner_browser);
|
|
|
|
|
2022-05-27 11:03:31 +02:00
|
|
|
return owner_browser->ShowContextMenu(params);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|