origin_trial_policy_impl.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2016 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 COMPONENTS_EMBEDDER_SUPPORT_ORIGIN_TRIALS_ORIGIN_TRIAL_POLICY_IMPL_H_
  5. #define COMPONENTS_EMBEDDER_SUPPORT_ORIGIN_TRIALS_ORIGIN_TRIAL_POLICY_IMPL_H_
  6. #include <set>
  7. #include <string>
  8. #include <vector>
  9. #include "base/strings/string_piece.h"
  10. #include "third_party/blink/public/common/origin_trials/origin_trial_policy.h"
  11. namespace embedder_support {
  12. // This class is instantiated on the main/ui thread, but its methods can be
  13. // accessed from any thread.
  14. class OriginTrialPolicyImpl : public blink::OriginTrialPolicy {
  15. public:
  16. OriginTrialPolicyImpl();
  17. OriginTrialPolicyImpl(const OriginTrialPolicyImpl&) = delete;
  18. OriginTrialPolicyImpl& operator=(const OriginTrialPolicyImpl&) = delete;
  19. ~OriginTrialPolicyImpl() override;
  20. // blink::OriginTrialPolicy interface
  21. bool IsOriginTrialsSupported() const override;
  22. const std::vector<blink::OriginTrialPublicKey>& GetPublicKeys()
  23. const override;
  24. bool IsFeatureDisabled(base::StringPiece feature) const override;
  25. bool IsFeatureDisabledForUser(base::StringPiece feature) const override;
  26. bool IsTokenDisabled(base::StringPiece token_signature) const override;
  27. bool IsOriginSecure(const GURL& url) const override;
  28. bool SetPublicKeysFromASCIIString(const std::string& ascii_public_key);
  29. bool SetDisabledFeatures(const std::string& disabled_feature_list);
  30. bool SetDisabledTokens(const std::string& disabled_token_list);
  31. private:
  32. std::vector<blink::OriginTrialPublicKey> public_keys_;
  33. std::set<std::string> disabled_features_;
  34. std::set<std::string> disabled_tokens_;
  35. };
  36. } // namespace embedder_support
  37. #endif // COMPONENTS_EMBEDDER_SUPPORT_ORIGIN_TRIALS_ORIGIN_TRIAL_POLICY_IMPL_H_