OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Classes for managing the SafeBrowsing interstitial pages. | 5 // Classes for managing the SafeBrowsing interstitial pages. |
6 // | 6 // |
7 // When a user is about to visit a page the SafeBrowsing system has deemed to | 7 // When a user is about to visit a page the SafeBrowsing system has deemed to |
8 // be malicious, either as malware or a phishing page, we show an interstitial | 8 // be malicious, either as malware or a phishing page, we show an interstitial |
9 // page with some options (go back, continue) to give the user a chance to avoid | 9 // page with some options (go back, continue) to give the user a chance to avoid |
10 // the harmful page. | 10 // the harmful page. |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include <map> | 32 #include <map> |
33 #include <vector> | 33 #include <vector> |
34 | 34 |
35 #include "chrome/browser/tab_contents/interstitial_page.h" | 35 #include "chrome/browser/tab_contents/interstitial_page.h" |
36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
37 #include "googleurl/src/gurl.h" | 37 #include "googleurl/src/gurl.h" |
38 | 38 |
39 class DictionaryValue; | 39 class DictionaryValue; |
40 class MessageLoop; | 40 class MessageLoop; |
41 class SafeBrowsingBlockingPageFactory; | 41 class SafeBrowsingBlockingPageFactory; |
| 42 class MalwareDetails; |
42 class TabContents; | 43 class TabContents; |
43 | 44 |
44 class SafeBrowsingBlockingPage : public InterstitialPage { | 45 class SafeBrowsingBlockingPage : public InterstitialPage { |
45 public: | 46 public: |
46 virtual ~SafeBrowsingBlockingPage(); | 47 virtual ~SafeBrowsingBlockingPage(); |
47 | 48 |
48 // Shows a blocking page warning the user about phishing/malware for a | 49 // Shows a blocking page warning the user about phishing/malware for a |
49 // specific resource. | 50 // specific resource. |
50 // You can call this method several times, if an interstitial is already | 51 // You can call this method several times, if an interstitial is already |
51 // showing, the new one will be queued and displayed if the user decides | 52 // showing, the new one will be queued and displayed if the user decides |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const std::wstring& title, | 98 const std::wstring& title, |
98 const std::wstring& headline, | 99 const std::wstring& headline, |
99 const std::wstring& description1, | 100 const std::wstring& description1, |
100 const std::wstring& description2, | 101 const std::wstring& description2, |
101 const std::wstring& description3); | 102 const std::wstring& description3); |
102 | 103 |
103 // Records a user action for this interstitial, using the form | 104 // Records a user action for this interstitial, using the form |
104 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. | 105 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. |
105 void RecordUserAction(BlockingPageEvent event); | 106 void RecordUserAction(BlockingPageEvent event); |
106 | 107 |
| 108 // See if we should even show the malware details option. For example, we |
| 109 // don't show it in incognito mode. |
| 110 bool CanShowMalwareDetailsOption(); |
| 111 |
| 112 // Called when the insterstitial is going away. If there is a |
| 113 // pending malware details object, we look at the user's |
| 114 // preferences, and if the option to send malware details is |
| 115 // enabled, the report is scheduled to be sent on the |sb_service_|. |
| 116 void FinishMalwareDetails(); |
| 117 |
107 // A list of SafeBrowsingService::UnsafeResource for a tab that the user | 118 // A list of SafeBrowsingService::UnsafeResource for a tab that the user |
108 // should be warned about. They are queued when displaying more than one | 119 // should be warned about. They are queued when displaying more than one |
109 // interstitial at a time. | 120 // interstitial at a time. |
110 typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap; | 121 typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap; |
111 static UnsafeResourceMap* GetUnsafeResourcesMap(); | 122 static UnsafeResourceMap* GetUnsafeResourcesMap(); |
112 | 123 |
113 // Notifies the SafeBrowsingService on the IO thread whether to proceed or not | 124 // Notifies the SafeBrowsingService on the IO thread whether to proceed or not |
114 // for the |resources|. | 125 // for the |resources|. |
115 static void NotifySafeBrowsingService(SafeBrowsingService* sb_service, | 126 static void NotifySafeBrowsingService(SafeBrowsingService* sb_service, |
116 const UnsafeResourceList& resources, | 127 const UnsafeResourceList& resources, |
(...skipping 12 matching lines...) Expand all Loading... |
129 // Whether the flagged resource is the main page (or a sub-resource is false). | 140 // Whether the flagged resource is the main page (or a sub-resource is false). |
130 bool is_main_frame_; | 141 bool is_main_frame_; |
131 | 142 |
132 // The index of a navigation entry that should be removed when DontProceed() | 143 // The index of a navigation entry that should be removed when DontProceed() |
133 // is invoked, -1 if not entry should be removed. | 144 // is invoked, -1 if not entry should be removed. |
134 int navigation_entry_index_to_remove_; | 145 int navigation_entry_index_to_remove_; |
135 | 146 |
136 // The list of unsafe resources this page is warning about. | 147 // The list of unsafe resources this page is warning about. |
137 UnsafeResourceList unsafe_resources_; | 148 UnsafeResourceList unsafe_resources_; |
138 | 149 |
| 150 // A MalwareDetails object that we start generating when the |
| 151 // blocking page is shown. The object will be sent when the warning |
| 152 // is gone (if the user enables the feature). |
| 153 scoped_refptr<MalwareDetails> malware_details_; |
| 154 |
139 // The factory used to instanciate SafeBrowsingBlockingPage objects. | 155 // The factory used to instanciate SafeBrowsingBlockingPage objects. |
140 // Usefull for tests, so they can provide their own implementation of | 156 // Usefull for tests, so they can provide their own implementation of |
141 // SafeBrowsingBlockingPage. | 157 // SafeBrowsingBlockingPage. |
142 static SafeBrowsingBlockingPageFactory* factory_; | 158 static SafeBrowsingBlockingPageFactory* factory_; |
143 | 159 |
144 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 160 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
145 }; | 161 }; |
146 | 162 |
147 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 163 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
148 class SafeBrowsingBlockingPageFactory { | 164 class SafeBrowsingBlockingPageFactory { |
149 public: | 165 public: |
150 virtual ~SafeBrowsingBlockingPageFactory() { } | 166 virtual ~SafeBrowsingBlockingPageFactory() { } |
151 | 167 |
152 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 168 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
153 SafeBrowsingService* service, | 169 SafeBrowsingService* service, |
154 TabContents* tab_contents, | 170 TabContents* tab_contents, |
155 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 171 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
156 }; | 172 }; |
157 | 173 |
158 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 174 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
OLD | NEW |