weblayer_client_side_detection_service_delegate.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "weblayer/browser/safe_browsing/weblayer_client_side_detection_service_delegate.h"
  5. #include "components/prefs/pref_service.h"
  6. #include "components/safe_browsing/core/common/proto/csd.pb.h"
  7. #include "components/safe_browsing/core/common/utils.h"
  8. #include "components/unified_consent/pref_names.h"
  9. #include "content/public/browser/storage_partition.h"
  10. #include "weblayer/browser/browser_context_impl.h"
  11. #include "weblayer/browser/browser_process.h"
  12. #include "weblayer/browser/safe_browsing/safe_browsing_service.h"
  13. #include "weblayer/browser/safe_browsing/weblayer_user_population_helper.h"
  14. namespace weblayer {
  15. WebLayerClientSideDetectionServiceDelegate::
  16. WebLayerClientSideDetectionServiceDelegate(
  17. BrowserContextImpl* browser_context)
  18. : browser_context_(browser_context) {}
  19. WebLayerClientSideDetectionServiceDelegate::
  20. ~WebLayerClientSideDetectionServiceDelegate() = default;
  21. PrefService* WebLayerClientSideDetectionServiceDelegate::GetPrefs() {
  22. DCHECK(browser_context_);
  23. return browser_context_->pref_service();
  24. }
  25. scoped_refptr<network::SharedURLLoaderFactory>
  26. WebLayerClientSideDetectionServiceDelegate::GetURLLoaderFactory() {
  27. return browser_context_->GetDefaultStoragePartition()
  28. ->GetURLLoaderFactoryForBrowserProcess();
  29. }
  30. scoped_refptr<network::SharedURLLoaderFactory>
  31. WebLayerClientSideDetectionServiceDelegate::GetSafeBrowsingURLLoaderFactory() {
  32. SafeBrowsingService* sb_service =
  33. BrowserProcess::GetInstance()->GetSafeBrowsingService();
  34. return sb_service->GetURLLoaderFactory();
  35. }
  36. safe_browsing::ChromeUserPopulation
  37. WebLayerClientSideDetectionServiceDelegate::GetUserPopulation() {
  38. return GetUserPopulationForBrowserContext(browser_context_);
  39. }
  40. } // namespace weblayer