if ( typeof browser == 'undefined' )
{
    browser = chrome;
}

navigator.mediaDevices.getUserMedia ( { video: true , audio: false } )
    .then ( function(stream)
    {
        console.log ( "Access granted" );
        browser.runtime.sendMessage ( { data: { cmd: 'cameraUnlocked' , params: { errnum: 0 } } } );
    } )
    .catch ( function ( err )
    {
        console.log ( "An error occurred" );
        console.log ( err );
        browser.runtime.sendMessage ( { data: { cmd: 'cameraUnlocked' , params: { errnum: 1 } } } );
    });
