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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_socket_utils.cc

Issue 22923014: TCPSockets are switched to the new Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
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/ref_counted.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/content_browser_client.h" 13 #include "content/public/browser/content_browser_client.h"
13 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/site_instance.h" 15 #include "content/public/browser/site_instance.h"
15 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
17 #include "net/cert/x509_certificate.h"
16 #include "ppapi/c/private/ppb_net_address_private.h" 18 #include "ppapi/c/private/ppb_net_address_private.h"
17 #include "ppapi/shared_impl/private/net_address_private_impl.h" 19 #include "ppapi/shared_impl/private/net_address_private_impl.h"
20 #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h"
18 21
19 namespace content { 22 namespace content {
20 namespace pepper_socket_utils { 23 namespace pepper_socket_utils {
21 24
22 SocketPermissionRequest CreateSocketPermissionRequest( 25 SocketPermissionRequest CreateSocketPermissionRequest(
23 SocketPermissionRequest::OperationType type, 26 SocketPermissionRequest::OperationType type,
24 const PP_NetAddress_Private& net_addr) { 27 const PP_NetAddress_Private& net_addr) {
25 std::string host = ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr, 28 std::string host = ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr,
26 false); 29 false);
27 int port = 0; 30 int port = 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 private_api, 73 private_api,
71 params)) { 74 params)) {
72 LOG(ERROR) << "Host " << site_instance->GetSiteURL().host() 75 LOG(ERROR) << "Host " << site_instance->GetSiteURL().host()
73 << " cannot use socket API or destination is not allowed"; 76 << " cannot use socket API or destination is not allowed";
74 return false; 77 return false;
75 } 78 }
76 79
77 return true; 80 return true;
78 } 81 }
79 82
83 bool GetCertificateFields(const net::X509Certificate& cert,
84 ppapi::PPB_X509Certificate_Fields* fields) {
85 const net::CertPrincipal& issuer = cert.issuer();
86 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME,
87 new base::StringValue(issuer.common_name));
88 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME,
89 new base::StringValue(issuer.locality_name));
90 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME,
91 new base::StringValue(issuer.state_or_province_name));
92 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME,
93 new base::StringValue(issuer.country_name));
94 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME,
95 new base::StringValue(JoinString(issuer.organization_names, '\n')));
96 fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME,
97 new base::StringValue(JoinString(issuer.organization_unit_names, '\n')));
98
99 const net::CertPrincipal& subject = cert.subject();
100 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME,
101 new base::StringValue(subject.common_name));
102 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME,
103 new base::StringValue(subject.locality_name));
104 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME,
105 new base::StringValue(subject.state_or_province_name));
106 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME,
107 new base::StringValue(subject.country_name));
108 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME,
109 new base::StringValue(JoinString(subject.organization_names, '\n')));
110 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME,
111 new base::StringValue(JoinString(subject.organization_unit_names, '\n')));
112
113 const std::string& serial_number = cert.serial_number();
114 fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER,
115 base::BinaryValue::CreateWithCopiedBuffer(serial_number.data(),
116 serial_number.length()));
117 fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE,
118 new base::FundamentalValue(cert.valid_start().ToDoubleT()));
119 fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER,
120 new base::FundamentalValue(cert.valid_expiry().ToDoubleT()));
121 std::string der;
122 net::X509Certificate::GetDEREncoded(cert.os_cert_handle(), &der);
123 fields->SetField(PP_X509CERTIFICATE_PRIVATE_RAW,
124 base::BinaryValue::CreateWithCopiedBuffer(der.data(), der.length()));
125 return true;
126 }
127
128 bool GetCertificateFields(const char* der,
129 uint32_t length,
130 ppapi::PPB_X509Certificate_Fields* fields) {
131 scoped_refptr<net::X509Certificate> cert =
132 net::X509Certificate::CreateFromBytes(der, length);
133 if (!cert.get())
134 return false;
135 return GetCertificateFields(*cert.get(), fields);
136 }
137
80 } // namespace pepper_socket_utils 138 } // namespace pepper_socket_utils
81 } // namespace content 139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698