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