aw_safe_browsing_navigation_throttle.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_NAVIGATION_THROTTLE_H_
  5. #define ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_NAVIGATION_THROTTLE_H_
  6. #include "content/public/browser/navigation_throttle.h"
  7. #include <memory>
  8. namespace content {
  9. class NavigationHandle;
  10. } // namespace content
  11. namespace android_webview {
  12. // This throttle monitors failed requests in an outer-most main frame (i.e.
  13. // doesn't apply for fenced-frames or portals), and if a request failed due to
  14. // it being blocked by Safe Browsing, it creates and displays an interstitial.
  15. // For other kinds of loads, the interstitial is navigated at the same time the
  16. // load is canceled in BaseUIManager::DisplayBlockingPage
  17. //
  18. // This NavigationThrottle doesn't actually perform a SafeBrowsing check nor
  19. // block the navigation. That happens in SafeBrowsing's
  20. // BrowserURLLoaderThrottle and RendererURLLoaderThrottles and related code.
  21. // Those cause the navigation to fail which invokes this throttle to show the
  22. // interstitial.
  23. class AwSafeBrowsingNavigationThrottle : public content::NavigationThrottle {
  24. public:
  25. static std::unique_ptr<AwSafeBrowsingNavigationThrottle>
  26. MaybeCreateThrottleFor(content::NavigationHandle* handle);
  27. ~AwSafeBrowsingNavigationThrottle() override {}
  28. const char* GetNameForLogging() override;
  29. content::NavigationThrottle::ThrottleCheckResult WillFailRequest() override;
  30. private:
  31. explicit AwSafeBrowsingNavigationThrottle(content::NavigationHandle* handle);
  32. };
  33. } // namespace android_webview
  34. #endif // ANDROID_WEBVIEW_BROWSER_SAFE_BROWSING_AW_SAFE_BROWSING_NAVIGATION_THROTTLE_H_