url_checker_delegate_impl.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2019 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. #ifndef WEBLAYER_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_
  5. #define WEBLAYER_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_
  6. #include "base/memory/ref_counted.h"
  7. #include "components/safe_browsing/core/browser/url_checker_delegate.h"
  8. #include "content/public/browser/web_contents.h"
  9. namespace security_interstitials {
  10. struct UnsafeResource;
  11. }
  12. namespace safe_browsing {
  13. class SafeBrowsingUIManager;
  14. }
  15. namespace weblayer {
  16. class UrlCheckerDelegateImpl : public safe_browsing::UrlCheckerDelegate {
  17. public:
  18. UrlCheckerDelegateImpl(
  19. scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
  20. database_manager,
  21. scoped_refptr<safe_browsing::SafeBrowsingUIManager> ui_manager);
  22. UrlCheckerDelegateImpl(const UrlCheckerDelegateImpl&) = delete;
  23. UrlCheckerDelegateImpl& operator=(const UrlCheckerDelegateImpl&) = delete;
  24. void SetSafeBrowsingDisabled(bool disabled);
  25. private:
  26. ~UrlCheckerDelegateImpl() override;
  27. // Implementation of UrlCheckerDelegate:
  28. void MaybeDestroyNoStatePrefetchContents(
  29. content::WebContents::OnceGetter web_contents_getter) override;
  30. void StartDisplayingBlockingPageHelper(
  31. const security_interstitials::UnsafeResource& resource,
  32. const std::string& method,
  33. const net::HttpRequestHeaders& headers,
  34. bool is_main_frame,
  35. bool has_user_gesture) override;
  36. void StartObservingInteractionsForDelayedBlockingPageHelper(
  37. const security_interstitials::UnsafeResource& resource,
  38. bool is_main_frame) override;
  39. bool IsUrlAllowlisted(const GURL& url) override;
  40. void SetPolicyAllowlistDomains(
  41. const std::vector<std::string>& allowlist_domains) override;
  42. bool ShouldSkipRequestCheck(const GURL& original_url,
  43. int frame_tree_node_id,
  44. int render_process_id,
  45. int render_frame_id,
  46. bool originated_from_service_worker) override;
  47. void NotifySuspiciousSiteDetected(
  48. const base::RepeatingCallback<content::WebContents*()>&
  49. web_contents_getter) override;
  50. const safe_browsing::SBThreatTypeSet& GetThreatTypes() override;
  51. safe_browsing::SafeBrowsingDatabaseManager* GetDatabaseManager() override;
  52. safe_browsing::BaseUIManager* GetUIManager() override;
  53. void StartDisplayingDefaultBlockingPage(
  54. const security_interstitials::UnsafeResource& resource);
  55. scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
  56. scoped_refptr<safe_browsing::SafeBrowsingUIManager> ui_manager_;
  57. safe_browsing::SBThreatTypeSet threat_types_;
  58. };
  59. } // namespace weblayer
  60. #endif // WEBLAYER_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_