OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
6 // anti-malware tables and checking urls against them. This is android_webview | 6 // anti-malware tables and checking urls against them. This is android_webview |
7 // specific ui_manager. | 7 // specific ui_manager. |
8 | 8 |
9 #ifndef ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ | 9 #ifndef ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ |
10 #define ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ | 10 #define ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ |
11 | 11 |
12 #include "components/safe_browsing/base_ui_manager.h" | 12 #include "components/safe_browsing/base_ui_manager.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 | 14 |
| 15 namespace safe_browsing { |
| 16 class BasePingManager; |
| 17 class SafeBrowsingURLRequestContextGetter; |
| 18 } // namespace |
| 19 |
15 namespace android_webview { | 20 namespace android_webview { |
| 21 class AwURLRequestContextGetter; |
16 | 22 |
17 class AwSafeBrowsingUIManager : public safe_browsing::BaseUIManager { | 23 class AwSafeBrowsingUIManager : public safe_browsing::BaseUIManager { |
18 public: | 24 public: |
19 class UIManagerClient { | 25 class UIManagerClient { |
20 public: | 26 public: |
21 static UIManagerClient* FromWebContents(content::WebContents* web_contents); | 27 static UIManagerClient* FromWebContents(content::WebContents* web_contents); |
22 | 28 |
23 // Whether this web contents can show any sort of interstitial | 29 // Whether this web contents can show any sort of interstitial |
24 virtual bool CanShowInterstitial() = 0; | 30 virtual bool CanShowInterstitial() = 0; |
25 | 31 |
26 // Returns the appropriate BaseBlockingPage::ErrorUiType | 32 // Returns the appropriate BaseBlockingPage::ErrorUiType |
27 virtual int GetErrorUiType() = 0; | 33 virtual int GetErrorUiType() = 0; |
28 }; | 34 }; |
29 | 35 |
30 // Construction needs to happen on the UI thread. | 36 // Construction needs to happen on the UI thread. |
31 AwSafeBrowsingUIManager(); | 37 explicit AwSafeBrowsingUIManager( |
32 | 38 AwURLRequestContextGetter* browser_url_request_context_getter); |
33 void DisplayBlockingPage(const UnsafeResource& resource) override; | |
34 | 39 |
35 // Gets the correct ErrorUiType for the web contents | 40 // Gets the correct ErrorUiType for the web contents |
36 int GetErrorUiType(const UnsafeResource& resource) const; | 41 int GetErrorUiType(const UnsafeResource& resource) const; |
37 | 42 |
| 43 // BaseUIManager methods: |
| 44 void DisplayBlockingPage(const UnsafeResource& resource) override; |
| 45 |
| 46 // Called on the IO thread by the ThreatDetails with the serialized |
| 47 // protocol buffer, so the service can send it over. |
| 48 void SendSerializedThreatDetails(const std::string& serialized) override; |
| 49 |
38 protected: | 50 protected: |
39 ~AwSafeBrowsingUIManager() override; | 51 ~AwSafeBrowsingUIManager() override; |
40 | 52 |
41 void ShowBlockingPageForResource(const UnsafeResource& resource) override; | 53 void ShowBlockingPageForResource(const UnsafeResource& resource) override; |
42 | 54 |
43 private: | 55 private: |
| 56 // Provides phishing and malware statistics. Accessed on IO thread. |
| 57 std::unique_ptr<safe_browsing::BasePingManager> ping_manager_; |
| 58 |
| 59 // The SafeBrowsingURLRequestContextGetter used to access |
| 60 // |url_request_context_|. Accessed on UI thread. |
| 61 scoped_refptr<safe_browsing::SafeBrowsingURLRequestContextGetter> |
| 62 url_request_context_getter_; |
| 63 |
44 DISALLOW_COPY_AND_ASSIGN(AwSafeBrowsingUIManager); | 64 DISALLOW_COPY_AND_ASSIGN(AwSafeBrowsingUIManager); |
45 }; | 65 }; |
46 | 66 |
47 } // namespace android_webview | 67 } // namespace android_webview |
48 | 68 |
49 #endif // ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ | 69 #endif // ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_UI_MANAGER_H_ |
OLD | NEW |