OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/safe_browsing/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
41 #include "net/base/registry_controlled_domain.h" | 41 #include "net/base/registry_controlled_domain.h" |
42 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
43 | 43 |
44 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
45 #include "chrome/installer/util/browser_distribution.h" | 45 #include "chrome/installer/util/browser_distribution.h" |
46 #endif | 46 #endif |
47 | 47 |
48 using content::BrowserThread; | 48 using content::BrowserThread; |
| 49 using content::NavigationEntry; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 // The default URL prefix where browser fetches chunk updates, hashes, | 53 // The default URL prefix where browser fetches chunk updates, hashes, |
53 // and reports safe browsing hits. | 54 // and reports safe browsing hits. |
54 const char* const kSbDefaultInfoURLPrefix = | 55 const char* const kSbDefaultInfoURLPrefix = |
55 "http://safebrowsing.clients.google.com/safebrowsing"; | 56 "http://safebrowsing.clients.google.com/safebrowsing"; |
56 | 57 |
57 // The default URL prefix where browser fetches MAC client key and reports | 58 // The default URL prefix where browser fetches MAC client key and reports |
58 // malware details. | 59 // malware details. |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 BrowserThread::IO, FROM_HERE, | 1049 BrowserThread::IO, FROM_HERE, |
1049 base::Bind(&SafeBrowsingService::OnBlockingPageDone, | 1050 base::Bind(&SafeBrowsingService::OnBlockingPageDone, |
1050 this, resources, false)); | 1051 this, resources, false)); |
1051 return; | 1052 return; |
1052 } | 1053 } |
1053 | 1054 |
1054 if (resource.threat_type != SafeBrowsingService::SAFE && | 1055 if (resource.threat_type != SafeBrowsingService::SAFE && |
1055 CanReportStats()) { | 1056 CanReportStats()) { |
1056 GURL page_url = tab_contents->GetURL(); | 1057 GURL page_url = tab_contents->GetURL(); |
1057 GURL referrer_url; | 1058 GURL referrer_url; |
1058 content::NavigationEntry* entry = | 1059 NavigationEntry* entry = tab_contents->GetController().GetActiveEntry(); |
1059 tab_contents->GetController().GetActiveEntry(); | |
1060 if (entry) | 1060 if (entry) |
1061 referrer_url = entry->GetReferrer().url; | 1061 referrer_url = entry->GetReferrer().url; |
1062 | 1062 |
1063 // When the malicious url is on the main frame, and resource.original_url | 1063 // When the malicious url is on the main frame, and resource.original_url |
1064 // is not the same as the resource.url, that means we have a redirect from | 1064 // is not the same as the resource.url, that means we have a redirect from |
1065 // resource.original_url to resource.url. | 1065 // resource.original_url to resource.url. |
1066 // Also, at this point, page_url points to the _previous_ page that we | 1066 // Also, at this point, page_url points to the _previous_ page that we |
1067 // were on. We replace page_url with resource.original_url and referrer | 1067 // were on. We replace page_url with resource.original_url and referrer |
1068 // with page_url. | 1068 // with page_url. |
1069 if (!resource.is_subresource && | 1069 if (!resource.is_subresource && |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 Stop(); | 1354 Stop(); |
1355 | 1355 |
1356 if (csd_service_.get()) | 1356 if (csd_service_.get()) |
1357 csd_service_->SetEnabledAndRefreshState(enable); | 1357 csd_service_->SetEnabledAndRefreshState(enable); |
1358 if (download_service_.get()) { | 1358 if (download_service_.get()) { |
1359 download_service_->SetEnabled( | 1359 download_service_->SetEnabled( |
1360 enable && !CommandLine::ForCurrentProcess()->HasSwitch( | 1360 enable && !CommandLine::ForCurrentProcess()->HasSwitch( |
1361 switches::kDisableImprovedDownloadProtection)); | 1361 switches::kDisableImprovedDownloadProtection)); |
1362 } | 1362 } |
1363 } | 1363 } |
OLD | NEW |