Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
26 #include "chrome/browser/safe_browsing/protocol_manager.h" 26 #include "chrome/browser/safe_browsing/protocol_manager.h"
27 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 27 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
28 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 28 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
29 #include "chrome/browser/tab_contents/tab_util.h" 29 #include "chrome/browser/tab_contents/tab_util.h"
30 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
31 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
36 #include "content/browser/tab_contents/tab_contents.h"
37 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
38 #include "content/public/browser/navigation_entry.h" 37 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_types.h" 39 #include "content/public/browser/notification_types.h"
40 #include "content/public/browser/web_contents.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 using content::NavigationEntry;
50 using content::WebContents;
50 51
51 namespace { 52 namespace {
52 53
53 // The default URL prefix where browser fetches chunk updates, hashes, 54 // The default URL prefix where browser fetches chunk updates, hashes,
54 // and reports safe browsing hits. 55 // and reports safe browsing hits.
55 const char* const kSbDefaultInfoURLPrefix = 56 const char* const kSbDefaultInfoURLPrefix =
56 "http://safebrowsing.clients.google.com/safebrowsing"; 57 "http://safebrowsing.clients.google.com/safebrowsing";
57 58
58 // The default URL prefix where browser fetches MAC client key and reports 59 // The default URL prefix where browser fetches MAC client key and reports
59 // malware details. 60 // malware details.
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 // and domain. 1030 // and domain.
1030 if (IsWhitelisted(resource)) { 1031 if (IsWhitelisted(resource)) {
1031 BrowserThread::PostTask( 1032 BrowserThread::PostTask(
1032 BrowserThread::IO, FROM_HERE, 1033 BrowserThread::IO, FROM_HERE,
1033 base::Bind(&SafeBrowsingService::NotifyClientBlockingComplete, 1034 base::Bind(&SafeBrowsingService::NotifyClientBlockingComplete,
1034 this, resource.client, true)); 1035 this, resource.client, true));
1035 return; 1036 return;
1036 } 1037 }
1037 1038
1038 // The tab might have been closed. 1039 // The tab might have been closed.
1039 TabContents* tab_contents = 1040 WebContents* web_contents =
1040 tab_util::GetTabContentsByID(resource.render_process_host_id, 1041 tab_util::GetWebContentsByID(resource.render_process_host_id,
1041 resource.render_view_id); 1042 resource.render_view_id);
1042 1043
1043 if (!tab_contents) { 1044 if (!web_contents) {
1044 // The tab is gone and we did not have a chance at showing the interstitial. 1045 // The tab is gone and we did not have a chance at showing the interstitial.
1045 // Just act as if "Don't Proceed" were chosen. 1046 // Just act as if "Don't Proceed" were chosen.
1046 std::vector<UnsafeResource> resources; 1047 std::vector<UnsafeResource> resources;
1047 resources.push_back(resource); 1048 resources.push_back(resource);
1048 BrowserThread::PostTask( 1049 BrowserThread::PostTask(
1049 BrowserThread::IO, FROM_HERE, 1050 BrowserThread::IO, FROM_HERE,
1050 base::Bind(&SafeBrowsingService::OnBlockingPageDone, 1051 base::Bind(&SafeBrowsingService::OnBlockingPageDone,
1051 this, resources, false)); 1052 this, resources, false));
1052 return; 1053 return;
1053 } 1054 }
1054 1055
1055 if (resource.threat_type != SafeBrowsingService::SAFE && 1056 if (resource.threat_type != SafeBrowsingService::SAFE &&
1056 CanReportStats()) { 1057 CanReportStats()) {
1057 GURL page_url = tab_contents->GetURL(); 1058 GURL page_url = web_contents->GetURL();
1058 GURL referrer_url; 1059 GURL referrer_url;
1059 NavigationEntry* entry = tab_contents->GetController().GetActiveEntry(); 1060 NavigationEntry* entry = web_contents->GetController().GetActiveEntry();
1060 if (entry) 1061 if (entry)
1061 referrer_url = entry->GetReferrer().url; 1062 referrer_url = entry->GetReferrer().url;
1062 1063
1063 // When the malicious url is on the main frame, and resource.original_url 1064 // 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 1065 // is not the same as the resource.url, that means we have a redirect from
1065 // resource.original_url to resource.url. 1066 // resource.original_url to resource.url.
1066 // Also, at this point, page_url points to the _previous_ page that we 1067 // 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 1068 // were on. We replace page_url with resource.original_url and referrer
1068 // with page_url. 1069 // with page_url.
1069 if (!resource.is_subresource && 1070 if (!resource.is_subresource &&
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 Stop(); 1355 Stop();
1355 1356
1356 if (csd_service_.get()) 1357 if (csd_service_.get())
1357 csd_service_->SetEnabledAndRefreshState(enable); 1358 csd_service_->SetEnabledAndRefreshState(enable);
1358 if (download_service_.get()) { 1359 if (download_service_.get()) {
1359 download_service_->SetEnabled( 1360 download_service_->SetEnabled(
1360 enable && !CommandLine::ForCurrentProcess()->HasSwitch( 1361 enable && !CommandLine::ForCurrentProcess()->HasSwitch(
1361 switches::kDisableImprovedDownloadProtection)); 1362 switches::kDisableImprovedDownloadProtection));
1362 } 1363 }
1363 } 1364 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/malware_details_history.cc ('k') | chrome/browser/safe_browsing/safe_browsing_tab_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698