| Index: android_webview/browser/aw_safe_browsing_resource_throttle.cc | 
| diff --git a/android_webview/browser/aw_safe_browsing_resource_throttle.cc b/android_webview/browser/aw_safe_browsing_resource_throttle.cc | 
| index b77c97d9b14174bbddb37d76e943a3b162ff7774..42db5899264abdddd976e6a5aab42a2d046c75ff 100644 | 
| --- a/android_webview/browser/aw_safe_browsing_resource_throttle.cc | 
| +++ b/android_webview/browser/aw_safe_browsing_resource_throttle.cc | 
| @@ -4,44 +4,80 @@ | 
|  | 
| #include "android_webview/browser/aw_safe_browsing_resource_throttle.h" | 
|  | 
| +#include <utility> | 
| + | 
| #include "android_webview/browser/aw_safe_browsing_ui_manager.h" | 
| #include "base/macros.h" | 
| -#include "components/safe_browsing/base_resource_throttle.h" | 
| +#include "base/memory/ptr_util.h" | 
| +#include "components/safe_browsing/base_ui_manager.h" | 
| +#include "components/safe_browsing/resource_throttle.h" | 
| #include "components/safe_browsing_db/database_manager.h" | 
| #include "components/security_interstitials/content/unsafe_resource.h" | 
| +#include "content/public/browser/browser_thread.h" | 
| #include "content/public/common/resource_type.h" | 
| #include "net/base/net_errors.h" | 
| #include "net/url_request/url_request.h" | 
|  | 
| namespace android_webview { | 
|  | 
| -// static | 
| -AwSafeBrowsingResourceThrottle* AwSafeBrowsingResourceThrottle::MaybeCreate( | 
| -    net::URLRequest* request, | 
| -    content::ResourceType resource_type, | 
| -    scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager, | 
| -    scoped_refptr<AwSafeBrowsingUIManager> ui_manager) { | 
| -  if (database_manager->IsSupported()) { | 
| -    return new AwSafeBrowsingResourceThrottle(request, resource_type, | 
| -                                              database_manager, ui_manager); | 
| +namespace { | 
| + | 
| +void StartDisplayingBlockingPageOnUIThread( | 
| +    scoped_refptr<safe_browsing::BaseUIManager> ui_manager, | 
| +    const security_interstitials::UnsafeResource& resource, | 
| +    base::OnceClosure cancel_on_io_thread) { | 
| +  content::WebContents* web_contents = resource.web_contents_getter.Run(); | 
| +  if (web_contents) { | 
| +    ui_manager->DisplayBlockingPage(resource); | 
| +    return; | 
| } | 
| -  return nullptr; | 
| + | 
| +  // Tab is gone or it's being prerendered. | 
| +  content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 
| +                                   std::move(cancel_on_io_thread)); | 
| } | 
|  | 
| -AwSafeBrowsingResourceThrottle::AwSafeBrowsingResourceThrottle( | 
| +class AwSafeBrowsingResourceThrottleDelegate final | 
| +    : public safe_browsing::ResourceThrottle::Delegate { | 
| + public: | 
| +  AwSafeBrowsingResourceThrottleDelegate() {} | 
| +  ~AwSafeBrowsingResourceThrottleDelegate() final {} | 
| + | 
| +  void MaybeDestroyPrerenderContents( | 
| +      const WebContentsGetter& web_contents_getter) final { | 
| +    // No prerender contents exist in the WebView, therefore none need to be | 
| +    // destroyed. | 
| +  } | 
| + | 
| +  void StartDisplayingBlockingPage( | 
| +      const security_interstitials::UnsafeResource& resource, | 
| +      scoped_refptr<safe_browsing::BaseUIManager> ui_manager, | 
| +      base::OnceClosure cancel_on_io_thread) final { | 
| +    content::BrowserThread::PostTask( | 
| +        content::BrowserThread::UI, FROM_HERE, | 
| +        base::BindOnce(&StartDisplayingBlockingPageOnUIThread, | 
| +                       std::move(ui_manager), resource, | 
| +                       std::move(cancel_on_io_thread))); | 
| +  } | 
| + | 
| + private: | 
| +  DISALLOW_COPY_AND_ASSIGN(AwSafeBrowsingResourceThrottleDelegate); | 
| +}; | 
| + | 
| +}  // namespace | 
| + | 
| +std::unique_ptr<content::ResourceThrottle> | 
| +MaybeCreateAwSafeBrowsingResourceThrottle( | 
| net::URLRequest* request, | 
| content::ResourceType resource_type, | 
| scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager, | 
| -    scoped_refptr<AwSafeBrowsingUIManager> ui_manager) | 
| -    : safe_browsing::BaseResourceThrottle(request, | 
| -                                          resource_type, | 
| -                                          database_manager, | 
| -                                          ui_manager) {} | 
| - | 
| -AwSafeBrowsingResourceThrottle::~AwSafeBrowsingResourceThrottle() {} | 
| +    scoped_refptr<AwSafeBrowsingUIManager> ui_manager) { | 
| +  if (!database_manager->IsSupported()) | 
| +    return nullptr; | 
|  | 
| -void AwSafeBrowsingResourceThrottle::CancelResourceLoad() { | 
| -  CancelWithError(net::ERR_FAILED); | 
| +  return base::MakeUnique<safe_browsing::ResourceThrottle>( | 
| +      request, resource_type, database_manager, ui_manager, | 
| +      base::MakeUnique<AwSafeBrowsingResourceThrottleDelegate>()); | 
| } | 
|  | 
| }  // namespace android_webview | 
|  |