pepper_socket_utils.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/common/socket_permission_request.h"
9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ppapi/c/pp_stdint.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct PP_NetAddress_Private;
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
13424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace net {
14424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class X509Certificate;
15424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace ppapi {
18424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class PPB_X509Certificate_Fields;
19424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
20424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace pepper_socket_utils {
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)SocketPermissionRequest CreateSocketPermissionRequest(
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SocketPermissionRequest::OperationType type,
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const PP_NetAddress_Private& net_addr);
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)// Returns true if the socket operation specified by |params| is allowed.
3068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)// If |params| is NULL, this method checks the basic "socket" permission, which
3168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)// is for those operations that don't require a specific socket permission rule.
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool CanUseSocketAPIs(bool external_plugin,
337d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                      bool private_api,
3468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                      const SocketPermissionRequest* params,
352385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch                      int render_process_id,
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                      int render_frame_id);
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
38424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Extracts the certificate field data from a net::X509Certificate into
39424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// PPB_X509Certificate_Fields.
40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool GetCertificateFields(const net::X509Certificate& cert,
41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)                          ppapi::PPB_X509Certificate_Fields* fields);
42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
43424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Extracts the certificate field data from the DER representation of a
44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// certificate into PPB_X509Certificate_Fields.
45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool GetCertificateFields(const char* der,
46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)                          uint32_t length,
47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)                          ppapi::PPB_X509Certificate_Fields* fields);
48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace pepper_socket_utils
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace content
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_
54