| OLD | NEW |
| 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/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/common/origin_trials/trial_token.h" | 9 #include "content/common/origin_trials/trial_token.h" |
| 10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 std::string token_feature; | 76 std::string token_feature; |
| 77 // TODO(mek): Log the validation errors to histograms? | 77 // TODO(mek): Log the validation errors to histograms? |
| 78 if (ValidateToken(token, origin, &token_feature) == | 78 if (ValidateToken(token, origin, &token_feature) == |
| 79 blink::WebOriginTrialTokenStatus::Success) | 79 blink::WebOriginTrialTokenStatus::Success) |
| 80 if (token_feature == feature_name) | 80 if (token_feature == feature_name) |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 std::unique_ptr<TrialTokenValidator::FeatureToTokensMap> |
| 87 TrialTokenValidator::GetValidTokens(const url::Origin& origin, |
| 88 const net::HttpResponseHeaders* headers) { |
| 89 std::unique_ptr<FeatureToTokensMap> tokens(new FeatureToTokensMap()); |
| 90 size_t iter = 0; |
| 91 std::string token; |
| 92 while (headers->EnumerateHeader(&iter, "Origin-Trial", &token)) { |
| 93 std::string token_feature; |
| 94 if (TrialTokenValidator::ValidateToken(token, origin, &token_feature) == |
| 95 blink::WebOriginTrialTokenStatus::Success) { |
| 96 (*tokens)[token_feature].push_back(token); |
| 97 } |
| 98 } |
| 99 return tokens; |
| 100 } |
| 101 |
| 86 } // namespace content | 102 } // namespace content |
| OLD | NEW |