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 5 #ifndef IOS_CHROME_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_ 6 #define IOS_CHROME_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "components/safe_browsing/core/browser/url_checker_delegate.h" 10 11 namespace safe_browsing { 12 class SafeBrowsingDatabaseManager; 13 } // namespace safe_browsing 14 15 // This is an iOS implementation of the delegate interface for 16 // SafeBrowsingUrlCheckerImpl. 17 class UrlCheckerDelegateImpl : public safe_browsing::UrlCheckerDelegate { 18 public: 19 UrlCheckerDelegateImpl( 20 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> 21 database_manager); 22 23 UrlCheckerDelegateImpl(const UrlCheckerDelegateImpl&) = delete; 24 UrlCheckerDelegateImpl& operator=(const UrlCheckerDelegateImpl&) = delete; 25 26 private: 27 ~UrlCheckerDelegateImpl() override; 28 29 // safe_browsing::UrlCheckerDelegate implementation 30 void MaybeDestroyPrerenderContents( 31 base::OnceCallback<content::WebContents*()> web_contents_getter) override; 32 void StartDisplayingBlockingPageHelper( 33 const security_interstitials::UnsafeResource& resource, 34 const std::string& method, 35 const net::HttpRequestHeaders& headers, 36 bool is_main_frame, 37 bool has_user_gesture) override; 38 void StartObservingInteractionsForDelayedBlockingPageHelper( 39 const security_interstitials::UnsafeResource& resource, 40 bool is_main_frame) override; 41 bool IsUrlAllowlisted(const GURL& url) 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 48 // This function is unused on iOS, since iOS cannot use content/. 49 // TODO(crbug.com/1069047): Refactor SafeBrowsingUrlCheckerImpl and 50 // UrlCheckerDelegate to extract the functionality that can be shared across 51 // platforms, and move methods used only by content/ to classes used only by 52 // content/. 53 void NotifySuspiciousSiteDetected( 54 const base::RepeatingCallback<content::WebContents*()>& 55 web_contents_getter) override; 56 const safe_browsing::SBThreatTypeSet& GetThreatTypes() override; 57 safe_browsing::SafeBrowsingDatabaseManager* GetDatabaseManager() override; 58 safe_browsing::BaseUIManager* GetUIManager() override; 59 60 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_; 61 safe_browsing::SBThreatTypeSet threat_types_; 62 }; 63 64 #endif // IOS_CHROME_BROWSER_SAFE_BROWSING_URL_CHECKER_DELEGATE_IMPL_H_ 65