OLD | NEW |
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 "platform_verification_flow.h" | 5 #include "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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 CHECK(url.is_valid()); | 438 CHECK(url.is_valid()); |
439 // Build a pattern to represent scheme and host. | 439 // Build a pattern to represent scheme and host. |
440 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( | 440 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( |
441 ContentSettingsPattern::CreateBuilder(false)); | 441 ContentSettingsPattern::CreateBuilder(false)); |
442 builder->WithScheme(url.scheme()) | 442 builder->WithScheme(url.scheme()) |
443 ->WithDomainWildcard() | 443 ->WithDomainWildcard() |
444 ->WithHost(url.host()) | 444 ->WithHost(url.host()) |
445 ->WithPathWildcard(); | 445 ->WithPathWildcard(); |
446 if (!url.port().empty()) | 446 if (!url.port().empty()) |
447 builder->WithPort(url.port()); | 447 builder->WithPort(url.port()); |
448 else if (url.SchemeIs(content::kHttpsScheme)) | 448 else if (url.SchemeIs(url::kHttpsScheme)) |
449 builder->WithPort(kDefaultHttpsPort); | 449 builder->WithPort(kDefaultHttpsPort); |
450 else if (url.SchemeIs(content::kHttpScheme)) | 450 else if (url.SchemeIs(url::kHttpScheme)) |
451 builder->WithPortWildcard(); | 451 builder->WithPortWildcard(); |
452 ContentSettingsPattern pattern = builder->Build(); | 452 ContentSettingsPattern pattern = builder->Build(); |
453 if (pattern.IsValid()) { | 453 if (pattern.IsValid()) { |
454 ContentSetting setting = allow_domain ? CONTENT_SETTING_ALLOW | 454 ContentSetting setting = allow_domain ? CONTENT_SETTING_ALLOW |
455 : CONTENT_SETTING_BLOCK; | 455 : CONTENT_SETTING_BLOCK; |
456 content_settings->SetContentSetting( | 456 content_settings->SetContentSetting( |
457 pattern, | 457 pattern, |
458 pattern, | 458 pattern, |
459 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 459 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
460 std::string(), | 460 std::string(), |
461 setting); | 461 setting); |
462 } else { | 462 } else { |
463 LOG(WARNING) << "Not recording action: invalid URL pattern"; | 463 LOG(WARNING) << "Not recording action: invalid URL pattern"; |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) { | 467 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) { |
468 scoped_refptr<net::X509Certificate> x509( | 468 scoped_refptr<net::X509Certificate> x509( |
469 net::X509Certificate::CreateFromBytes(certificate.data(), | 469 net::X509Certificate::CreateFromBytes(certificate.data(), |
470 certificate.length())); | 470 certificate.length())); |
471 if (!x509.get() || x509->valid_expiry().is_null()) { | 471 if (!x509.get() || x509->valid_expiry().is_null()) { |
472 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; | 472 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; |
473 return false; | 473 return false; |
474 } | 474 } |
475 return (base::Time::Now() > x509->valid_expiry()); | 475 return (base::Time::Now() > x509->valid_expiry()); |
476 } | 476 } |
477 | 477 |
478 } // namespace attestation | 478 } // namespace attestation |
479 } // namespace chromeos | 479 } // namespace chromeos |
OLD | NEW |