| Index: content/common/origin_trials/trial_token_validator.cc
|
| diff --git a/content/common/origin_trials/trial_token_validator.cc b/content/common/origin_trials/trial_token_validator.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b7d61fec4b1969e21fc6de8cce55143c1a3fc14f
|
| --- /dev/null
|
| +++ b/content/common/origin_trials/trial_token_validator.cc
|
| @@ -0,0 +1,28 @@
|
| +// 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/common/origin_trials/trial_token_validator.h"
|
| +
|
| +#include "base/time/time.h"
|
| +#include "content/common/origin_trials/trial_token.h"
|
| +#include "content/public/common/content_client.h"
|
| +
|
| +namespace content {
|
| +
|
| +bool TrialTokenValidator::ValidateToken(const std::string& token,
|
| + const url::Origin& origin,
|
| + base::StringPiece featureName) {
|
| + scoped_ptr<TrialToken> trial_token = TrialToken::Parse(token);
|
| +
|
| + // TODO(iclelland): Allow for multiple signing keys, and iterate over all
|
| + // active keys here. https://crbug.com/543220
|
| + ContentClient* content_client = GetContentClient();
|
| + base::StringPiece public_key = content_client->GetOriginTrialPublicKey();
|
| +
|
| + return !public_key.empty() && trial_token &&
|
| + trial_token->IsAppropriate(origin, featureName) &&
|
| + trial_token->IsValid(base::Time::Now(), public_key);
|
| +}
|
| +
|
| +} // namespace content
|
|
|