2014-10-31 12:17:05 -06:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-10-22 08:55:13 -06:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
|
2014-10-22 08:55:13 -06:00
|
|
|
|
2024-01-05 04:18:31 -07:00
|
|
|
#include "base/containers/flat_map.h"
|
2023-05-11 14:07:39 -06:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2014-10-22 08:55:13 -06:00
|
|
|
#include "content/public/browser/browser_plugin_guest_manager.h"
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2014-10-22 08:55:13 -06:00
|
|
|
|
|
|
|
class WebViewManager : public content::BrowserPluginGuestManager {
|
|
|
|
public:
|
2015-09-04 20:43:30 -06:00
|
|
|
WebViewManager();
|
|
|
|
~WebViewManager() override;
|
2015-02-04 16:08:29 -07:00
|
|
|
|
2021-11-03 05:41:45 -06:00
|
|
|
// disable copy
|
|
|
|
WebViewManager(const WebViewManager&) = delete;
|
|
|
|
WebViewManager& operator=(const WebViewManager&) = delete;
|
|
|
|
|
2014-10-23 09:08:48 -06:00
|
|
|
void AddGuest(int guest_instance_id,
|
|
|
|
content::WebContents* embedder,
|
2015-09-02 18:47:58 -06:00
|
|
|
content::WebContents* web_contents);
|
2014-10-23 09:08:48 -06:00
|
|
|
void RemoveGuest(int guest_instance_id);
|
2016-05-25 11:13:12 -06:00
|
|
|
|
|
|
|
static WebViewManager* GetWebViewManager(content::WebContents* web_contents);
|
|
|
|
|
2014-10-22 08:55:13 -06:00
|
|
|
// content::BrowserPluginGuestManager:
|
2014-12-09 15:38:43 -07:00
|
|
|
bool ForEachGuest(content::WebContents* embedder,
|
2023-11-28 14:40:12 -07:00
|
|
|
base::FunctionRef<bool(content::WebContents*)> fn) override;
|
2014-10-22 08:55:13 -06:00
|
|
|
|
|
|
|
private:
|
2014-10-23 09:08:48 -06:00
|
|
|
struct WebContentsWithEmbedder {
|
2023-05-11 14:07:39 -06:00
|
|
|
raw_ptr<content::WebContents> web_contents;
|
|
|
|
raw_ptr<content::WebContents> embedder;
|
2014-10-23 09:08:48 -06:00
|
|
|
};
|
2015-02-04 16:28:26 -07:00
|
|
|
// guest_instance_id => (web_contents, embedder)
|
2024-01-05 04:18:31 -07:00
|
|
|
base::flat_map<int, WebContentsWithEmbedder> web_contents_embedder_map_;
|
2014-10-22 08:55:13 -06:00
|
|
|
};
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|
2014-10-22 08:55:13 -06:00
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
|