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

Side by Side Diff: chrome/browser/chromeos/attestation/platform_verification_flow.cc

Issue 1001723002: media: Refactor PlatformVerificationFlow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/attestation/platform_verification_flow.h" 5 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" 14 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
15 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" 15 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h"
16 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
18 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
19 #include "chrome/browser/media/protected_media_identifier_permission_context_fac tory.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chromeos/attestation/attestation_flow.h" 22 #include "chromeos/attestation/attestation_flow.h"
22 #include "chromeos/cryptohome/async_method_caller.h" 23 #include "chromeos/cryptohome/async_method_caller.h"
23 #include "chromeos/dbus/cryptohome_client.h" 24 #include "chromeos/dbus/cryptohome_client.h"
24 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "components/content_settings/core/browser/host_content_settings_map.h" 26 #include "components/content_settings/core/browser/host_content_settings_map.h"
26 #include "components/content_settings/core/common/content_settings_pattern.h" 27 #include "components/content_settings/core/common/content_settings_pattern.h"
28 #include "components/content_settings/core/common/permission_request_id.h"
27 #include "components/pref_registry/pref_registry_syncable.h" 29 #include "components/pref_registry/pref_registry_syncable.h"
28 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
29 #include "components/user_prefs/user_prefs.h" 31 #include "components/user_prefs/user_prefs.h"
30 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
33 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
34 #include "content/public/common/url_constants.h" 38 #include "content/public/common/url_constants.h"
35 #include "net/cert/x509_certificate.h" 39 #include "net/cert/x509_certificate.h"
36 40
37 namespace { 41 namespace {
38 42
39 const char kDefaultHttpsPort[] = "443";
40 const int kTimeoutInSeconds = 8; 43 const int kTimeoutInSeconds = 8;
41 const char kAttestationResultHistogram[] = 44 const char kAttestationResultHistogram[] =
42 "ChromeOS.PlatformVerification.Result"; 45 "ChromeOS.PlatformVerification.Result";
43 const char kAttestationAvailableHistogram[] = 46 const char kAttestationAvailableHistogram[] =
44 "ChromeOS.PlatformVerification.Available"; 47 "ChromeOS.PlatformVerification.Available";
45 const int kAttestationResultHistogramMax = 10; 48 const int kAttestationResultHistogramMax = 10;
46 49
47 // A callback method to handle DBus errors. 50 // A callback method to handle DBus errors.
48 void DBusCallback(const base::Callback<void(bool)>& on_success, 51 void DBusCallback(const base::Callback<void(bool)>& on_success,
49 const base::Closure& on_failure, 52 const base::Closure& on_failure,
(...skipping 20 matching lines...) Expand all
70 73
71 namespace chromeos { 74 namespace chromeos {
72 namespace attestation { 75 namespace attestation {
73 76
74 // A default implementation of the Delegate interface. 77 // A default implementation of the Delegate interface.
75 class DefaultDelegate : public PlatformVerificationFlow::Delegate { 78 class DefaultDelegate : public PlatformVerificationFlow::Delegate {
76 public: 79 public:
77 DefaultDelegate() {} 80 DefaultDelegate() {}
78 ~DefaultDelegate() override {} 81 ~DefaultDelegate() override {}
79 82
80 void ShowConsentPrompt(
81 content::WebContents* web_contents,
82 const GURL& requesting_origin,
83 const PlatformVerificationFlow::Delegate::ConsentCallback& callback)
84 override {
85 PlatformVerificationDialog::ShowDialog(web_contents, requesting_origin,
86 callback);
87 }
88
89 PrefService* GetPrefs(content::WebContents* web_contents) override { 83 PrefService* GetPrefs(content::WebContents* web_contents) override {
90 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()); 84 return user_prefs::UserPrefs::Get(web_contents->GetBrowserContext());
91 } 85 }
92 86
93 const GURL& GetURL(content::WebContents* web_contents) override { 87 const GURL& GetURL(content::WebContents* web_contents) override {
94 const GURL& url = web_contents->GetLastCommittedURL(); 88 const GURL& url = web_contents->GetLastCommittedURL();
95 if (!url.is_valid()) 89 if (!url.is_valid())
96 return web_contents->GetVisibleURL(); 90 return web_contents->GetVisibleURL();
97 return url; 91 return url;
98 } 92 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 161
168 PlatformVerificationFlow::~PlatformVerificationFlow() { 162 PlatformVerificationFlow::~PlatformVerificationFlow() {
169 } 163 }
170 164
171 void PlatformVerificationFlow::ChallengePlatformKey( 165 void PlatformVerificationFlow::ChallengePlatformKey(
172 content::WebContents* web_contents, 166 content::WebContents* web_contents,
173 const std::string& service_id, 167 const std::string& service_id,
174 const std::string& challenge, 168 const std::string& challenge,
175 const ChallengeCallback& callback) { 169 const ChallengeCallback& callback) {
176 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 170 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
171
177 if (!delegate_->GetURL(web_contents).is_valid()) { 172 if (!delegate_->GetURL(web_contents).is_valid()) {
178 LOG(WARNING) << "PlatformVerificationFlow: Invalid URL."; 173 LOG(WARNING) << "PlatformVerificationFlow: Invalid URL.";
179 ReportError(callback, INTERNAL_ERROR); 174 ReportError(callback, INTERNAL_ERROR);
180 return; 175 return;
181 } 176 }
182 if (!IsAttestationEnabled(web_contents)) { 177
178 // Note: The following two checks are also checked in GetPermissionStatus.
179 // Checking them here explicitly to report the correct error type.
180
181 if (!IsAttestationAllowedByPolicy()) {
182 VLOG(1) << "Platform verification not allowed by device policy.";
183 ReportError(callback, POLICY_REJECTED); 183 ReportError(callback, POLICY_REJECTED);
184 return; 184 return;
185 } 185 }
186 // A platform key must be bound to a user. They are not allowed in incognito 186
187 // A platform key must be bound to a user. They are not allowed in incognito
187 // or guest mode. 188 // or guest mode.
188 if (delegate_->IsGuestOrIncognito(web_contents)) { 189 if (delegate_->IsGuestOrIncognito(web_contents)) {
189 VLOG(1) << "Platform verification denied because the current session is " 190 VLOG(1) << "Platform verification denied because the current session is "
190 << "guest or incognito."; 191 << "guest or incognito.";
191 ReportError(callback, PLATFORM_NOT_VERIFIED); 192 ReportError(callback, PLATFORM_NOT_VERIFIED);
192 return; 193 return;
193 } 194 }
195
196 if (!IsPermittedByUser(web_contents)) {
ddorwin 2015/03/12 00:28:32 Perhaps note that the user should have already bee
197 VLOG(1) << "Platform verification not permitted by user.";
198 ReportError(callback, USER_REJECTED);
ddorwin 2015/03/12 00:28:32 OOC, where do these values go and why? Do we use t
199 return;
200 }
201
194 ChallengeContext context(web_contents, service_id, challenge, callback); 202 ChallengeContext context(web_contents, service_id, challenge, callback);
195 // Check if the device has been prepared to use attestation. 203 // Check if the device has been prepared to use attestation.
196 BoolDBusMethodCallback dbus_callback = base::Bind( 204 BoolDBusMethodCallback dbus_callback =
197 &DBusCallback, 205 base::Bind(&DBusCallback,
198 base::Bind(&PlatformVerificationFlow::CheckEnrollment, this, context), 206 base::Bind(&PlatformVerificationFlow::OnAttestationPrepared,
xhwang 2015/03/11 23:01:17 I skipped the CheckEnrollment step because we don'
199 base::Bind(&ReportError, callback, INTERNAL_ERROR)); 207 this, context),
208 base::Bind(&ReportError, callback, INTERNAL_ERROR));
200 cryptohome_client_->TpmAttestationIsPrepared(dbus_callback); 209 cryptohome_client_->TpmAttestationIsPrepared(dbus_callback);
201 } 210 }
202 211
203 void PlatformVerificationFlow::CheckEnrollment(const ChallengeContext& context, 212 void PlatformVerificationFlow::OnAttestationPrepared(
204 bool attestation_prepared) { 213 const ChallengeContext& context,
214 bool attestation_prepared) {
205 UMA_HISTOGRAM_BOOLEAN(kAttestationAvailableHistogram, attestation_prepared); 215 UMA_HISTOGRAM_BOOLEAN(kAttestationAvailableHistogram, attestation_prepared);
216
206 if (!attestation_prepared) { 217 if (!attestation_prepared) {
207 // This device is not currently able to use attestation features. 218 // This device is not currently able to use attestation features.
208 ReportError(context.callback, PLATFORM_NOT_VERIFIED); 219 ReportError(context.callback, PLATFORM_NOT_VERIFIED);
209 return; 220 return;
210 } 221 }
211 BoolDBusMethodCallback dbus_callback = base::Bind(
212 &DBusCallback,
213 base::Bind(&PlatformVerificationFlow::CheckConsent, this, context),
214 base::Bind(&ReportError, context.callback, INTERNAL_ERROR));
215 cryptohome_client_->TpmAttestationIsEnrolled(dbus_callback);
216 }
217 222
218 void PlatformVerificationFlow::CheckConsent(const ChallengeContext& context, 223 // Permission allowed. Now proceed to get certificate.
219 bool /* attestation_enrolled */) { 224 const user_manager::User* user = delegate_->GetUser(context.web_contents);
220 content::WebContents* web_contents = context.web_contents; 225 if (!user) {
221 226 ReportError(context.callback, INTERNAL_ERROR);
222 bool enabled_for_origin = false; 227 LOG(ERROR) << "Profile does not map to a valid user.";
223 bool found =
224 GetOriginPref(delegate_->GetContentSettings(web_contents),
225 delegate_->GetURL(web_contents), &enabled_for_origin);
226 if (found && !enabled_for_origin) {
227 VLOG(1) << "Platform verification denied because the origin has been "
228 << "blocked by the user.";
229 ReportError(context.callback, USER_REJECTED);
230 return; 228 return;
231 } 229 }
232 230
233 PrefService* pref_service = delegate_->GetPrefs(web_contents); 231 GetCertificate(context, user->email(), false /* Don't force a new key */);
234 if (!pref_service) {
235 LOG(ERROR) << "Failed to get user prefs.";
236 ReportError(context.callback, INTERNAL_ERROR);
237 return;
238 }
239
240 // Consent required if user has never given consent for this origin, or if
241 // user has never given consent to attestation for content protection on this
242 // device.
243 bool consent_required =
244 !found || !pref_service->GetBoolean(prefs::kRAConsentGranted);
xhwang 2015/03/11 23:01:17 This logic is moved to ProtectedMediaIdentifierPer
245
246 Delegate::ConsentCallback consent_callback = base::Bind(
247 &PlatformVerificationFlow::OnConsentResponse,
248 this,
249 context,
250 consent_required);
251 if (consent_required) {
252 // TODO(xhwang): Using delegate_->GetURL() here is not right. The consent
253 // may be requested by a frame from a different origin. This will be solved
254 // when http://crbug.com/454847 is fixed.
255 delegate_->ShowConsentPrompt(
256 context.web_contents,
257 delegate_->GetURL(context.web_contents).GetOrigin(), consent_callback);
258 } else {
259 consent_callback.Run(CONSENT_RESPONSE_NONE);
260 }
261 } 232 }
262 233
263 void PlatformVerificationFlow::RegisterProfilePrefs( 234 void PlatformVerificationFlow::RegisterProfilePrefs(
264 user_prefs::PrefRegistrySyncable* prefs) { 235 user_prefs::PrefRegistrySyncable* prefs) {
265 prefs->RegisterBooleanPref(prefs::kRAConsentGranted, 236 prefs->RegisterBooleanPref(prefs::kRAConsentGranted,
266 false, // Default value. 237 false, // Default value.
267 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 238 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
268 } 239 }
269 240
270 void PlatformVerificationFlow::OnConsentResponse(
271 const ChallengeContext& context,
272 bool consent_required,
273 ConsentResponse consent_response) {
274 if (consent_required) {
275 if (consent_response == CONSENT_RESPONSE_NONE) {
276 // No user response - do not proceed and do not modify any settings.
277 LOG(WARNING) << "PlatformVerificationFlow: No response from user.";
278 ReportError(context.callback, USER_REJECTED);
279 return;
280 }
281 if (!UpdateSettings(context.web_contents, consent_response)) {
282 ReportError(context.callback, INTERNAL_ERROR);
283 return;
284 }
285 if (consent_response == CONSENT_RESPONSE_DENY) {
286 content::RecordAction(
287 base::UserMetricsAction("PlatformVerificationRejected"));
288 VLOG(1) << "Platform verification denied by user.";
289 ReportError(context.callback, USER_REJECTED);
290 return;
291 } else if (consent_response == CONSENT_RESPONSE_ALLOW) {
292 content::RecordAction(
293 base::UserMetricsAction("PlatformVerificationAccepted"));
294 VLOG(1) << "Platform verification accepted by user.";
295 }
296 }
297
298 // At this point all user interaction is complete and we can proceed with the
299 // certificate request.
300 const user_manager::User* user = delegate_->GetUser(context.web_contents);
301 if (!user) {
302 ReportError(context.callback, INTERNAL_ERROR);
303 LOG(ERROR) << "Profile does not map to a valid user.";
304 return;
305 }
306
307 GetCertificate(context, user->email(), false /* Don't force a new key */);
308 }
309
310 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, 241 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context,
311 const std::string& user_id, 242 const std::string& user_id,
312 bool force_new_key) { 243 bool force_new_key) {
313 scoped_ptr<base::Timer> timer(new base::Timer(false, // Don't retain. 244 scoped_ptr<base::Timer> timer(new base::Timer(false, // Don't retain.
314 false)); // Don't repeat. 245 false)); // Don't repeat.
315 base::Closure timeout_callback = base::Bind( 246 base::Closure timeout_callback = base::Bind(
316 &PlatformVerificationFlow::OnCertificateTimeout, 247 &PlatformVerificationFlow::OnCertificateTimeout,
317 this, 248 this,
318 context); 249 context);
319 timer->Start(FROM_HERE, timeout_delay_, timeout_callback); 250 timer->Start(FROM_HERE, timeout_delay_, timeout_callback);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 326 }
396 VLOG(1) << "Platform verification successful."; 327 VLOG(1) << "Platform verification successful.";
397 UMA_HISTOGRAM_ENUMERATION(kAttestationResultHistogram, SUCCESS, 328 UMA_HISTOGRAM_ENUMERATION(kAttestationResultHistogram, SUCCESS,
398 kAttestationResultHistogramMax); 329 kAttestationResultHistogramMax);
399 context.callback.Run(SUCCESS, 330 context.callback.Run(SUCCESS,
400 signed_data_pb.data(), 331 signed_data_pb.data(),
401 signed_data_pb.signature(), 332 signed_data_pb.signature(),
402 certificate); 333 certificate);
403 } 334 }
404 335
405 bool PlatformVerificationFlow::IsAttestationEnabled( 336 bool PlatformVerificationFlow::IsAttestationAllowedByPolicy() {
406 content::WebContents* web_contents) {
407 // Check the device policy for the feature. 337 // Check the device policy for the feature.
408 bool enabled_for_device = false; 338 bool enabled_for_device = false;
409 if (!CrosSettings::Get()->GetBoolean(kAttestationForContentProtectionEnabled, 339 if (!CrosSettings::Get()->GetBoolean(kAttestationForContentProtectionEnabled,
410 &enabled_for_device)) { 340 &enabled_for_device)) {
411 LOG(ERROR) << "Failed to get device setting."; 341 LOG(ERROR) << "Failed to get device setting.";
412 return false; 342 return false;
413 } 343 }
414 if (!enabled_for_device) { 344 if (!enabled_for_device) {
415 VLOG(1) << "Platform verification denied because Verified Access is " 345 VLOG(1) << "Platform verification denied because Verified Access is "
416 << "disabled for the device."; 346 << "disabled for the device.";
417 return false; 347 return false;
418 } 348 }
419 349
420 // Check the user preference for the feature.
421 PrefService* pref_service = delegate_->GetPrefs(web_contents);
422 if (!pref_service) {
423 LOG(ERROR) << "Failed to get user prefs.";
424 return false;
425 }
426 if (!pref_service->GetBoolean(prefs::kEnableDRM)) {
427 VLOG(1) << "Platform verification denied because content protection "
428 << "identifiers have been disabled by the user.";
429 return false;
430 }
431
432 // Check the user preference for this origin.
433 bool enabled_for_origin = false;
434 bool found =
435 GetOriginPref(delegate_->GetContentSettings(web_contents),
436 delegate_->GetURL(web_contents), &enabled_for_origin);
437 if (found && !enabled_for_origin) {
438 VLOG(1) << "Platform verification denied because the origin has been "
439 << "blocked by the user.";
440 return false;
441 }
442 return true; 350 return true;
443 } 351 }
444 352
445 bool PlatformVerificationFlow::UpdateSettings( 353 bool PlatformVerificationFlow::IsPermittedByUser(
446 content::WebContents* web_contents, 354 content::WebContents* web_contents) {
447 ConsentResponse consent_response) { 355 ProtectedMediaIdentifierPermissionContext* permission_context =
448 PrefService* pref_service = delegate_->GetPrefs(web_contents); 356 ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
449 if (!pref_service) { 357 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
450 LOG(ERROR) << "Failed to get user prefs.";
451 return false;
452 }
453 358
454 if (consent_response == CONSENT_RESPONSE_ALLOW) { 359 // TODO(xhwang): Using delegate_->GetURL() here is not right. The platform
ddorwin 2015/03/12 00:28:32 What URL does this give us? GLCURL below gets us t
455 pref_service->SetBoolean(prefs::kRAConsentGranted, true); 360 // verification may be requested by a frame from a different origin. This will
456 } 361 // be solved when http://crbug.com/454847 is fixed.
362 const GURL& requesting_origin = delegate_->GetURL(web_contents).GetOrigin();
457 363
458 RecordOriginConsent(delegate_->GetContentSettings(web_contents), 364 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
459 delegate_->GetURL(web_contents), 365
460 (consent_response == CONSENT_RESPONSE_ALLOW)); 366 ContentSetting content_setting = permission_context->GetPermissionStatus(
461 return true; 367 requesting_origin, embedding_origin);
368
369 return content_setting == CONTENT_SETTING_ALLOW;
462 } 370 }
463 371
464 bool PlatformVerificationFlow::GetOriginPref( 372 bool PlatformVerificationFlow::GetOriginPref(
465 HostContentSettingsMap* content_settings, 373 HostContentSettingsMap* content_settings,
466 const GURL& url, 374 const GURL& url,
467 bool* pref_value) { 375 bool* pref_value) {
468 CHECK(content_settings); 376 CHECK(content_settings);
469 CHECK(url.is_valid()); 377 CHECK(url.is_valid());
470 ContentSetting setting = content_settings->GetContentSetting( 378 ContentSetting setting = content_settings->GetContentSetting(
471 url, 379 url,
472 url, 380 url,
473 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, 381 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
474 std::string()); 382 std::string());
475 if (setting != CONTENT_SETTING_ALLOW && setting != CONTENT_SETTING_BLOCK) 383 if (setting != CONTENT_SETTING_ALLOW && setting != CONTENT_SETTING_BLOCK)
476 return false; 384 return false;
477 if (pref_value) 385 if (pref_value)
478 *pref_value = (setting == CONTENT_SETTING_ALLOW); 386 *pref_value = (setting == CONTENT_SETTING_ALLOW);
479 return true; 387 return true;
480 } 388 }
481 389
482 void PlatformVerificationFlow::RecordOriginConsent(
xhwang 2015/03/11 23:01:17 These are now handled by ProtectedMediaIdentifierP
483 HostContentSettingsMap* content_settings,
484 const GURL& url,
485 bool allow_origin) {
486 CHECK(content_settings);
487 CHECK(url.is_valid());
488 // Build a pattern to represent scheme and host.
489 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder(
490 ContentSettingsPattern::CreateBuilder(false));
491 builder->WithScheme(url.scheme())
492 ->WithDomainWildcard()
493 ->WithHost(url.host())
494 ->WithPathWildcard();
495 if (!url.port().empty())
496 builder->WithPort(url.port());
497 else if (url.SchemeIs(url::kHttpsScheme))
498 builder->WithPort(kDefaultHttpsPort);
499 else if (url.SchemeIs(url::kHttpScheme))
500 builder->WithPortWildcard();
501 ContentSettingsPattern pattern = builder->Build();
502 if (pattern.IsValid()) {
503 ContentSetting setting =
504 allow_origin ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
505 content_settings->SetContentSetting(
506 pattern,
507 pattern,
508 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
509 std::string(),
510 setting);
511 } else {
512 LOG(WARNING) << "Not recording action: invalid URL pattern";
513 }
514 }
515
516 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) { 390 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) {
517 scoped_refptr<net::X509Certificate> x509( 391 scoped_refptr<net::X509Certificate> x509(
518 net::X509Certificate::CreateFromBytes(certificate.data(), 392 net::X509Certificate::CreateFromBytes(certificate.data(),
519 certificate.length())); 393 certificate.length()));
520 if (!x509.get() || x509->valid_expiry().is_null()) { 394 if (!x509.get() || x509->valid_expiry().is_null()) {
521 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; 395 LOG(WARNING) << "Failed to parse certificate, cannot check expiry.";
522 return false; 396 return false;
523 } 397 }
524 return (base::Time::Now() > x509->valid_expiry()); 398 return (base::Time::Now() > x509->valid_expiry());
525 } 399 }
526 400
527 } // namespace attestation 401 } // namespace attestation
528 } // namespace chromeos 402 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698