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

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

Issue 56135: Adding unit tests for the SafeBrowsingBlockingPage class (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 5
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void SafeBrowsingService::DoDisplayBlockingPage( 257 void SafeBrowsingService::DoDisplayBlockingPage(
258 const UnsafeResource& resource) { 258 const UnsafeResource& resource) {
259 // The tab might have been closed. 259 // The tab might have been closed.
260 WebContents* wc = 260 WebContents* wc =
261 tab_util::GetWebContentsByID(resource.render_process_host_id, 261 tab_util::GetWebContentsByID(resource.render_process_host_id,
262 resource.render_view_id); 262 resource.render_view_id);
263 263
264 if (!wc) { 264 if (!wc) {
265 // The tab is gone and we did not have a chance at showing the interstitial. 265 // The tab is gone and we did not have a chance at showing the interstitial.
266 // Just act as "Don't Proceed" was chosen. 266 // Just act as "Don't Proceed" was chosen.
267 base::Thread* io_thread = g_browser_process->io_thread();
268 if (!io_thread)
269 return;
270 std::vector<UnsafeResource> resources; 267 std::vector<UnsafeResource> resources;
271 resources.push_back(resource); 268 resources.push_back(resource);
272 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 269 MessageLoop* message_loop;
270 if (g_browser_process->io_thread())
271 message_loop = g_browser_process->io_thread()->message_loop();
272 else // For unit-tests, just post on the current thread.
273 message_loop = MessageLoop::current();
274 message_loop->PostTask(FROM_HERE, NewRunnableMethod(
273 this, &SafeBrowsingService::OnBlockingPageDone, resources, false)); 275 this, &SafeBrowsingService::OnBlockingPageDone, resources, false));
274 return; 276 return;
275 } 277 }
276 278
277 // Report the malware sub-resource to the SafeBrowsing servers if we have a 279 // Report the malware sub-resource to the SafeBrowsing servers if we have a
278 // malware sub-resource on a safe page and only if the user has opted in to 280 // malware sub-resource on a safe page and only if the user has opted in to
279 // reporting statistics. 281 // reporting statistics.
280 PrefService* prefs = g_browser_process->local_state(); 282 PrefService* prefs = g_browser_process->local_state();
281 DCHECK(prefs); 283 DCHECK(prefs);
282 if (prefs && prefs->GetBoolean(prefs::kMetricsReportingEnabled) && 284 if (prefs && prefs->GetBoolean(prefs::kMetricsReportingEnabled) &&
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // report if it's not there. 731 // report if it's not there.
730 std::string list; 732 std::string list;
731 std::vector<SBPrefix> prefix_hits; 733 std::vector<SBPrefix> prefix_hits;
732 std::vector<SBFullHashResult> full_hits; 734 std::vector<SBFullHashResult> full_hits;
733 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits, 735 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits,
734 protocol_manager_->last_update()); 736 protocol_manager_->last_update());
735 737
736 if (full_hits.empty()) 738 if (full_hits.empty())
737 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url); 739 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url);
738 } 740 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/tab_contents/interstitial_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698