mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* chore: bump chromium in DEPS to 87.0.4280.6 * chore: bump chromium in DEPS to 87.0.4280.11 * chore: update patches * Add deprecated_default_sources_assignment_filter variable https://chromium-review.googlesource.com/c/chromium/src/+/2416496 * 2426564: Remove global sources assignment filter value https://chromium-review.googlesource.com/c/chromium/src/+/2426564 * Remove set_sources_filter import * chore: fixup printing patch * Add DragOperation and AllowedDragOperations Mojo types https://chromium-review.googlesource.com/c/chromium/src/+/2196167 * Add DragOperation and AllowedDragOperations Mojo types https://chromium-review.googlesource.com/c/chromium/src/+/2196167 * Remove several references to BrowserPlugin from content https://chromium-review.googlesource.com/c/chromium/src/+/2401031 * Remove SurfaceEmbeddingTime and LocalSurfaceIdAllocation https://chromium-review.googlesource.com/c/chromium/src/+/2415128 * Remove several references to BrowserPlugin from content https://chromium-review.googlesource.com/c/chromium/src/+/2401031 * Service Manager embedders switches have been removed or moved Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2440974 * Remove SurfaceEmbeddingTime and LocalSurfaceIdAllocation https://chromium-review.googlesource.com/c/chromium/src/+/2415128 * [XProto] Remove usage of Xlib Visuals https://chromium-review.googlesource.com/c/chromium/src/+/2429933 * Implement tabs.removeCSS in electrons TabsExecuteScriptFunction Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2250506 * Remove lossy ConvertSizeToPixel() methods https://chromium-review.googlesource.com/c/chromium/src/+/2419534 * Remove all keyboard related usage of Xlib Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2436787 * fix: use parent namespace for zygote switches * ConvertRectToPixel methods have been removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2429143 * impl SortingLSH service Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2425327 * chore: update patches * chore: fix servicemanager removed namespace * chore: revert removed methods * chore: update patches * ExtensionURLLoaderFactory is now owned by its receivers Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2357523 * chore: fix linting * Skip Angle manifest file https://chromium-review.googlesource.com/c/angle/angle/+/2425197 Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
// Copyright (c) 2014 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_manager.h"
|
|
|
|
#include "content/public/browser/render_frame_host.h"
|
|
#include "content/public/browser/render_process_host.h"
|
|
#include "content/public/browser/web_contents.h"
|
|
#include "shell/browser/electron_browser_context.h"
|
|
|
|
namespace electron {
|
|
|
|
WebViewManager::WebViewManager() = default;
|
|
|
|
WebViewManager::~WebViewManager() = default;
|
|
|
|
void WebViewManager::AddGuest(int guest_instance_id,
|
|
int element_instance_id,
|
|
content::WebContents* embedder,
|
|
content::WebContents* web_contents) {
|
|
web_contents_embedder_map_[guest_instance_id] = {web_contents, embedder};
|
|
|
|
// Map the element in embedder to guest.
|
|
int owner_process_id = embedder->GetMainFrame()->GetProcess()->GetID();
|
|
ElementInstanceKey key(owner_process_id, element_instance_id);
|
|
element_instance_id_to_guest_map_[key] = guest_instance_id;
|
|
}
|
|
|
|
void WebViewManager::RemoveGuest(int guest_instance_id) {
|
|
if (web_contents_embedder_map_.erase(guest_instance_id) == 0)
|
|
return;
|
|
|
|
// Remove the record of element in embedder too.
|
|
for (const auto& element : element_instance_id_to_guest_map_)
|
|
if (element.second == guest_instance_id) {
|
|
element_instance_id_to_guest_map_.erase(element.first);
|
|
break;
|
|
}
|
|
}
|
|
|
|
content::WebContents* WebViewManager::GetEmbedder(int guest_instance_id) {
|
|
const auto iter = web_contents_embedder_map_.find(guest_instance_id);
|
|
return iter == std::end(web_contents_embedder_map_) ? nullptr
|
|
: iter->second.embedder;
|
|
}
|
|
|
|
bool WebViewManager::ForEachGuest(content::WebContents* embedder_web_contents,
|
|
const GuestCallback& callback) {
|
|
for (auto& item : web_contents_embedder_map_) {
|
|
if (item.second.embedder != embedder_web_contents)
|
|
continue;
|
|
|
|
auto* guest_web_contents = item.second.web_contents;
|
|
if (guest_web_contents && callback.Run(guest_web_contents))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// static
|
|
WebViewManager* WebViewManager::GetWebViewManager(
|
|
content::WebContents* web_contents) {
|
|
auto* context = web_contents->GetBrowserContext();
|
|
if (context) {
|
|
auto* manager = context->GetGuestManager();
|
|
return static_cast<WebViewManager*>(manager);
|
|
} else {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
} // namespace electron
|