| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.h" | 5 #include "content/common/origin_trials/trial_token.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return nullptr; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 std::string origin_string; | 154 std::string origin_string; |
| 155 std::string feature_name; | 155 std::string feature_name; |
| 156 int expiry_timestamp = 0; | 156 int expiry_timestamp = 0; |
| 157 datadict->GetString("origin", &origin_string); | 157 datadict->GetString("origin", &origin_string); |
| 158 datadict->GetString("feature", &feature_name); | 158 datadict->GetString("feature", &feature_name); |
| 159 datadict->GetInteger("expiry", &expiry_timestamp); | 159 datadict->GetInteger("expiry", &expiry_timestamp); |
| 160 | 160 |
| 161 // Ensure that the origin is a valid (non-unique) origin URL. | 161 // Ensure that the origin is a valid (non-opaque) origin URL. |
| 162 url::Origin origin = url::Origin(GURL(origin_string)); | 162 url::Origin origin = url::Origin(GURL(origin_string)); |
| 163 if (origin.unique()) { | 163 if (origin.opaque()) { |
| 164 return nullptr; | 164 return nullptr; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // The |isSubdomain| flag is optional. If found, ensure it is a valid boolean. | 167 // The |isSubdomain| flag is optional. If found, ensure it is a valid boolean. |
| 168 bool is_subdomain = false; | 168 bool is_subdomain = false; |
| 169 if (datadict->HasKey("isSubdomain")) { | 169 if (datadict->HasKey("isSubdomain")) { |
| 170 if (!datadict->GetBoolean("isSubdomain", &is_subdomain)) { | 170 if (!datadict->GetBoolean("isSubdomain", &is_subdomain)) { |
| 171 return nullptr; | 171 return nullptr; |
| 172 } | 172 } |
| 173 } | 173 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 TrialToken::TrialToken(const url::Origin& origin, | 225 TrialToken::TrialToken(const url::Origin& origin, |
| 226 bool match_subdomains, | 226 bool match_subdomains, |
| 227 const std::string& feature_name, | 227 const std::string& feature_name, |
| 228 uint64_t expiry_timestamp) | 228 uint64_t expiry_timestamp) |
| 229 : origin_(origin), | 229 : origin_(origin), |
| 230 match_subdomains_(match_subdomains), | 230 match_subdomains_(match_subdomains), |
| 231 feature_name_(feature_name), | 231 feature_name_(feature_name), |
| 232 expiry_time_(base::Time::FromDoubleT(expiry_timestamp)) {} | 232 expiry_time_(base::Time::FromDoubleT(expiry_timestamp)) {} |
| 233 | 233 |
| 234 } // namespace content | 234 } // namespace content |
| OLD | NEW |