OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/ui/webui/interstitials/interstitial_ui.h" | 5 #include "chrome/browser/ui/webui/interstitials/interstitial_ui.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 int options_mask = 0; | 167 int options_mask = 0; |
168 if (overridable) | 168 if (overridable) |
169 options_mask |= SSLBlockingPage::OVERRIDABLE; | 169 options_mask |= SSLBlockingPage::OVERRIDABLE; |
170 if (strict_enforcement) | 170 if (strict_enforcement) |
171 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; | 171 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; |
172 return new BadClockBlockingPage(web_contents, cert_error, ssl_info, | 172 return new BadClockBlockingPage(web_contents, cert_error, ssl_info, |
173 request_url, time_triggered_, nullptr, | 173 request_url, time_triggered_, nullptr, |
174 base::Callback<void(bool)>()); | 174 base::Callback<void(bool)>()); |
175 } | 175 } |
176 | 176 |
177 SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( | 177 safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( |
178 content::WebContents* web_contents) { | 178 content::WebContents* web_contents) { |
179 SBThreatType threat_type = SB_THREAT_TYPE_URL_MALWARE; | 179 safe_browsing::SBThreatType threat_type = |
| 180 safe_browsing::SB_THREAT_TYPE_URL_MALWARE; |
180 GURL request_url("http://example.com"); | 181 GURL request_url("http://example.com"); |
181 std::string url_param; | 182 std::string url_param; |
182 if (net::GetValueForKeyInQuery(web_contents->GetURL(), | 183 if (net::GetValueForKeyInQuery(web_contents->GetURL(), |
183 "url", | 184 "url", |
184 &url_param)) { | 185 &url_param)) { |
185 if (GURL(url_param).is_valid()) | 186 if (GURL(url_param).is_valid()) |
186 request_url = GURL(url_param); | 187 request_url = GURL(url_param); |
187 } | 188 } |
188 std::string type_param; | 189 std::string type_param; |
189 if (net::GetValueForKeyInQuery(web_contents->GetURL(), | 190 if (net::GetValueForKeyInQuery(web_contents->GetURL(), |
190 "type", | 191 "type", |
191 &type_param)) { | 192 &type_param)) { |
192 if (type_param == "malware") { | 193 if (type_param == "malware") { |
193 threat_type = SB_THREAT_TYPE_URL_MALWARE; | 194 threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE; |
194 } else if (type_param == "phishing") { | 195 } else if (type_param == "phishing") { |
195 threat_type = SB_THREAT_TYPE_URL_PHISHING; | 196 threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING; |
196 } else if (type_param == "clientside_malware") { | 197 } else if (type_param == "clientside_malware") { |
197 threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; | 198 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; |
198 } else if (type_param == "clientside_phishing") { | 199 } else if (type_param == "clientside_phishing") { |
199 threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; | 200 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; |
200 // Interstitials for client side phishing urls load after the page loads | 201 // Interstitials for client side phishing urls load after the page loads |
201 // (see SafeBrowsingBlockingPage::IsMainPageLoadBlocked), so there should | 202 // (see SafeBrowsingBlockingPage::IsMainPageLoadBlocked), so there should |
202 // either be a new navigation entry, or there shouldn't be any pending | 203 // either be a new navigation entry, or there shouldn't be any pending |
203 // entries. Clear any pending navigation entries. | 204 // entries. Clear any pending navigation entries. |
204 content::NavigationController* controller = | 205 content::NavigationController* controller = |
205 &web_contents->GetController(); | 206 &web_contents->GetController(); |
206 controller->DiscardNonCommittedEntries(); | 207 controller->DiscardNonCommittedEntries(); |
207 } | 208 } |
208 } | 209 } |
209 SafeBrowsingBlockingPage::UnsafeResource resource; | 210 safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource; |
210 resource.url = request_url; | 211 resource.url = request_url; |
211 resource.threat_type = threat_type; | 212 resource.threat_type = threat_type; |
212 // Create a blocking page without showing the interstitial. | 213 // Create a blocking page without showing the interstitial. |
213 return SafeBrowsingBlockingPage::CreateBlockingPage( | 214 return safe_browsing::SafeBrowsingBlockingPage::CreateBlockingPage( |
214 g_browser_process->safe_browsing_service()->ui_manager().get(), | 215 g_browser_process->safe_browsing_service()->ui_manager().get(), |
215 web_contents, | 216 web_contents, |
216 resource); | 217 resource); |
217 } | 218 } |
218 | 219 |
219 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 220 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
220 CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( | 221 CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( |
221 content::WebContents* web_contents) { | 222 content::WebContents* web_contents) { |
222 bool is_wifi_connection = false; | 223 bool is_wifi_connection = false; |
223 GURL landing_url("https://captive.portal/login"); | 224 GURL landing_url("https://captive.portal/login"); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 html = interstitial_delegate.get()->GetHTMLContents(); | 323 html = interstitial_delegate.get()->GetHTMLContents(); |
323 } else { | 324 } else { |
324 html = ResourceBundle::GetSharedInstance() | 325 html = ResourceBundle::GetSharedInstance() |
325 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 326 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
326 .as_string(); | 327 .as_string(); |
327 } | 328 } |
328 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 329 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
329 html_bytes->data().assign(html.begin(), html.end()); | 330 html_bytes->data().assign(html.begin(), html.end()); |
330 callback.Run(html_bytes.get()); | 331 callback.Run(html_bytes.get()); |
331 } | 332 } |
OLD | NEW |