30fbeec036
* chore: bump chromium in DEPS to 130.0.6723.4 * chore: bump chromium in DEPS to 131.0.6724.0 * chore: update patches * chore: update libc++ filenames * 5844369: controlledframe: Disable Web Bluetooth for <webview> & <controlledframe> https://chromium-review.googlesource.com/c/chromium/src/+/5844369 * (multiple CLs): Use an opaque type for FrameTreeNode IDs 5807683: Use an opaque type for FrameTreeNode IDs, part 1 | https://chromium-review.googlesource.com/c/chromium/src/+/5807683 5829746: Use an opaque type for FrameTreeNode IDs, part 2 | https://chromium-review.googlesource.com/c/chromium/src/+/5829746 5836903: Use an opaque type for FrameTreeNode IDs, part 7 | https://chromium-review.googlesource.com/c/chromium/src/+/5836903 5837249: Use an opaque type for FrameTreeNode IDs, part 8 | https://chromium-review.googlesource.com/c/chromium/src/+/5837249 5836564: Use an opaque type for FrameTreeNode IDs, part 12 | https://chromium-review.googlesource.com/c/chromium/src/+/5836564 5837180: Use an opaque type for FrameTreeNode IDs, part 15 | https://chromium-review.googlesource.com/c/chromium/src/+/5837180 * 5822889: [task] Make GetForegroundTaskRunner non-virtual https://chromium-review.googlesource.com/c/v8/v8/+/5822889 * 5833297: Remove unused inner WebContents attach params https://chromium-review.googlesource.com/c/chromium/src/+/5833297 * 5806403: Shift PowerMonitor to non static https://chromium-review.googlesource.com/c/chromium/src/+/5806403 * 5666874: [3/N] Remove old OnPowerChange in PowerObserver https://chromium-review.googlesource.com/c/chromium/src/+/5666874 * 5829085: [v8] Differentiate between UserVisible and BestEffort task runners https://chromium-review.googlesource.com/c/chromium/src/+/5829085 * 5791112: [webrtc] Use `c/b/permissions/system` for system permissions https://chromium-review.googlesource.com/c/chromium/src/+/5791112 * 5825636: [Extensions] Create WebContentsObservers with ExtensionsBrowserClient https://chromium-review.googlesource.com/c/chromium/src/+/5825636 * fixup! (multiple CLs): Use an opaque type for FrameTreeNode IDs * fixup! 5791112: [webrtc] Use `c/b/permissions/system` for system permissions https://chromium-review.googlesource.com/c/chromium/src/+/5791112 * chore: bump chromium in DEPS to 131.0.6726.0 * chore: update patches * chore: update libc++ filenames * 5858119: Declutter: Allow opening to a specific feature https://chromium-review.googlesource.com/c/chromium/src/+/5858119 * fix: macOS SDK 15 error Not sure exactly what changed in the upgrade to macOS SDK 15, but it triggered a new error: ``` electron/shell/browser/ui/message_box_mac.mm:84:7: error: multiple methods named 'highlight:' found with mismatched result, parameter type or attributes ``` The `highlight:` selector a few lines down was ambiguous because the object type of the `NSArray` was not specified. Specifying `NSButton` as the element type makes the selector unambiguous for type checking. * 5854143: [File Download Access Prevention] Obfuscate download file for enterprise deep scan https://chromium-review.googlesource.com/c/chromium/src/+/5854143 * 5854811: Use kNotAllowedError instead of kSecurityError for Web MIDI https://chromium-review.googlesource.com/c/chromium/src/+/5854811 * chore: bump chromium in DEPS to 131.0.6728.0 * chore: update patches * disable invalid test * chore: bump chromium in DEPS to 131.0.6730.0 * chore: update patches * update build tools target commit for new macOS SDK * chore: update libc++ file names * chore: bump chromium in DEPS to 131.0.6732.0 * chore: bump chromium in DEPS to 131.0.6734.0 * 5856527: [UI] Use mojo enum for `WindowShowState` in ui/ https://chromium-review.googlesource.com/c/chromium/src/+/5856527 * chore: update build-tools sha to include macOD 15.0 SDK --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: clavin <clavin@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: alice <alice@makenotion.com>
129 lines
4.7 KiB
C++
129 lines
4.7 KiB
C++
// Copyright (c) 2015 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/web_view_guest_delegate.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
|
#include "content/public/browser/navigation_handle.h"
|
|
#include "content/public/browser/render_frame_host.h"
|
|
#include "content/public/browser/render_process_host.h"
|
|
#include "content/public/browser/render_view_host.h"
|
|
#include "content/public/browser/render_widget_host.h"
|
|
#include "content/public/browser/render_widget_host_view.h"
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
|
#include "third_party/blink/public/common/page/page_zoom.h"
|
|
|
|
namespace electron {
|
|
|
|
WebViewGuestDelegate::WebViewGuestDelegate(content::WebContents* embedder,
|
|
api::WebContents* api_web_contents)
|
|
: embedder_web_contents_(embedder), api_web_contents_(api_web_contents) {}
|
|
|
|
WebViewGuestDelegate::~WebViewGuestDelegate() {
|
|
ResetZoomController();
|
|
}
|
|
|
|
void WebViewGuestDelegate::AttachToIframe(
|
|
content::WebContents* embedder_web_contents,
|
|
int embedder_frame_id) {
|
|
embedder_web_contents_ = embedder_web_contents;
|
|
|
|
int embedder_process_id =
|
|
embedder_web_contents_->GetPrimaryMainFrame()->GetProcess()->GetID();
|
|
auto* embedder_frame =
|
|
content::RenderFrameHost::FromID(embedder_process_id, embedder_frame_id);
|
|
DCHECK_EQ(embedder_web_contents_,
|
|
content::WebContents::FromRenderFrameHost(embedder_frame));
|
|
|
|
content::WebContents* guest_web_contents = api_web_contents_->web_contents();
|
|
|
|
// Attach this inner WebContents |guest_web_contents| to the outer
|
|
// WebContents |embedder_web_contents|. The outer WebContents's
|
|
// frame |embedder_frame| hosts the inner WebContents.
|
|
embedder_web_contents_->AttachInnerWebContents(
|
|
base::WrapUnique<content::WebContents>(guest_web_contents),
|
|
embedder_frame,
|
|
/*is_full_page=*/false);
|
|
|
|
ResetZoomController();
|
|
|
|
embedder_zoom_controller_ =
|
|
WebContentsZoomController::FromWebContents(embedder_web_contents_);
|
|
embedder_zoom_controller_->AddObserver(this);
|
|
auto* zoom_controller = api_web_contents_->GetZoomController();
|
|
zoom_controller->SetEmbedderZoomController(embedder_zoom_controller_);
|
|
|
|
api_web_contents_->Emit("did-attach");
|
|
}
|
|
|
|
void WebViewGuestDelegate::WillDestroy() {
|
|
ResetZoomController();
|
|
}
|
|
|
|
content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() {
|
|
return embedder_web_contents_;
|
|
}
|
|
|
|
void WebViewGuestDelegate::OnZoomChanged(
|
|
const WebContentsZoomController::ZoomChangedEventData& data) {
|
|
if (data.web_contents == GetOwnerWebContents()) {
|
|
auto* zoom_controller = api_web_contents_->GetZoomController();
|
|
if (data.temporary) {
|
|
zoom_controller->SetTemporaryZoomLevel(data.new_zoom_level);
|
|
} else {
|
|
if (blink::ZoomValuesEqual(data.new_zoom_level,
|
|
zoom_controller->GetZoomLevel()))
|
|
return;
|
|
zoom_controller->SetZoomLevel(data.new_zoom_level);
|
|
}
|
|
// Change the default zoom factor to match the embedders' new zoom level.
|
|
double zoom_factor = blink::ZoomLevelToZoomFactor(data.new_zoom_level);
|
|
zoom_controller->SetDefaultZoomFactor(zoom_factor);
|
|
}
|
|
}
|
|
|
|
void WebViewGuestDelegate::OnZoomControllerDestroyed(
|
|
WebContentsZoomController* zoom_controller) {
|
|
ResetZoomController();
|
|
}
|
|
|
|
void WebViewGuestDelegate::ResetZoomController() {
|
|
if (embedder_zoom_controller_) {
|
|
embedder_zoom_controller_->RemoveObserver(this);
|
|
embedder_zoom_controller_ = nullptr;
|
|
}
|
|
}
|
|
|
|
std::unique_ptr<content::WebContents>
|
|
WebViewGuestDelegate::CreateNewGuestWindow(
|
|
const content::WebContents::CreateParams& create_params) {
|
|
// Code below mirrors what content::WebContentsImpl::CreateNewWindow
|
|
// does for non-guest sources
|
|
content::WebContents::CreateParams guest_params(create_params);
|
|
guest_params.context = embedder_web_contents_->GetNativeView();
|
|
std::unique_ptr<content::WebContents> guest_contents =
|
|
content::WebContents::Create(guest_params);
|
|
if (!create_params.opener_suppressed) {
|
|
auto* guest_contents_impl =
|
|
static_cast<content::WebContentsImpl*>(guest_contents.release());
|
|
auto* new_guest_view = guest_contents_impl->GetView();
|
|
content::RenderWidgetHostView* widget_view =
|
|
new_guest_view->CreateViewForWidget(
|
|
guest_contents_impl->GetRenderViewHost()->GetWidget());
|
|
if (!create_params.initially_hidden)
|
|
widget_view->Show();
|
|
return base::WrapUnique(
|
|
static_cast<content::WebContentsImpl*>(guest_contents_impl));
|
|
}
|
|
return guest_contents;
|
|
}
|
|
|
|
base::WeakPtr<content::BrowserPluginGuestDelegate>
|
|
WebViewGuestDelegate::GetGuestDelegateWeakPtr() {
|
|
return weak_ptr_factory_.GetWeakPtr();
|
|
}
|
|
|
|
} // namespace electron
|