aw_safe_browsing_blocking_page.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2017 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 ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_BLOCKING_PAGE_H_
  5. #define ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_BLOCKING_PAGE_H_
  6. #include <memory>
  7. #include "android_webview/browser/network_service/aw_web_resource_request.h"
  8. #include "components/safe_browsing/content/browser/base_blocking_page.h"
  9. #include "components/security_interstitials/core/base_safe_browsing_error_ui.h"
  10. namespace security_interstitials {
  11. struct UnsafeResource;
  12. } // namespace security_interstitials
  13. namespace content {
  14. class WebContents;
  15. } // namespace content
  16. namespace android_webview {
  17. class AwSafeBrowsingUIManager;
  18. class AwSafeBrowsingBlockingPage : public safe_browsing::BaseBlockingPage {
  19. public:
  20. typedef security_interstitials::UnsafeResource UnsafeResource;
  21. static AwSafeBrowsingBlockingPage* CreateBlockingPage(
  22. AwSafeBrowsingUIManager* ui_manager,
  23. content::WebContents* web_contents,
  24. const GURL& main_frame_url,
  25. const UnsafeResource& unsafe_resource,
  26. std::unique_ptr<AwWebResourceRequest> resource_request);
  27. ~AwSafeBrowsingBlockingPage() override;
  28. // safe_browsing::BaseBlockingPage:
  29. void CreatedPostCommitErrorPageNavigation(
  30. content::NavigationHandle* error_page_navigation_handle) override;
  31. protected:
  32. // Used to specify which BaseSafeBrowsingErrorUI to instantiate, and
  33. // parameters they require.
  34. // Note: these values are persisted in UMA logs, so they should never be
  35. // renumbered or reused.
  36. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.android_webview
  37. enum class ErrorUiType { LOUD, QUIET_SMALL, QUIET_GIANT, COUNT };
  38. // Don't instantiate this class directly, use ShowBlockingPage instead.
  39. AwSafeBrowsingBlockingPage(
  40. AwSafeBrowsingUIManager* ui_manager,
  41. content::WebContents* web_contents,
  42. const GURL& main_frame_url,
  43. const UnsafeResourceList& unsafe_resources,
  44. std::unique_ptr<
  45. security_interstitials::SecurityInterstitialControllerClient>
  46. controller_client,
  47. const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options,
  48. ErrorUiType errorUiType,
  49. std::unique_ptr<AwWebResourceRequest> resource_request);
  50. // Called when the interstitial is going away. If there is a
  51. // pending threat details object, we look at the user's
  52. // preferences, and if the option to send threat details is
  53. // enabled, the report is scheduled to be sent on the |ui_manager_|.
  54. void FinishThreatDetails(const base::TimeDelta& delay,
  55. bool did_proceed,
  56. int num_visits) override;
  57. void OnInterstitialClosing() override;
  58. // Whether ThreatDetails collection is in progress as part of this
  59. // interstitial.
  60. bool threat_details_in_progress_;
  61. // Holds a copy of the resource request that triggered this blocking page,
  62. // only used with committed interstitials.
  63. std::unique_ptr<AwWebResourceRequest> resource_request_;
  64. };
  65. } // namespace android_webview
  66. #endif // ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_BLOCKING_PAGE_H_