pepper_socket_utils.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
6#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
7
8#include "content/public/common/socket_permission_request.h"
9#include "ppapi/c/pp_stdint.h"
10
11struct PP_NetAddress_Private;
12
13namespace net {
14class X509Certificate;
15}
16
17namespace ppapi {
18class PPB_X509Certificate_Fields;
19}
20
21namespace content {
22
23namespace pepper_socket_utils {
24
25SocketPermissionRequest CreateSocketPermissionRequest(
26    SocketPermissionRequest::OperationType type,
27    const PP_NetAddress_Private& net_addr);
28
29// Returns true if the socket operation specified by |params| is allowed.
30// If |params| is NULL, this method checks the basic "socket" permission, which
31// is for those operations that don't require a specific socket permission rule.
32bool CanUseSocketAPIs(bool external_plugin,
33                      bool private_api,
34                      const SocketPermissionRequest* params,
35                      int render_process_id,
36                      int render_frame_id);
37
38// Extracts the certificate field data from a net::X509Certificate into
39// PPB_X509Certificate_Fields.
40bool GetCertificateFields(const net::X509Certificate& cert,
41                          ppapi::PPB_X509Certificate_Fields* fields);
42
43// Extracts the certificate field data from the DER representation of a
44// certificate into PPB_X509Certificate_Fields.
45bool GetCertificateFields(const char* der,
46                          uint32_t length,
47                          ppapi::PPB_X509Certificate_Fields* fields);
48
49}  // namespace pepper_socket_utils
50
51}  // namespace content
52
53#endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
54