| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "url/origin.h" | 14 #include "url/origin.h" |
| 15 | 15 |
| 16 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); |
| 17 |
| 16 namespace blink { | 18 namespace blink { |
| 17 enum class WebOriginTrialTokenStatus; | 19 enum class WebOriginTrialTokenStatus; |
| 18 } | 20 } |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 | 23 |
| 22 // The Experimental Framework (EF) provides limited access to experimental | 24 // The Experimental Framework (EF) provides limited access to experimental |
| 23 // features, on a per-origin basis (origin trials). This class defines the trial | 25 // features, on a per-origin basis (origin trials). This class defines the trial |
| 24 // token data structure, used to securely provide access to an experimental | 26 // token data structure, used to securely provide access to an experimental |
| 25 // feature. | 27 // feature. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 53 // and has not yet expired. Otherwise, the return value indicates why the | 55 // and has not yet expired. Otherwise, the return value indicates why the |
| 54 // token is not valid. | 56 // token is not valid. |
| 55 blink::WebOriginTrialTokenStatus IsValid(const url::Origin& origin, | 57 blink::WebOriginTrialTokenStatus IsValid(const url::Origin& origin, |
| 56 const base::Time& now) const; | 58 const base::Time& now) const; |
| 57 | 59 |
| 58 url::Origin origin() { return origin_; } | 60 url::Origin origin() { return origin_; } |
| 59 std::string feature_name() { return feature_name_; } | 61 std::string feature_name() { return feature_name_; } |
| 60 base::Time expiry_time() { return expiry_time_; } | 62 base::Time expiry_time() { return expiry_time_; } |
| 61 | 63 |
| 62 protected: | 64 protected: |
| 65 // Tests can access the Parse method directly to validate it, and so are |
| 66 // declared as friends here. All other access to Parse should be made through |
| 67 // TrialToken::From, which will always also ensure that there is a valid |
| 68 // signature attached to the token. |
| 63 friend class TrialTokenTest; | 69 friend class TrialTokenTest; |
| 70 friend int ::LLVMFuzzerTestOneInput(const uint8_t*, size_t); |
| 64 | 71 |
| 65 // If the string represents a properly signed and well-formed token, the token | 72 // If the string represents a properly signed and well-formed token, the token |
| 66 // payload is returned in the |out_token_payload| parameter and success is | 73 // payload is returned in the |out_token_payload| parameter and success is |
| 67 // returned. Otherwise,the return code indicates what was wrong with the | 74 // returned. Otherwise,the return code indicates what was wrong with the |
| 68 // string, and |out_token_payload| is unchanged. | 75 // string, and |out_token_payload| is unchanged. |
| 69 static blink::WebOriginTrialTokenStatus Extract( | 76 static blink::WebOriginTrialTokenStatus Extract( |
| 70 const std::string& token_text, | 77 const std::string& token_text, |
| 71 base::StringPiece public_key, | 78 base::StringPiece public_key, |
| 72 std::string* out_token_payload); | 79 std::string* out_token_payload); |
| 73 | 80 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 94 // The name of the experimental feature which this token enables. | 101 // The name of the experimental feature which this token enables. |
| 95 std::string feature_name_; | 102 std::string feature_name_; |
| 96 | 103 |
| 97 // The time until which this token should be considered valid. | 104 // The time until which this token should be considered valid. |
| 98 base::Time expiry_time_; | 105 base::Time expiry_time_; |
| 99 }; | 106 }; |
| 100 | 107 |
| 101 } // namespace content | 108 } // namespace content |
| 102 | 109 |
| 103 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 110 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| OLD | NEW |