scoped_web_frame.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "extensions/renderer/scoped_web_frame.h"
  5. #include "mojo/public/cpp/bindings/associated_remote.h"
  6. #include "mojo/public/cpp/bindings/pending_remote.h"
  7. #include "third_party/blink/public/common/tokens/tokens.h"
  8. #include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
  9. #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h"
  10. #include "third_party/blink/public/web/web_heap.h"
  11. #include "third_party/blink/public/web/web_view.h"
  12. #include "third_party/blink/public/web/web_widget.h"
  13. namespace extensions {
  14. ScopedWebFrame::ScopedWebFrame()
  15. : agent_group_scheduler_(
  16. blink::scheduler::WebAgentGroupScheduler::CreateForTesting()),
  17. view_(blink::WebView::Create(
  18. /*client=*/nullptr,
  19. /*is_hidden=*/false,
  20. /*is_prerendering=*/false,
  21. /*is_inside_portal=*/false,
  22. /*fenced_frame_mode=*/absl::nullopt,
  23. /*compositing_enabled=*/false,
  24. /*widgets_never_composited=*/false,
  25. /*opener=*/nullptr,
  26. mojo::NullAssociatedReceiver(),
  27. *agent_group_scheduler_,
  28. /*session_storage_namespace_id=*/base::EmptyString(),
  29. /*page_base_background_color=*/absl::nullopt)),
  30. frame_(blink::WebLocalFrame::CreateMainFrame(view_,
  31. &frame_client_,
  32. nullptr,
  33. blink::LocalFrameToken(),
  34. nullptr)) {
  35. view_->DidAttachLocalMainFrame();
  36. }
  37. ScopedWebFrame::~ScopedWebFrame() {
  38. view_->Close();
  39. blink::WebHeap::CollectAllGarbageForTesting();
  40. agent_group_scheduler_ = nullptr;
  41. }
  42. } // namespace extensions