Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: content/common/origin_trials/trial_token_validator.cc

Issue 1909633003: Collect UMA data for Origin Trials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix/update unit tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #include "content/common/origin_trials/trial_token_validator.h" 5 #include "content/common/origin_trials/trial_token_validator.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/common/origin_trials/trial_token.h" 8 #include "content/common/origin_trials/trial_token.h"
9 #include "content/public/common/content_client.h" 9 #include "content/public/common/content_client.h"
10 #include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 bool TrialTokenValidator::ValidateToken(const std::string& token, 14 blink::WebOriginTrialTokenStatus TrialTokenValidator::ValidateToken(
14 const url::Origin& origin, 15 const std::string& token,
15 base::StringPiece feature_name) { 16 const url::Origin& origin,
17 base::StringPiece feature_name) {
16 // TODO(iclelland): Allow for multiple signing keys, and iterate over all 18 // TODO(iclelland): Allow for multiple signing keys, and iterate over all
17 // active keys here. https://crbug.com/543220 19 // active keys here. https://crbug.com/543220
18 ContentClient* content_client = GetContentClient(); 20 ContentClient* content_client = GetContentClient();
19 base::StringPiece public_key = content_client->GetOriginTrialPublicKey(); 21 base::StringPiece public_key = content_client->GetOriginTrialPublicKey();
20 if (public_key.empty()) { 22 if (public_key.empty()) {
21 return false; 23 return blink::WebOriginTrialTokenStatus::NotSupported;
22 } 24 }
23 std::unique_ptr<TrialToken> trial_token = TrialToken::From(token, public_key);
24 25
25 return trial_token && 26 blink::WebOriginTrialTokenStatus status;
26 trial_token->IsValidForFeature(origin, feature_name, 27 std::unique_ptr<TrialToken> trial_token =
28 TrialToken::From(token, public_key, &status);
29 if (status != blink::WebOriginTrialTokenStatus::Success) {
30 return status;
31 }
32
33 return trial_token->IsValidForFeature(origin, feature_name,
iclelland 2016/04/28 17:00:58 I'd be happier with a DCHECK(trial_token) here bef
chasej 2016/05/02 15:53:11 Does a DCHECK buy you much here? The pointer is pr
iclelland 2016/05/02 16:17:55 Fair enough; a crash is a crash :) Documentation-
27 base::Time::Now()); 34 base::Time::Now());
28 } 35 }
29 36
30 } // namespace content 37 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698