OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/pepper/pepper_socket_utils.h" | 5 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
16 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
18 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
19 #include "net/base/ip_address.h" | 20 #include "net/base/ip_address.h" |
20 #include "net/base/ip_endpoint.h" | 21 #include "net/base/ip_endpoint.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 return false; | 73 return false; |
73 } | 74 } |
74 | 75 |
75 return true; | 76 return true; |
76 } | 77 } |
77 | 78 |
78 bool GetCertificateFields(const net::X509Certificate& cert, | 79 bool GetCertificateFields(const net::X509Certificate& cert, |
79 ppapi::PPB_X509Certificate_Fields* fields) { | 80 ppapi::PPB_X509Certificate_Fields* fields) { |
80 const net::CertPrincipal& issuer = cert.issuer(); | 81 const net::CertPrincipal& issuer = cert.issuer(); |
81 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME, | 82 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME, |
82 new base::StringValue(issuer.common_name)); | 83 base::MakeUnique<base::StringValue>(issuer.common_name)); |
dcheng
2016/06/15 08:34:03
We pass a created BinaryValue to SetField(), so I
| |
83 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME, | 84 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME, |
84 new base::StringValue(issuer.locality_name)); | 85 base::MakeUnique<base::StringValue>(issuer.locality_name)); |
85 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME, | 86 fields->SetField( |
86 new base::StringValue(issuer.state_or_province_name)); | 87 PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME, |
88 base::MakeUnique<base::StringValue>(issuer.state_or_province_name)); | |
87 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME, | 89 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME, |
88 new base::StringValue(issuer.country_name)); | 90 base::MakeUnique<base::StringValue>(issuer.country_name)); |
89 fields->SetField( | 91 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME, |
90 PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME, | 92 base::MakeUnique<base::StringValue>( |
91 new base::StringValue(base::JoinString(issuer.organization_names, "\n"))); | 93 base::JoinString(issuer.organization_names, "\n"))); |
92 fields->SetField( | 94 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME, |
93 PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME, | 95 base::MakeUnique<base::StringValue>( |
94 new base::StringValue( | 96 base::JoinString(issuer.organization_unit_names, "\n"))); |
95 base::JoinString(issuer.organization_unit_names, "\n"))); | |
96 | 97 |
97 const net::CertPrincipal& subject = cert.subject(); | 98 const net::CertPrincipal& subject = cert.subject(); |
98 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME, | 99 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME, |
99 new base::StringValue(subject.common_name)); | 100 base::MakeUnique<base::StringValue>(subject.common_name)); |
100 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME, | 101 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME, |
101 new base::StringValue(subject.locality_name)); | 102 base::MakeUnique<base::StringValue>(subject.locality_name)); |
102 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME, | 103 fields->SetField( |
103 new base::StringValue(subject.state_or_province_name)); | 104 PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME, |
105 base::MakeUnique<base::StringValue>(subject.state_or_province_name)); | |
104 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME, | 106 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME, |
105 new base::StringValue(subject.country_name)); | 107 base::MakeUnique<base::StringValue>(subject.country_name)); |
106 fields->SetField( | 108 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME, |
107 PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME, | 109 base::MakeUnique<base::StringValue>( |
108 new base::StringValue( | 110 base::JoinString(subject.organization_names, "\n"))); |
109 base::JoinString(subject.organization_names, "\n"))); | 111 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME, |
110 fields->SetField( | 112 base::MakeUnique<base::StringValue>(base::JoinString( |
111 PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME, | 113 subject.organization_unit_names, "\n"))); |
112 new base::StringValue( | |
113 base::JoinString(subject.organization_unit_names, "\n"))); | |
114 | 114 |
115 const std::string& serial_number = cert.serial_number(); | 115 const std::string& serial_number = cert.serial_number(); |
116 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER, | 116 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER, |
117 base::BinaryValue::CreateWithCopiedBuffer( | 117 base::BinaryValue::CreateWithCopiedBuffer( |
118 serial_number.data(), serial_number.length())); | 118 serial_number.data(), serial_number.length())); |
119 fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE, | 119 fields->SetField( |
120 new base::FundamentalValue(cert.valid_start().ToDoubleT())); | 120 PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE, |
121 base::MakeUnique<base::FundamentalValue>(cert.valid_start().ToDoubleT())); | |
121 fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER, | 122 fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER, |
122 new base::FundamentalValue(cert.valid_expiry().ToDoubleT())); | 123 base::MakeUnique<base::FundamentalValue>( |
124 cert.valid_expiry().ToDoubleT())); | |
123 std::string der; | 125 std::string der; |
124 net::X509Certificate::GetDEREncoded(cert.os_cert_handle(), &der); | 126 net::X509Certificate::GetDEREncoded(cert.os_cert_handle(), &der); |
125 fields->SetField( | 127 fields->SetField( |
126 PP_X509CERTIFICATE_PRIVATE_RAW, | 128 PP_X509CERTIFICATE_PRIVATE_RAW, |
127 base::BinaryValue::CreateWithCopiedBuffer(der.data(), der.length())); | 129 base::BinaryValue::CreateWithCopiedBuffer(der.data(), der.length())); |
128 return true; | 130 return true; |
129 } | 131 } |
130 | 132 |
131 bool GetCertificateFields(const char* der, | 133 bool GetCertificateFields(const char* der, |
132 uint32_t length, | 134 uint32_t length, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 } | 184 } |
183 | 185 |
184 void OpenUDPFirewallHole(const net::IPEndPoint& address, | 186 void OpenUDPFirewallHole(const net::IPEndPoint& address, |
185 FirewallHoleOpenCallback callback) { | 187 FirewallHoleOpenCallback callback) { |
186 OpenFirewallHole(address, chromeos::FirewallHole::PortType::UDP, callback); | 188 OpenFirewallHole(address, chromeos::FirewallHole::PortType::UDP, callback); |
187 } | 189 } |
188 #endif // defined(OS_CHROMEOS) | 190 #endif // defined(OS_CHROMEOS) |
189 | 191 |
190 } // namespace pepper_socket_utils | 192 } // namespace pepper_socket_utils |
191 } // namespace content | 193 } // namespace content |
OLD | NEW |