import { ipcRenderer } from 'electron'
import rpc from 'pauls-electron-rpc'

// it would be better to import this from package.json
const BEAKER_VERSION = '0.0.1'

// method which will populate window.beaker with the APIs deemed appropriate for the protocol
export default function () {
  window.beaker = { version: BEAKER_VERSION }
  var webAPIs = ipcRenderer.sendSync('get-web-api-manifests', window.location.protocol)
  for (var k in webAPIs) {
    window[k] = rpc.importAPI(k, webAPIs[k], { timeout: false })
  }
}
import { ipcRenderer, webFrame } from 'electron'
import rpc from 'pauls-electron-rpc'

// it would be better to import this from package.json
const BEAKER_VERSION = '0.0.1'

// method which will populate window.beaker with the APIs deemed appropriate for the protocol
export default function () {

  // mark the safe protocol as 'secure' to enable all DOM APIs
  webFrame.registerURLSchemeAsSecure('safe');
  window.beaker = { version: BEAKER_VERSION }
  var webAPIs = ipcRenderer.sendSync('get-web-api-manifests', window.location.protocol)
  for (var k in webAPIs) {
    window[k] = rpc.importAPI(k, webAPIs[k], { timeout: false })
  }
}
Mark safe as a secure protocol
feat/webview: Mark safe as a secure protocol

Chrom(e|ium) exposes many newer DOM APIs and HTML5 features (like User Media or Geolocation)
only over secure connections – primarily https – in order to prevent the user from
accidentially exposing themselves to third parties. For any webpage deliver over an unsecure
protocol those APIs will be flat out denied.

This patch registers our own `safe`-protocol as a secure one, in order to enable said
DOM APIs and HTML5 features.
