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

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

Issue 1741783002: Add disabled origin trial feature list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ef-finch
Patch Set: Separate the introduction of preference-persistence into a different CL Created 4 years, 6 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 #include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 blink::WebOriginTrialTokenStatus TrialTokenValidator::ValidateToken( 14 blink::WebOriginTrialTokenStatus TrialTokenValidator::ValidateToken(
15 const std::string& token, 15 const std::string& token,
16 const url::Origin& origin, 16 const url::Origin& origin,
17 base::StringPiece feature_name) { 17 base::StringPiece feature_name) {
18 ContentClient* content_client = GetContentClient();
Sorin Jianu 2016/06/07 17:20:24 can this be const?
iclelland 2016/06/08 13:37:56 Certainly -- I was thinking at the time that I did
19 if (content_client->IsOriginTrialFeatureDisabled(feature_name))
20 return blink::WebOriginTrialTokenStatus::FeatureDisabled;
21
18 // TODO(iclelland): Allow for multiple signing keys, and iterate over all 22 // TODO(iclelland): Allow for multiple signing keys, and iterate over all
19 // active keys here. https://crbug.com/543220 23 // active keys here. https://crbug.com/543220
20 ContentClient* content_client = GetContentClient();
21 base::StringPiece public_key = content_client->GetOriginTrialPublicKey(); 24 base::StringPiece public_key = content_client->GetOriginTrialPublicKey();
22 if (public_key.empty()) { 25 if (public_key.empty()) {
23 return blink::WebOriginTrialTokenStatus::NotSupported; 26 return blink::WebOriginTrialTokenStatus::NotSupported;
24 } 27 }
25 28
26 blink::WebOriginTrialTokenStatus status; 29 blink::WebOriginTrialTokenStatus status;
27 std::unique_ptr<TrialToken> trial_token = 30 std::unique_ptr<TrialToken> trial_token =
28 TrialToken::From(token, public_key, &status); 31 TrialToken::From(token, public_key, &status);
29 if (status != blink::WebOriginTrialTokenStatus::Success) { 32 if (status != blink::WebOriginTrialTokenStatus::Success) {
30 return status; 33 return status;
31 } 34 }
32 35
33 return trial_token->IsValidForFeature(origin, feature_name, 36 return trial_token->IsValidForFeature(origin, feature_name,
34 base::Time::Now()); 37 base::Time::Now());
35 } 38 }
36 39
37 } // namespace content 40 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698