web_view_manager.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
  5. #define ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_
  6. #include <map>
  7. #include "content/public/browser/browser_plugin_guest_manager.h"
  8. namespace electron {
  9. class WebViewManager : public content::BrowserPluginGuestManager {
  10. public:
  11. WebViewManager();
  12. ~WebViewManager() override;
  13. // disable copy
  14. WebViewManager(const WebViewManager&) = delete;
  15. WebViewManager& operator=(const WebViewManager&) = delete;
  16. void AddGuest(int guest_instance_id,
  17. content::WebContents* embedder,
  18. content::WebContents* web_contents);
  19. void RemoveGuest(int guest_instance_id);
  20. static WebViewManager* GetWebViewManager(content::WebContents* web_contents);
  21. // content::BrowserPluginGuestManager:
  22. bool ForEachGuest(content::WebContents* embedder,
  23. const GuestCallback& callback) override;
  24. private:
  25. struct WebContentsWithEmbedder {
  26. content::WebContents* web_contents;
  27. content::WebContents* embedder;
  28. };
  29. // guest_instance_id => (web_contents, embedder)
  30. std::map<int, WebContentsWithEmbedder> web_contents_embedder_map_;
  31. };
  32. } // namespace electron
  33. #endif // ELECTRON_SHELL_BROWSER_WEB_VIEW_MANAGER_H_