Home | History | Annotate | Download | only in trusted
      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 
      6 /* From trusted/ppb_broker_trusted.idl modified Mon Dec  3 11:10:40 2012. */
      7 
      8 #ifndef PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_
      9 #define PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_
     10 
     11 #include "ppapi/c/pp_bool.h"
     12 #include "ppapi/c/pp_completion_callback.h"
     13 #include "ppapi/c/pp_instance.h"
     14 #include "ppapi/c/pp_macros.h"
     15 #include "ppapi/c/pp_resource.h"
     16 #include "ppapi/c/pp_stdint.h"
     17 
     18 #define PPB_BROKER_TRUSTED_INTERFACE_0_2 "PPB_BrokerTrusted;0.2"
     19 #define PPB_BROKER_TRUSTED_INTERFACE_0_3 "PPB_BrokerTrusted;0.3"
     20 #define PPB_BROKER_TRUSTED_INTERFACE PPB_BROKER_TRUSTED_INTERFACE_0_3
     21 
     22 /**
     23  * @file
     24  * This file defines the PPB_BrokerTrusted interface, which provides
     25  * access to a trusted broker with greater privileges than the plugin.
     26  */
     27 
     28 
     29 /**
     30  * @addtogroup Interfaces
     31  * @{
     32  */
     33 /**
     34  * The PPB_BrokerTrusted interface provides access to a trusted broker
     35  * with greater privileges than the plugin. The interface only supports
     36  * out-of-process plugins and is to be used by proxy implementations.  All
     37  * functions should be called from the main thread only.
     38  *
     39  * A PPB_BrokerTrusted resource represents a connection to the broker. Its
     40  * lifetime controls the lifetime of the broker, regardless of whether the
     41  * handle is closed. The handle should be closed before the resource is
     42  * released.
     43  */
     44 struct PPB_BrokerTrusted_0_3 {
     45   /**
     46    * Returns a trusted broker resource.
     47    */
     48   PP_Resource (*CreateTrusted)(PP_Instance instance);
     49   /**
     50    * Returns true if the resource is a trusted broker.
     51    */
     52   PP_Bool (*IsBrokerTrusted)(PP_Resource resource);
     53   /**
     54    * Connects to the trusted broker. It may have already
     55    * been launched by another instance.
     56    * The plugin takes ownership of the handle once the callback has been called
     57    * with a result of PP_OK. The plugin should immediately call GetHandle and
     58    * begin managing it. If the result is not PP_OK, the browser still owns the
     59    * handle.
     60    *
     61    * Returns PP_ERROR_WOULD_BLOCK on success, and invokes
     62    * the |connect_callback| asynchronously to complete.
     63    * As this function should always be invoked from the main thread,
     64    * do not use the blocking variant of PP_CompletionCallback.
     65    * Returns PP_ERROR_FAILED if called from an in-process plugin.
     66    */
     67   int32_t (*Connect)(PP_Resource broker,
     68                      struct PP_CompletionCallback connect_callback);
     69   /**
     70    * Gets the handle to the pipe. Use once Connect has completed. Each instance
     71    * of this interface has its own pipe.
     72    *
     73    * Returns PP_OK on success, and places the result into the given output
     74    * parameter. The handle is only set when returning PP_OK. Calling this
     75    * before connect has completed will return PP_ERROR_FAILED.
     76    */
     77   int32_t (*GetHandle)(PP_Resource broker, int32_t* handle);
     78   /**
     79    * Returns PP_TRUE if the plugin has permission to launch the broker. A user
     80    * must explicitly grant permission to launch the broker for a particular
     81    * website. This is done through an infobar that is displayed when |Connect|
     82    * is called. This function returns PP_TRUE if the user has already granted
     83    * permission to launch the broker for the website containing this plugin
     84    * instance. Returns PP_FALSE otherwise.
     85    */
     86   PP_Bool (*IsAllowed)(PP_Resource broker);
     87 };
     88 
     89 typedef struct PPB_BrokerTrusted_0_3 PPB_BrokerTrusted;
     90 
     91 struct PPB_BrokerTrusted_0_2 {
     92   PP_Resource (*CreateTrusted)(PP_Instance instance);
     93   PP_Bool (*IsBrokerTrusted)(PP_Resource resource);
     94   int32_t (*Connect)(PP_Resource broker,
     95                      struct PP_CompletionCallback connect_callback);
     96   int32_t (*GetHandle)(PP_Resource broker, int32_t* handle);
     97 };
     98 /**
     99  * @}
    100  */
    101 
    102 #endif  /* PPAPI_C_TRUSTED_PPB_BROKER_TRUSTED_H_ */
    103 
    104