child_web_contents_tracker.cc 833 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2017 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/browser/child_web_contents_tracker.h"
  5. #include <unordered_set>
  6. namespace atom {
  7. namespace {
  8. std::unordered_set<content::WebContents*> g_child_web_contents;
  9. } // namespace
  10. ChildWebContentsTracker::ChildWebContentsTracker(
  11. content::WebContents* web_contents)
  12. : content::WebContentsObserver(web_contents) {
  13. g_child_web_contents.insert(web_contents);
  14. }
  15. bool ChildWebContentsTracker::IsChildWebContents(
  16. content::WebContents* web_contents) {
  17. return g_child_web_contents.find(web_contents) != g_child_web_contents.end();
  18. }
  19. void ChildWebContentsTracker::WebContentsDestroyed() {
  20. g_child_web_contents.erase(web_contents());
  21. delete this;
  22. }
  23. } // namespace atom