test_popup_navigation_delegate.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2020 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 "components/blocked_content/test/test_popup_navigation_delegate.h"
  5. namespace blocked_content {
  6. TestPopupNavigationDelegate::ResultHolder::ResultHolder() = default;
  7. TestPopupNavigationDelegate::ResultHolder::~ResultHolder() = default;
  8. TestPopupNavigationDelegate::TestPopupNavigationDelegate(
  9. const GURL& url,
  10. ResultHolder* result_holder)
  11. : url_(url), result_holder_(result_holder) {}
  12. content::RenderFrameHost* TestPopupNavigationDelegate::GetOpener() {
  13. return nullptr;
  14. }
  15. bool TestPopupNavigationDelegate::GetOriginalUserGesture() {
  16. return true;
  17. }
  18. const GURL& TestPopupNavigationDelegate::GetURL() {
  19. return url_;
  20. }
  21. PopupNavigationDelegate::NavigateResult
  22. TestPopupNavigationDelegate::NavigateWithGesture(
  23. const blink::mojom::WindowFeatures& window_features,
  24. absl::optional<WindowOpenDisposition> updated_disposition) {
  25. if (result_holder_) {
  26. result_holder_->did_navigate = true;
  27. result_holder_->navigation_window_features = window_features;
  28. result_holder_->navigation_disposition = updated_disposition;
  29. }
  30. return NavigateResult();
  31. }
  32. void TestPopupNavigationDelegate::OnPopupBlocked(
  33. content::WebContents* web_contents,
  34. int total_popups_blocked_on_page) {
  35. if (result_holder_)
  36. result_holder_->total_popups_blocked_on_page = total_popups_blocked_on_page;
  37. }
  38. } // namespace blocked_content