OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/loader/safe_browsing_resource_throttle.h" | 5 #include "chrome/browser/loader/safe_browsing_resource_throttle.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 AsWeakPtr(), ui_manager(), resource)); | 85 AsWeakPtr(), ui_manager(), resource)); |
86 } | 86 } |
87 | 87 |
88 // Static | 88 // Static |
89 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( | 89 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( |
90 const base::WeakPtr<safe_browsing::BaseResourceThrottle>& throttle, | 90 const base::WeakPtr<safe_browsing::BaseResourceThrottle>& throttle, |
91 scoped_refptr<BaseUIManager> ui_manager, | 91 scoped_refptr<BaseUIManager> ui_manager, |
92 const security_interstitials::UnsafeResource& resource) { | 92 const security_interstitials::UnsafeResource& resource) { |
93 content::WebContents* web_contents = resource.web_contents_getter.Run(); | 93 content::WebContents* web_contents = resource.web_contents_getter.Run(); |
94 if (web_contents) { | 94 if (web_contents) { |
95 // Once activated, the subresource filter will filter subresources, but is | 95 BaseResourceThrottle::NotifySubresourceFilterOfBlockedResource(resource); |
96 // triggered when the main frame document matches Safe Browsing blacklists. | |
97 if (!resource.is_subresource) { | |
98 using subresource_filter::ContentSubresourceFilterDriverFactory; | |
99 ContentSubresourceFilterDriverFactory* driver_factory = | |
100 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); | |
101 DCHECK(driver_factory); | |
102 | |
103 // For a redirect chain of A -> B -> C, the subresource filter expects C | |
104 // as the resource URL and [A, B] as redirect URLs. | |
105 std::vector<GURL> redirect_parent_urls; | |
106 if (!resource.redirect_urls.empty()) { | |
107 redirect_parent_urls.push_back(resource.original_url); | |
108 redirect_parent_urls.insert(redirect_parent_urls.end(), | |
109 resource.redirect_urls.begin(), | |
110 std::prev(resource.redirect_urls.end())); | |
111 } | |
112 | |
113 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( | |
114 resource.url, redirect_parent_urls, resource.threat_type, | |
115 resource.threat_metadata.threat_pattern_type); | |
116 } | |
117 | |
118 prerender::PrerenderContents* prerender_contents = | 96 prerender::PrerenderContents* prerender_contents = |
119 prerender::PrerenderContents::FromWebContents(web_contents); | 97 prerender::PrerenderContents::FromWebContents(web_contents); |
120 if (prerender_contents) { | 98 if (prerender_contents) { |
121 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); | 99 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); |
122 } else { | 100 } else { |
123 ui_manager->DisplayBlockingPage(resource); | 101 ui_manager->DisplayBlockingPage(resource); |
124 return; | 102 return; |
125 } | 103 } |
126 } | 104 } |
127 | 105 |
128 // Tab is gone or it's being prerendered. | 106 // Tab is gone or it's being prerendered. |
129 content::BrowserThread::PostTask( | 107 content::BrowserThread::PostTask( |
130 content::BrowserThread::IO, FROM_HERE, | 108 content::BrowserThread::IO, FROM_HERE, |
131 base::Bind(&SafeBrowsingResourceThrottle::Cancel, throttle)); | 109 base::Bind(&SafeBrowsingResourceThrottle::Cancel, throttle)); |
132 } | 110 } |
OLD | NEW |