screenshot-service.js 2.37 KB
/*
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2017 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 */

/* globals Promise */

define('screens/player/firmware/screenshot/impl/screenshot-service', [
    'underscore',
    'screens/player/shared/serviceadmin',
    'screens/player/firmware/screenshot/screenshot',
    'screens/player/firmware/screenshot/spi/screenshot',
    'module'
], function(_, ServiceAdmin, Screenshot, ScreenshotSpi, mod) {
    'use strict';

    /**
     * Implements the Screenshot service
     *
     * @class ScreenshotService
     * @implements {Screenshot}
     */
    var ScreenshotService = function() {};

    ScreenshotService.serviceName = Screenshot.serviceName;

    ScreenshotService.prototype = _.assign({}, Screenshot, {

        serviceId: mod.id,

        /**
         * @function ScreenshotService#activate
         * @inheritdoc
         */
        activate: function() {
            // wait for screenshot service to start.
            return new Promise(function(resolve) {
                ServiceAdmin.onServiceHighestRankedStart(ScreenshotSpi.serviceName, function(spi) {
                    resolve();
                });
            });
        },

        /**
         * @function ScreenshotService#deactivate
         * @inheritdoc
         */
        deactivate: function() { },

        /**
         * @function ScreenshotService#captureScreenshotAsURI
         * @inheritdoc
         */
        captureScreenshotAsURI: function() {
            var spi = ServiceAdmin.getService(ScreenshotSpi.serviceName);
            return spi.captureScreenshotAsURI();
        }
    });

    return ScreenshotService;
});

/* istanbul ignore next */
require([
    'screens/player/firmware/screenshot/impl/screenshot-service',
    'screens/player/shared/serviceadmin'
], function(Service, ServiceAdmin) {
    'use strict';
    ServiceAdmin.register(new Service());
});