| 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/safe_browsing/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 // static | 280 // static |
| 281 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() { | 281 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() { |
| 282 if (!factory_) | 282 if (!factory_) |
| 283 factory_ = g_safe_browsing_service_factory_impl.Pointer(); | 283 factory_ = g_safe_browsing_service_factory_impl.Pointer(); |
| 284 return factory_->CreateSafeBrowsingService(); | 284 return factory_->CreateSafeBrowsingService(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 SafeBrowsingService::SafeBrowsingService() | 287 SafeBrowsingService::SafeBrowsingService() |
| 288 : services_delegate_(ServicesDelegate::Create(this)), | 288 : services_delegate_(ServicesDelegate::Create(this)), |
| 289 enabled_(false), | |
| 290 enabled_by_prefs_(false), | 289 enabled_by_prefs_(false), |
| 291 enabled_v4_only_(safe_browsing::V4FeatureList::IsV4OnlyEnabled()) {} | 290 enabled_v4_only_(safe_browsing::V4FeatureList::IsV4OnlyEnabled()) {} |
| 292 | 291 |
| 293 SafeBrowsingService::~SafeBrowsingService() { | 292 SafeBrowsingService::~SafeBrowsingService() { |
| 294 // We should have already been shut down. If we're still enabled, then the | 293 // We should have already been shut down. If we're still enabled, then the |
| 295 // database isn't going to be closed properly, which could lead to corruption. | 294 // database isn't going to be closed properly, which could lead to corruption. |
| 296 DCHECK(!enabled_); | 295 DCHECK(!enabled_); |
| 297 } | 296 } |
| 298 | 297 |
| 299 void SafeBrowsingService::Initialize() { | 298 void SafeBrowsingService::Initialize() { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 return false; | 385 return false; |
| 387 #endif | 386 #endif |
| 388 } | 387 } |
| 389 | 388 |
| 390 scoped_refptr<net::URLRequestContextGetter> | 389 scoped_refptr<net::URLRequestContextGetter> |
| 391 SafeBrowsingService::url_request_context() { | 390 SafeBrowsingService::url_request_context() { |
| 392 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 391 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 393 return url_request_context_getter_; | 392 return url_request_context_getter_; |
| 394 } | 393 } |
| 395 | 394 |
| 395 // TODO(ntfschr): componentize this once BaseSafeBrowsingUIManager contains a |
| 396 // SafeBrowsingService |
| 396 const scoped_refptr<SafeBrowsingUIManager>& | 397 const scoped_refptr<SafeBrowsingUIManager>& |
| 397 SafeBrowsingService::ui_manager() const { | 398 SafeBrowsingService::ui_manager() const { |
| 398 return ui_manager_; | 399 return ui_manager_; |
| 399 } | 400 } |
| 400 | 401 |
| 401 const scoped_refptr<SafeBrowsingDatabaseManager>& | 402 const scoped_refptr<SafeBrowsingDatabaseManager>& |
| 402 SafeBrowsingService::database_manager() const { | 403 SafeBrowsingService::database_manager() const { |
| 403 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; | 404 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; |
| 404 } | 405 } |
| 405 | 406 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 TRACE_EVENT1("loader", "SafeBrowsingService::OnResourceRequest", "url", | 457 TRACE_EVENT1("loader", "SafeBrowsingService::OnResourceRequest", "url", |
| 457 request->url().spec()); | 458 request->url().spec()); |
| 458 | 459 |
| 459 ResourceRequestInfo info = ResourceRequestDetector::GetRequestInfo(request); | 460 ResourceRequestInfo info = ResourceRequestDetector::GetRequestInfo(request); |
| 460 BrowserThread::PostTask( | 461 BrowserThread::PostTask( |
| 461 BrowserThread::UI, FROM_HERE, | 462 BrowserThread::UI, FROM_HERE, |
| 462 base::Bind(&SafeBrowsingService::ProcessResourceRequest, this, info)); | 463 base::Bind(&SafeBrowsingService::ProcessResourceRequest, this, info)); |
| 463 #endif | 464 #endif |
| 464 } | 465 } |
| 465 | 466 |
| 467 // TODO(ntfschr): componentize this once BaseSafeBrowsingUIManager contains a |
| 468 // SafeBrowsingService |
| 466 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { | 469 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { |
| 467 return new SafeBrowsingUIManager(this); | 470 return new SafeBrowsingUIManager(this); |
| 468 } | 471 } |
| 469 | 472 |
| 470 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { | 473 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { |
| 471 #if defined(SAFE_BROWSING_DB_LOCAL) | 474 #if defined(SAFE_BROWSING_DB_LOCAL) |
| 472 return new LocalSafeBrowsingDatabaseManager(this); | 475 return new LocalSafeBrowsingDatabaseManager(this); |
| 473 #elif defined(SAFE_BROWSING_DB_REMOTE) | 476 #elif defined(SAFE_BROWSING_DB_REMOTE) |
| 474 return new RemoteSafeBrowsingDatabaseManager(); | 477 return new RemoteSafeBrowsingDatabaseManager(); |
| 475 #else | 478 #else |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 ping_manager()->ReportThreatDetails(report); | 743 ping_manager()->ReportThreatDetails(report); |
| 741 } | 744 } |
| 742 | 745 |
| 743 void SafeBrowsingService::ProcessResourceRequest( | 746 void SafeBrowsingService::ProcessResourceRequest( |
| 744 const ResourceRequestInfo& request) { | 747 const ResourceRequestInfo& request) { |
| 745 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 748 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 746 services_delegate_->ProcessResourceRequest(&request); | 749 services_delegate_->ProcessResourceRequest(&request); |
| 747 } | 750 } |
| 748 | 751 |
| 749 } // namespace safe_browsing | 752 } // namespace safe_browsing |
| OLD | NEW |