| 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/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 15 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 15 #include "chrome/browser/ssl/bad_clock_blocking_page.h" | 16 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 16 #include "chrome/browser/ssl/ssl_blocking_page.h" | 17 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/browser_resources.h" | 19 #include "chrome/grit/browser_resources.h" |
| 19 #include "components/grit/components_resources.h" | 20 #include "components/grit/components_resources.h" |
| 20 #include "components/security_interstitials/core/ssl_error_ui.h" | 21 #include "components/security_interstitials/core/ssl_error_ui.h" |
| 21 #include "content/public/browser/interstitial_page_delegate.h" | 22 #include "content/public/browser/interstitial_page_delegate.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/url_data_source.h" | 25 #include "content/public/browser/url_data_source.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; | 237 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; |
| 237 } else if (type_param == "clientside_phishing") { | 238 } else if (type_param == "clientside_phishing") { |
| 238 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; | 239 threat_type = safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; |
| 239 } | 240 } |
| 240 } | 241 } |
| 241 safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource; | 242 safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource; |
| 242 resource.url = request_url; | 243 resource.url = request_url; |
| 243 resource.is_subresource = request_url != main_frame_url; | 244 resource.is_subresource = request_url != main_frame_url; |
| 244 resource.is_subframe = false; | 245 resource.is_subframe = false; |
| 245 resource.threat_type = threat_type; | 246 resource.threat_type = threat_type; |
| 246 resource.render_process_host_id = | 247 resource.web_contents_getter = |
| 247 web_contents->GetRenderProcessHost()->GetID(); | 248 safe_browsing::SafeBrowsingUIManager::UnsafeResource:: |
| 248 resource.render_frame_id = web_contents->GetMainFrame()->GetRoutingID(); | 249 GetWebContentsGetter(web_contents->GetRenderProcessHost()->GetID(), |
| 250 web_contents->GetMainFrame()->GetRoutingID()); |
| 249 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; | 251 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; |
| 250 | 252 |
| 251 // Normally safebrowsing interstitial types which block the main page load | 253 // Normally safebrowsing interstitial types which block the main page load |
| 252 // (SB_THREAT_TYPE_URL_MALWARE, SB_THREAT_TYPE_URL_PHISHING, and | 254 // (SB_THREAT_TYPE_URL_MALWARE, SB_THREAT_TYPE_URL_PHISHING, and |
| 253 // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a | 255 // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a |
| 254 // pending navigation when the SafeBrowsingBlockingPage is created. This demo | 256 // pending navigation when the SafeBrowsingBlockingPage is created. This demo |
| 255 // creates a SafeBrowsingBlockingPage but does not actually show a real | 257 // creates a SafeBrowsingBlockingPage but does not actually show a real |
| 256 // interstitial. Instead it extracts the html and displays it manually, so the | 258 // interstitial. Instead it extracts the html and displays it manually, so the |
| 257 // parts which depend on the NavigationEntry are not hit. | 259 // parts which depend on the NavigationEntry are not hit. |
| 258 return safe_browsing::SafeBrowsingBlockingPage::CreateBlockingPage( | 260 return safe_browsing::SafeBrowsingBlockingPage::CreateBlockingPage( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 html = interstitial_delegate.get()->GetHTMLContents(); | 376 html = interstitial_delegate.get()->GetHTMLContents(); |
| 375 } else { | 377 } else { |
| 376 html = ResourceBundle::GetSharedInstance() | 378 html = ResourceBundle::GetSharedInstance() |
| 377 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 379 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
| 378 .as_string(); | 380 .as_string(); |
| 379 } | 381 } |
| 380 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 382 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
| 381 html_bytes->data().assign(html.begin(), html.end()); | 383 html_bytes->data().assign(html.begin(), html.end()); |
| 382 callback.Run(html_bytes.get()); | 384 callback.Run(html_bytes.get()); |
| 383 } | 385 } |
| OLD | NEW |