15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* From trusted/ppb_broker_trusted.idl modified Mon Dec 3 11:10:40 2012. */ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_bool.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_completion_callback.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_instance.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_macros.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_resource.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_stdint.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPB_BROKER_TRUSTED_INTERFACE_0_2 "PPB_BrokerTrusted;0.2" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define PPB_BROKER_TRUSTED_INTERFACE_0_3 "PPB_BrokerTrusted;0.3" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define PPB_BROKER_TRUSTED_INTERFACE PPB_BROKER_TRUSTED_INTERFACE_0_3 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/** 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @file 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This file defines the PPB_BrokerTrusted interface, which provides 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * access to a trusted broker with greater privileges than the plugin. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/** 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @addtogroup Interfaces 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @{ 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/** 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The PPB_BrokerTrusted interface provides access to a trusted broker 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * with greater privileges than the plugin. The interface only supports 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * out-of-process plugins and is to be used by proxy implementations. All 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * functions should be called from the main thread only. 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A PPB_BrokerTrusted resource represents a connection to the broker. Its 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * lifetime controls the lifetime of the broker, regardless of whether the 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * handle is closed. The handle should be closed before the resource is 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * released. 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct PPB_BrokerTrusted_0_3 { 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns a trusted broker resource. 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_Resource (*CreateTrusted)(PP_Instance instance); 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns true if the resource is a trusted broker. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_Bool (*IsBrokerTrusted)(PP_Resource resource); 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Connects to the trusted broker. It may have already 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * been launched by another instance. 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The plugin takes ownership of the handle once the callback has been called 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * with a result of PP_OK. The plugin should immediately call GetHandle and 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * begin managing it. If the result is not PP_OK, the browser still owns the 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * handle. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns PP_ERROR_WOULD_BLOCK on success, and invokes 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the |connect_callback| asynchronously to complete. 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * As this function should always be invoked from the main thread, 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * do not use the blocking variant of PP_CompletionCallback. 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns PP_ERROR_FAILED if called from an in-process plugin. 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32_t (*Connect)(PP_Resource broker, 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct PP_CompletionCallback connect_callback); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Gets the handle to the pipe. Use once Connect has completed. Each instance 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * of this interface has its own pipe. 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns PP_OK on success, and places the result into the given output 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * parameter. The handle is only set when returning PP_OK. Calling this 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * before connect has completed will return PP_ERROR_FAILED. 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32_t (*GetHandle)(PP_Resource broker, int32_t* handle); 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) /** 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Returns PP_TRUE if the plugin has permission to launch the broker. A user 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * must explicitly grant permission to launch the broker for a particular 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * website. This is done through an infobar that is displayed when |Connect| 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * is called. This function returns PP_TRUE if the user has already granted 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * permission to launch the broker for the website containing this plugin 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * instance. Returns PP_FALSE otherwise. 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */ 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PP_Bool (*IsAllowed)(PP_Resource broker); 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)typedef struct PPB_BrokerTrusted_0_3 PPB_BrokerTrusted; 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct PPB_BrokerTrusted_0_2 { 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PP_Resource (*CreateTrusted)(PP_Instance instance); 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PP_Bool (*IsBrokerTrusted)(PP_Resource resource); 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int32_t (*Connect)(PP_Resource broker, 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) struct PP_CompletionCallback connect_callback); 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int32_t (*GetHandle)(PP_Resource broker, int32_t* handle); 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/** 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @} 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ */ 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 104