Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/resources/cryptotoken/cryptotokenorigincheck.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Implements a check whether an origin is allowed to assert an 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. 7 * app id based on whether they share the same effective TLD + 1.
8 * 8 *
9 */ 9 */
10 'use strict'; 10 'use strict';
11 11
12 /** 12 /**
13 * Implements half of the app id policy: whether an origin is allowed to claim 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, 14 * an app id. For checking whether the app id also lists the origin,
15 * @see AppIdChecker. 15 * @see AppIdChecker.
16 * @implements OriginChecker 16 * @implements OriginChecker
17 * @constructor 17 * @constructor
18 */ 18 */
19 function CryptoTokenOriginChecker() { 19 function CryptoTokenOriginChecker() {}
20 }
21 20
22 /** 21 /**
23 * Checks whether the origin is allowed to claim the app ids. 22 * Checks whether the origin is allowed to claim the app ids.
24 * @param {string} origin The origin claiming the app id. 23 * @param {string} origin The origin claiming the app id.
25 * @param {!Array<string>} appIds The app ids being claimed. 24 * @param {!Array<string>} appIds The app ids being claimed.
26 * @return {Promise<boolean>} A promise for the result of the check. 25 * @return {Promise<boolean>} A promise for the result of the check.
27 */ 26 */
28 CryptoTokenOriginChecker.prototype.canClaimAppIds = function(origin, appIds) { 27 CryptoTokenOriginChecker.prototype.canClaimAppIds = function(origin, appIds) {
29 var appIdChecks = appIds.map(this.checkAppId_.bind(this, origin)); 28 var appIdChecks = appIds.map(this.checkAppId_.bind(this, origin));
30 return Promise.all(appIdChecks).then(function(results) { 29 return Promise.all(appIdChecks).then(function(results) {
31 return results.every(function(result) { 30 return results.every(function(result) {
32 return result; 31 return result;
33 }); 32 });
34 }); 33 });
35 }; 34 };
36 35
37 /** 36 /**
38 * Checks if a single appId can be asserted by the given origin. 37 * Checks if a single appId can be asserted by the given origin.
39 * @param {string} origin The origin. 38 * @param {string} origin The origin.
40 * @param {string} appId The appId to check 39 * @param {string} appId The appId to check
41 * @return {Promise<boolean>} A promise for the result of the check 40 * @return {Promise<boolean>} A promise for the result of the check
42 * @private 41 * @private
43 */ 42 */
44 CryptoTokenOriginChecker.prototype.checkAppId_ = 43 CryptoTokenOriginChecker.prototype.checkAppId_ = function(origin, appId) {
45 function(origin, appId) {
46 return new Promise(function(resolve, reject) { 44 return new Promise(function(resolve, reject) {
47 if (!chrome.cryptotokenPrivate) { 45 if (!chrome.cryptotokenPrivate) {
48 reject(); 46 reject();
49 return; 47 return;
50 } 48 }
51 chrome.cryptotokenPrivate.canOriginAssertAppId(origin, appId, resolve); 49 chrome.cryptotokenPrivate.canOriginAssertAppId(origin, appId, resolve);
52 }); 50 });
53 }; 51 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698