| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return nullptr; | 143 return nullptr; |
| 144 } | 144 } |
| 145 | 145 |
| 146 std::string origin_string; | 146 std::string origin_string; |
| 147 std::string feature_name; | 147 std::string feature_name; |
| 148 int expiry_timestamp = 0; | 148 int expiry_timestamp = 0; |
| 149 datadict->GetString("origin", &origin_string); | 149 datadict->GetString("origin", &origin_string); |
| 150 datadict->GetString("feature", &feature_name); | 150 datadict->GetString("feature", &feature_name); |
| 151 datadict->GetInteger("expiry", &expiry_timestamp); | 151 datadict->GetInteger("expiry", &expiry_timestamp); |
| 152 | 152 |
| 153 // Ensure that the origin is a valid (non-unique) origin URL. | 153 // Ensure that the origin is a valid (non-opaque) origin URL. |
| 154 url::Origin origin = url::Origin(GURL(origin_string)); | 154 url::Origin origin = url::Origin(GURL(origin_string)); |
| 155 if (origin.unique()) { | 155 if (origin.opaque()) { |
| 156 return nullptr; | 156 return nullptr; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // The |isSubdomain| flag is optional. If found, ensure it is a valid boolean. | 159 // The |isSubdomain| flag is optional. If found, ensure it is a valid boolean. |
| 160 bool is_subdomain = false; | 160 bool is_subdomain = false; |
| 161 if (datadict->HasKey("isSubdomain")) { | 161 if (datadict->HasKey("isSubdomain")) { |
| 162 if (!datadict->GetBoolean("isSubdomain", &is_subdomain)) { | 162 if (!datadict->GetBoolean("isSubdomain", &is_subdomain)) { |
| 163 return nullptr; | 163 return nullptr; |
| 164 } | 164 } |
| 165 } | 165 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 TrialToken::TrialToken(const url::Origin& origin, | 217 TrialToken::TrialToken(const url::Origin& origin, |
| 218 bool match_subdomains, | 218 bool match_subdomains, |
| 219 const std::string& feature_name, | 219 const std::string& feature_name, |
| 220 uint64_t expiry_timestamp) | 220 uint64_t expiry_timestamp) |
| 221 : origin_(origin), | 221 : origin_(origin), |
| 222 match_subdomains_(match_subdomains), | 222 match_subdomains_(match_subdomains), |
| 223 feature_name_(feature_name), | 223 feature_name_(feature_name), |
| 224 expiry_time_(base::Time::FromDoubleT(expiry_timestamp)) {} | 224 expiry_time_(base::Time::FromDoubleT(expiry_timestamp)) {} |
| 225 | 225 |
| 226 } // namespace content | 226 } // namespace content |
| OLD | NEW |