background_fetch_permission_context.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 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_BACKGROUND_FETCH_BACKGROUND_FETCH_PERMISSION_CONTEXT_H_
  5. #define WEBLAYER_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_PERMISSION_CONTEXT_H_
  6. #include "components/content_settings/core/common/content_settings.h"
  7. #include "components/permissions/permission_context_base.h"
  8. class GURL;
  9. namespace weblayer {
  10. // Manages user permissions for Background Fetch. Background Fetch permission
  11. // is currently dynamic and relies on the Automatic Downloads content setting.
  12. class BackgroundFetchPermissionContext
  13. : public permissions::PermissionContextBase {
  14. public:
  15. explicit BackgroundFetchPermissionContext(
  16. content::BrowserContext* browser_context);
  17. BackgroundFetchPermissionContext(
  18. const BackgroundFetchPermissionContext& other) = delete;
  19. BackgroundFetchPermissionContext& operator=(
  20. const BackgroundFetchPermissionContext& other) = delete;
  21. ~BackgroundFetchPermissionContext() override = default;
  22. private:
  23. // PermissionContextBase implementation.
  24. bool IsRestrictedToSecureOrigins() const override;
  25. ContentSetting GetPermissionStatusInternal(
  26. content::RenderFrameHost* render_frame_host,
  27. const GURL& requesting_origin,
  28. const GURL& embedding_origin) const override;
  29. };
  30. } // namespace weblayer
  31. #endif // WEBLAYER_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_PERMISSION_CONTEXT_H_