webui_allowlist_provider.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_
  5. #define UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_
  6. #include "base/synchronization/lock.h"
  7. #include "base/thread_annotations.h"
  8. #include "components/content_settings/core/browser/content_settings_observable_provider.h"
  9. #include "components/content_settings/core/common/content_settings.h"
  10. #include "ui/webui/webui_allowlist.h"
  11. class ContentSettingsPattern;
  12. // A provider that supplies HostContentSettingsMap with a list of auto-granted
  13. // permissions from the underlying WebUIAllowlist.
  14. class WebUIAllowlistProvider : public content_settings::ObservableProvider {
  15. public:
  16. explicit WebUIAllowlistProvider(scoped_refptr<WebUIAllowlist> allowlist);
  17. WebUIAllowlistProvider(const WebUIAllowlistProvider&) = delete;
  18. void operator=(const WebUIAllowlistProvider&) = delete;
  19. ~WebUIAllowlistProvider() override;
  20. void NotifyContentSettingChange(
  21. const ContentSettingsPattern& primary_pattern,
  22. const ContentSettingsPattern& secondary_pattern,
  23. ContentSettingsType content_type);
  24. // content_settings::ObservableProvider:
  25. // The following methods are thread-safe.
  26. std::unique_ptr<content_settings::RuleIterator> GetRuleIterator(
  27. ContentSettingsType content_type,
  28. bool incognito) const override;
  29. void ShutdownOnUIThread() override;
  30. bool SetWebsiteSetting(
  31. const ContentSettingsPattern& primary_pattern,
  32. const ContentSettingsPattern& secondary_pattern,
  33. ContentSettingsType content_type,
  34. base::Value&& value,
  35. const content_settings::ContentSettingConstraints& constraints) override;
  36. void ClearAllContentSettingsRules(ContentSettingsType content_type) override;
  37. private:
  38. const scoped_refptr<WebUIAllowlist> allowlist_;
  39. };
  40. #endif // UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_