usb_chooser_context_factory.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2022 Microsoft, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
  5. #define ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
  6. #include <memory>
  7. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  8. namespace base {
  9. template <typename T>
  10. class NoDestructor;
  11. } // namespace base
  12. namespace electron {
  13. class UsbChooserContext;
  14. class UsbChooserContextFactory : public BrowserContextKeyedServiceFactory {
  15. public:
  16. static UsbChooserContext* GetForBrowserContext(
  17. content::BrowserContext* context);
  18. static UsbChooserContext* GetForBrowserContextIfExists(
  19. content::BrowserContext* context);
  20. static UsbChooserContextFactory* GetInstance();
  21. UsbChooserContextFactory(const UsbChooserContextFactory&) = delete;
  22. UsbChooserContextFactory& operator=(const UsbChooserContextFactory&) = delete;
  23. private:
  24. friend base::NoDestructor<UsbChooserContextFactory>;
  25. UsbChooserContextFactory();
  26. ~UsbChooserContextFactory() override;
  27. // BrowserContextKeyedServiceFactory methods:
  28. std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
  29. content::BrowserContext* profile) const override;
  30. };
  31. } // namespace electron
  32. #endif // ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_