cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / resources / cryptotoken / cryptotokenorigincheck.js
blob3e4ac5e05590866a790f9c370a37bb5eb77d3cb7
1 // Copyright 2015 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.
5 /**
6 * @fileoverview Implements a check whether an origin is allowed to assert an
7 * app id based on whether they share the same effective TLD + 1.
9 */
10 'use strict';
12 /**
13 * Implements half of the app id policy: whether an origin is allowed to claim
14 * an app id. For checking whether the app id also lists the origin,
15 * @see AppIdChecker.
16 * @implements OriginChecker
17 * @constructor
19 function CryptoTokenOriginChecker() {
22 /**
23 * Checks whether the origin is allowed to claim the app ids.
24 * @param {string} origin The origin claiming the app id.
25 * @param {!Array<string>} appIds The app ids being claimed.
26 * @return {Promise<boolean>} A promise for the result of the check.
28 CryptoTokenOriginChecker.prototype.canClaimAppIds = function(origin, appIds) {
29 var appIdChecks = appIds.map(this.checkAppId_.bind(this, origin));
30 return Promise.all(appIdChecks).then(function(results) {
31 return results.every(function(result) {
32 return result;
33 });
34 });
37 /**
38 * Checks if a single appId can be asserted by the given origin.
39 * @param {string} origin The origin.
40 * @param {string} appId The appId to check
41 * @return {Promise<boolean>} A promise for the result of the check
42 * @private
44 CryptoTokenOriginChecker.prototype.checkAppId_ =
45 function(origin, appId) {
46 return new Promise(function(resolve, reject) {
47 if (!chrome.cryptotokenPrivate) {
48 reject();
49 return;
51 chrome.cryptotokenPrivate.canOriginAssertAppId(origin, appId, resolve);
52 });