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

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

Issue 2450993003: Componentize safe_browsing [1]: create component, move messages, constants and switches. (Closed)
Patch Set: fix compile Created 4 years 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
OLDNEW
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 11 matching lines...) Expand all
22 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
23 #include "base/threading/worker_pool.h" 23 #include "base/threading/worker_pool.h"
24 #include "base/trace_event/trace_event.h" 24 #include "base/trace_event/trace_event.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
27 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/profiles/profile_manager.h" 29 #include "chrome/browser/profiles/profile_manager.h"
30 #include "chrome/browser/safe_browsing/ping_manager.h" 30 #include "chrome/browser/safe_browsing/ping_manager.h"
31 #include "chrome/browser/safe_browsing/ui_manager.h" 31 #include "chrome/browser/safe_browsing/ui_manager.h"
32 #include "chrome/common/chrome_constants.h"
33 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
36 #include "chrome/common/safe_browsing/file_type_policies.h" 35 #include "chrome/common/safe_browsing/file_type_policies.h"
37 #include "chrome/common/url_constants.h"
38 #include "components/prefs/pref_change_registrar.h" 36 #include "components/prefs/pref_change_registrar.h"
39 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
38 #include "components/safe_browsing/common/safebrowsing_constants.h"
39 #include "components/safe_browsing/common/safebrowsing_switches.h"
40 #include "components/safe_browsing_db/database_manager.h" 40 #include "components/safe_browsing_db/database_manager.h"
41 #include "components/safe_browsing_db/safe_browsing_prefs.h" 41 #include "components/safe_browsing_db/safe_browsing_prefs.h"
42 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" 42 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h"
43 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h " 43 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h "
44 #include "content/public/browser/browser_thread.h" 44 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/cookie_store_factory.h" 45 #include "content/public/browser/cookie_store_factory.h"
46 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/resource_request_info.h" 47 #include "content/public/browser/resource_request_info.h"
48 #include "google_apis/google_api_keys.h" 48 #include "google_apis/google_api_keys.h"
49 #include "net/cookies/cookie_store.h" 49 #include "net/cookies/cookie_store.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // static 262 // static
263 base::FilePath SafeBrowsingService::GetCookieFilePathForTesting() { 263 base::FilePath SafeBrowsingService::GetCookieFilePathForTesting() {
264 return CookieFilePath(); 264 return CookieFilePath();
265 } 265 }
266 266
267 // static 267 // static
268 base::FilePath SafeBrowsingService::GetBaseFilename() { 268 base::FilePath SafeBrowsingService::GetBaseFilename() {
269 base::FilePath path; 269 base::FilePath path;
270 bool result = PathService::Get(chrome::DIR_USER_DATA, &path); 270 bool result = PathService::Get(chrome::DIR_USER_DATA, &path);
271 DCHECK(result); 271 DCHECK(result);
272 return path.Append(chrome::kSafeBrowsingBaseFilename); 272 return path.Append(safe_browsing::kSafeBrowsingBaseFilename);
273 } 273 }
274 274
275 275
276 // static 276 // static
277 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() { 277 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() {
278 if (!factory_) 278 if (!factory_)
279 factory_ = g_safe_browsing_service_factory_impl.Pointer(); 279 factory_ = g_safe_browsing_service_factory_impl.Pointer();
280 return factory_->CreateSafeBrowsingService(); 280 return factory_->CreateSafeBrowsingService();
281 } 281 }
282 282
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 RegisterVariationsSeedSignatureAnalysis(); 463 RegisterVariationsSeedSignatureAnalysis();
464 #endif 464 #endif
465 } 465 }
466 466
467 SafeBrowsingProtocolConfig SafeBrowsingService::GetProtocolConfig() const { 467 SafeBrowsingProtocolConfig SafeBrowsingService::GetProtocolConfig() const {
468 SafeBrowsingProtocolConfig config; 468 SafeBrowsingProtocolConfig config;
469 config.client_name = GetProtocolConfigClientName(); 469 config.client_name = GetProtocolConfigClientName();
470 470
471 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 471 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
472 config.disable_auto_update = 472 config.disable_auto_update =
473 cmdline->HasSwitch(switches::kSbDisableAutoUpdate) || 473 cmdline->HasSwitch(safe_browsing::switches::kSbDisableAutoUpdate) ||
474 cmdline->HasSwitch(switches::kDisableBackgroundNetworking); 474 cmdline->HasSwitch(::switches::kDisableBackgroundNetworking);
475 config.url_prefix = kSbDefaultURLPrefix; 475 config.url_prefix = kSbDefaultURLPrefix;
476 config.backup_connect_error_url_prefix = kSbBackupConnectErrorURLPrefix; 476 config.backup_connect_error_url_prefix = kSbBackupConnectErrorURLPrefix;
477 config.backup_http_error_url_prefix = kSbBackupHttpErrorURLPrefix; 477 config.backup_http_error_url_prefix = kSbBackupHttpErrorURLPrefix;
478 config.backup_network_error_url_prefix = kSbBackupNetworkErrorURLPrefix; 478 config.backup_network_error_url_prefix = kSbBackupNetworkErrorURLPrefix;
479 479
480 return config; 480 return config;
481 } 481 }
482 482
483 V4ProtocolConfig 483 V4ProtocolConfig
484 SafeBrowsingService::GetV4ProtocolConfig() const { 484 SafeBrowsingService::GetV4ProtocolConfig() const {
485 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 485 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
486 return V4ProtocolConfig( 486 return V4ProtocolConfig(
487 GetProtocolConfigClientName(), 487 GetProtocolConfigClientName(),
488 cmdline->HasSwitch(switches::kDisableBackgroundNetworking), 488 cmdline->HasSwitch(::switches::kDisableBackgroundNetworking),
489 google_apis::GetAPIKey(), SafeBrowsingProtocolManagerHelper::Version()); 489 google_apis::GetAPIKey(), SafeBrowsingProtocolManagerHelper::Version());
490 } 490 }
491 491
492 std::string SafeBrowsingService::GetProtocolConfigClientName() const { 492 std::string SafeBrowsingService::GetProtocolConfigClientName() const {
493 std::string client_name; 493 std::string client_name;
494 // On Windows, get the safe browsing client name from the browser 494 // On Windows, get the safe browsing client name from the browser
495 // distribution classes in installer util. These classes don't yet have 495 // distribution classes in installer util. These classes don't yet have
496 // an analog on non-Windows builds so just keep the name specified here. 496 // an analog on non-Windows builds so just keep the name specified here.
497 #if defined(OS_WIN) 497 #if defined(OS_WIN)
498 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 498 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 ping_manager()->ReportThreatDetails(report); 704 ping_manager()->ReportThreatDetails(report);
705 } 705 }
706 706
707 void SafeBrowsingService::ProcessResourceRequest( 707 void SafeBrowsingService::ProcessResourceRequest(
708 const ResourceRequestInfo& request) { 708 const ResourceRequestInfo& request) {
709 DCHECK_CURRENTLY_ON(BrowserThread::UI); 709 DCHECK_CURRENTLY_ON(BrowserThread::UI);
710 services_delegate_->ProcessResourceRequest(&request); 710 services_delegate_->ProcessResourceRequest(&request);
711 } 711 }
712 712
713 } // namespace safe_browsing 713 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698