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 13 matching lines...) Expand all Loading... |
24 #include "chromeos/cryptohome/async_method_caller.h" | 24 #include "chromeos/cryptohome/async_method_caller.h" |
25 #include "chromeos/dbus/cryptohome_client.h" | 25 #include "chromeos/dbus/cryptohome_client.h" |
26 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
27 #include "components/user_prefs/pref_registry_syncable.h" | 27 #include "components/user_prefs/pref_registry_syncable.h" |
28 #include "components/user_prefs/user_prefs.h" | 28 #include "components/user_prefs/user_prefs.h" |
29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/user_metrics.h" | 31 #include "content/public/browser/user_metrics.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
| 34 #include "net/base/url_constants.h" |
34 #include "net/cert/x509_certificate.h" | 35 #include "net/cert/x509_certificate.h" |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 const char kDefaultHttpsPort[] = "443"; | 39 const char kDefaultHttpsPort[] = "443"; |
39 const int kTimeoutInSeconds = 8; | 40 const int kTimeoutInSeconds = 8; |
40 | 41 |
41 // A callback method to handle DBus errors. | 42 // A callback method to handle DBus errors. |
42 void DBusCallback(const base::Callback<void(bool)>& on_success, | 43 void DBusCallback(const base::Callback<void(bool)>& on_success, |
43 const base::Closure& on_failure, | 44 const base::Closure& on_failure, |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 CHECK(url.is_valid()); | 439 CHECK(url.is_valid()); |
439 // Build a pattern to represent scheme and host. | 440 // Build a pattern to represent scheme and host. |
440 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( | 441 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( |
441 ContentSettingsPattern::CreateBuilder(false)); | 442 ContentSettingsPattern::CreateBuilder(false)); |
442 builder->WithScheme(url.scheme()) | 443 builder->WithScheme(url.scheme()) |
443 ->WithDomainWildcard() | 444 ->WithDomainWildcard() |
444 ->WithHost(url.host()) | 445 ->WithHost(url.host()) |
445 ->WithPathWildcard(); | 446 ->WithPathWildcard(); |
446 if (!url.port().empty()) | 447 if (!url.port().empty()) |
447 builder->WithPort(url.port()); | 448 builder->WithPort(url.port()); |
448 else if (url.SchemeIs(content::kHttpsScheme)) | 449 else if (url.SchemeIs(net::kHttpsScheme)) |
449 builder->WithPort(kDefaultHttpsPort); | 450 builder->WithPort(kDefaultHttpsPort); |
450 else if (url.SchemeIs(content::kHttpScheme)) | 451 else if (url.SchemeIs(net::kHttpScheme)) |
451 builder->WithPortWildcard(); | 452 builder->WithPortWildcard(); |
452 ContentSettingsPattern pattern = builder->Build(); | 453 ContentSettingsPattern pattern = builder->Build(); |
453 if (pattern.IsValid()) { | 454 if (pattern.IsValid()) { |
454 ContentSetting setting = allow_domain ? CONTENT_SETTING_ALLOW | 455 ContentSetting setting = allow_domain ? CONTENT_SETTING_ALLOW |
455 : CONTENT_SETTING_BLOCK; | 456 : CONTENT_SETTING_BLOCK; |
456 content_settings->SetContentSetting( | 457 content_settings->SetContentSetting( |
457 pattern, | 458 pattern, |
458 pattern, | 459 pattern, |
459 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 460 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
460 std::string(), | 461 std::string(), |
461 setting); | 462 setting); |
462 } else { | 463 } else { |
463 LOG(WARNING) << "Not recording action: invalid URL pattern"; | 464 LOG(WARNING) << "Not recording action: invalid URL pattern"; |
464 } | 465 } |
465 } | 466 } |
466 | 467 |
467 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) { | 468 bool PlatformVerificationFlow::IsExpired(const std::string& certificate) { |
468 scoped_refptr<net::X509Certificate> x509( | 469 scoped_refptr<net::X509Certificate> x509( |
469 net::X509Certificate::CreateFromBytes(certificate.data(), | 470 net::X509Certificate::CreateFromBytes(certificate.data(), |
470 certificate.length())); | 471 certificate.length())); |
471 if (!x509.get() || x509->valid_expiry().is_null()) { | 472 if (!x509.get() || x509->valid_expiry().is_null()) { |
472 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; | 473 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; |
473 return false; | 474 return false; |
474 } | 475 } |
475 return (base::Time::Now() > x509->valid_expiry()); | 476 return (base::Time::Now() > x509->valid_expiry()); |
476 } | 477 } |
477 | 478 |
478 } // namespace attestation | 479 } // namespace attestation |
479 } // namespace chromeos | 480 } // namespace chromeos |
OLD | NEW |