electron/shell/browser/web_view_manager.h
Charles Kerr 22970f573b
perf: use flat_set, flat_map for small, trivially-moved containers (#40817)
* refactor: use base::flat_map in ElectronMenuModel

* refactor: use base::flat_map in BuildSubmenuFromModel()

* refactor: use base::flat_map in GetDialogsMap()

* refactor: use base::flat_map in DesktopCapturer

* refactor: use base::flat_map, flat_set in ElectronBrowserClient

* refactor: use base::flat_map in ProxyingURLLoaderFactory

* refactor: use base::flat_map in MapToCommonId()

* refactor: use base::flat_map for g_map_id

* refactor: use base::flat_map for ViewsDelegate::AppbarAutohideEdgeMap

* refactor: use base::flat_map for App::app_metrics_

* refactor: use base::flat_map for PowerSaveBlocker::wake_lock_types_

* refactor: use base::flat_map for NativeImage::hicons_

* refactor: use base::flat_map for MenuViews::menu_runners_

* refactor: use base::flat_map for WebViewManager::web_contents_embedder_map_

* refactor: use base::flat_map for InspectableWebContents::extensions_api_

* refactor: use base::flat_set for libnotify GetServerCapabilities()

* refactor: use base::flat_set for InspectableWebContents::loaders_

* refactor: use base::flat_set for ElectronRendererClient::environments_

refactor: use base::flat_set for ElectronRendererClient::injected_frames_

* refactor: use base::flat_set for WebWorkerObserver::environments_
2024-01-05 12:18:31 +01:00

45 lines
1.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.
#ifndef ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
#define ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "content/public/browser/browser_plugin_guest_manager.h"
namespace electron {
class WebViewManager : public content::BrowserPluginGuestManager {
public:
WebViewManager();
~WebViewManager() override;
// disable copy
WebViewManager(const WebViewManager&) = delete;
WebViewManager& operator=(const WebViewManager&) = delete;
void AddGuest(int guest_instance_id,
content::WebContents* embedder,
content::WebContents* web_contents);
void RemoveGuest(int guest_instance_id);
static WebViewManager* GetWebViewManager(content::WebContents* web_contents);
// content::BrowserPluginGuestManager:
bool ForEachGuest(content::WebContents* embedder,
base::FunctionRef<bool(content::WebContents*)> fn) override;
private:
struct WebContentsWithEmbedder {
raw_ptr<content::WebContents> web_contents;
raw_ptr<content::WebContents> embedder;
};
// guest_instance_id => (web_contents, embedder)
base::flat_map<int, WebContentsWithEmbedder> web_contents_embedder_map_;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_