weblayer_ping_manager_factory.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2022 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. #ifndef WEBLAYER_BROWSER_SAFE_BROWSING_WEBLAYER_PING_MANAGER_FACTORY_H_
  5. #define WEBLAYER_BROWSER_SAFE_BROWSING_WEBLAYER_PING_MANAGER_FACTORY_H_
  6. #include "base/no_destructor.h"
  7. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  8. #include "components/safe_browsing/core/browser/ping_manager.h"
  9. namespace weblayer {
  10. // Factory for creating the KeyedService PingManager for WebLayer. It returns
  11. // null for incognito mode.
  12. class WebLayerPingManagerFactory : public BrowserContextKeyedServiceFactory {
  13. public:
  14. static WebLayerPingManagerFactory* GetInstance();
  15. static safe_browsing::PingManager* GetForBrowserContext(
  16. content::BrowserContext* context);
  17. // TODO(crbug.com/1171215): Remove this once browsertests can enable this
  18. // functionality via the production mechanism for doing so.
  19. void SignInAccountForTesting();
  20. private:
  21. friend class base::NoDestructor<WebLayerPingManagerFactory>;
  22. WebLayerPingManagerFactory();
  23. ~WebLayerPingManagerFactory() override;
  24. // BrowserContextKeyedServiceFactory override:
  25. KeyedService* BuildServiceInstanceFor(
  26. content::BrowserContext* context) const override;
  27. bool ShouldFetchAccessTokenForReport(content::BrowserContext* context) const;
  28. std::string GetProtocolConfigClientName() const;
  29. // TODO(crbug.com/1171215): Remove this once browsertests can enable this
  30. // functionality via the production mechanism for doing so.
  31. bool is_account_signed_in_for_testing_ = false;
  32. };
  33. } // namespace weblayer
  34. #endif // WEBLAYER_BROWSER_SAFE_BROWSING_WEBLAYER_PING_MANAGER_FACTORY_H_