web_view_manager.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 SHELL_BROWSER_WEB_VIEW_MANAGER_H_
  5. #define 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. void AddGuest(int guest_instance_id,
  14. content::WebContents* embedder,
  15. content::WebContents* web_contents);
  16. void RemoveGuest(int guest_instance_id);
  17. static WebViewManager* GetWebViewManager(content::WebContents* web_contents);
  18. // content::BrowserPluginGuestManager:
  19. bool ForEachGuest(content::WebContents* embedder,
  20. const GuestCallback& callback) override;
  21. private:
  22. struct WebContentsWithEmbedder {
  23. content::WebContents* web_contents;
  24. content::WebContents* embedder;
  25. };
  26. // guest_instance_id => (web_contents, embedder)
  27. std::map<int, WebContentsWithEmbedder> web_contents_embedder_map_;
  28. DISALLOW_COPY_AND_ASSIGN(WebViewManager);
  29. };
  30. } // namespace electron
  31. #endif // SHELL_BROWSER_WEB_VIEW_MANAGER_H_