Chromium Code Reviews| Index: content/child/origin_trials/trial_token_validator.cc |
| diff --git a/content/child/origin_trials/trial_token_validator.cc b/content/child/origin_trials/trial_token_validator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c4e22da1be9b5f2f27deb899fd68ceb9a388dba2 |
| --- /dev/null |
| +++ b/content/child/origin_trials/trial_token_validator.cc |
| @@ -0,0 +1,27 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/child/origin_trials/trial_token_validator.h" |
| + |
| +#include "base/time/time.h" |
| +#include "content/common/origin_trials/trial_token.h" |
| + |
| +namespace content { |
| + |
| +TrialTokenValidator::TrialTokenValidator() {} |
| +TrialTokenValidator::~TrialTokenValidator() {} |
| + |
| +bool TrialTokenValidator::validateToken(const blink::WebString& token, |
| + const blink::WebString& origin, |
| + const blink::WebString& featureName) { |
| + bool result = false; |
| + scoped_ptr<TrialToken> trialToken = TrialToken::Parse(token.utf8()); |
| + if (trialToken) { |
| + result = (trialToken->IsAppropriate(origin.utf8(), featureName.utf8()) && |
| + trialToken->IsValid(base::Time::Now())); |
| + } |
| + return result; |
|
davidben
2016/01/27 19:38:33
Optional nit: I would probably have written this a
iclelland
2016/01/28 12:18:12
Thanks, I'll do that; I like the look of it.
|
| +} |
| + |
| +} // namespace content |