| Index: content/common/origin_trials/trial_token.h
|
| diff --git a/content/common/origin_trials/trial_token.h b/content/common/origin_trials/trial_token.h
|
| index fa05e3713b5b943cbd3f8fd774d09f1c5f8793cc..f563a6378a42cb7e7c7aa93710c503aa3dfea47a 100644
|
| --- a/content/common/origin_trials/trial_token.h
|
| +++ b/content/common/origin_trials/trial_token.h
|
| @@ -13,6 +13,10 @@
|
| #include "content/common/content_export.h"
|
| #include "url/origin.h"
|
|
|
| +namespace blink {
|
| +enum class WebOriginTrialTokenStatus;
|
| +}
|
| +
|
| namespace content {
|
|
|
| // The Experimental Framework (EF) provides limited access to experimental
|
| @@ -32,19 +36,26 @@ class CONTENT_EXPORT TrialToken {
|
| public:
|
| ~TrialToken();
|
|
|
| - // Returns a token object if the string represents a signed well-formed token,
|
| - // or nullptr otherwise. (This does not mean that the token is currently
|
| - // valid, or appropriate for a given origin / feature, just that it is
|
| + // If the string represents a signed well-formed token, a token object is
|
| + // returned, and success is returned in the |out_status| parameter. Otherwise,
|
| + // the |out_status| parameter indicates what was wrong with the string, and
|
| + // nullptr is returned.
|
| + // Note that success does not mean that the token is currently valid, or
|
| + // appropriate for a given origin / feature. It only means that it is
|
| // correctly formatted and signed by the supplied public key, and can be
|
| - // parsed.)
|
| - static std::unique_ptr<TrialToken> From(const std::string& token_text,
|
| - base::StringPiece public_key);
|
| -
|
| - // Returns true if this token is appropriate for use by the given origin,
|
| - // for the given feature name, and has not yet expired.
|
| - bool IsValidForFeature(const url::Origin& origin,
|
| - base::StringPiece feature_name,
|
| - const base::Time& now) const;
|
| + // parsed.
|
| + static std::unique_ptr<TrialToken> From(
|
| + const std::string& token_text,
|
| + base::StringPiece public_key,
|
| + blink::WebOriginTrialTokenStatus* out_status);
|
| +
|
| + // Returns success if this token is appropriate for use by the given origin
|
| + // and feature name, and has not yet expired. Otherwise, the return value
|
| + // indicates why the token is not valid.
|
| + blink::WebOriginTrialTokenStatus IsValidForFeature(
|
| + const url::Origin& origin,
|
| + base::StringPiece feature_name,
|
| + const base::Time& now) const;
|
|
|
| url::Origin origin() { return origin_; }
|
| std::string feature_name() { return feature_name_; }
|
| @@ -53,14 +64,18 @@ class CONTENT_EXPORT TrialToken {
|
| protected:
|
| friend class TrialTokenTest;
|
|
|
| - // Returns the payload of a signed token, or nullptr if the token is not
|
| - // properly signed, or is not well-formed.
|
| - static std::unique_ptr<std::string> Extract(const std::string& token_text,
|
| - base::StringPiece public_key);
|
| + // If the string represents a properly signed and well-formed token, the token
|
| + // payload is returned in the |out_token_payload| parameter and success is
|
| + // returned. Otherwise,the return code indicates what was wrong with the
|
| + // string, and |out_token_payload| is unchanged.
|
| + static blink::WebOriginTrialTokenStatus Extract(
|
| + const std::string& token_text,
|
| + base::StringPiece public_key,
|
| + std::string* out_token_payload);
|
|
|
| // Returns a token object if the string represents a well-formed JSON token
|
| // payload, or nullptr otherwise.
|
| - static std::unique_ptr<TrialToken> Parse(const std::string& token_json);
|
| + static std::unique_ptr<TrialToken> Parse(const std::string& token_payload);
|
|
|
| bool ValidateOrigin(const url::Origin& origin) const;
|
| bool ValidateFeatureName(base::StringPiece feature_name) const;
|
|
|