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

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

Issue 799923007: Enable 3rd party support for Security Keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove duplicate line from merge Created 6 years 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
(Empty)
1 // Copyright 2014 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.
4
5 /**
6 * @fileoverview Provides an implementation of approved origins that relies
7 * on the chrome.cryptotokenPrivate.requestPermission API.
8 * (and only) allows google.com to use security keys.
9 *
10 */
11 'use strict';
12
13 /**
14 * Allows the caller to check whether the user has approved the use of
15 * security keys from an origin.
16 * @constructor
17 * @implements {ApprovedOrigins}
18 */
19 function CryptoTokenApprovedOrigin() {}
20
21 /**
22 * Checks whether the origin is approved to use security keys. (If not, an
23 * approval prompt may be shown.)
24 * @param {string} origin The origin to approve.
25 * @param {number=} opt_tabId A tab id to display approval prompt in.
26 * For this implementation, the tabId is always necessary, even though
27 * the type allows undefined.
28 * @return {Promise.<boolean>} A promise for the result of the check.
29 */
30 CryptoTokenApprovedOrigin.prototype.isApprovedOrigin =
31 function(origin, opt_tabId) {
32 return new Promise(function(resolve, reject) {
33 if (!chrome.cryptotokenPrivate ||
34 !chrome.cryptotokenPrivate.requestPermission) {
35 resolve(false);
36 return;
37 }
38 if (!opt_tabId) {
39 resolve(false);
40 return;
41 }
42 var tabId = /** @type {number} */ (opt_tabId);
43 chrome.cryptotokenPrivate.requestPermission(tabId, origin,
44 function(result) {
45 if (result == 'ALLOWED') {
46 resolve(true);
47 return;
48 }
49 if (chrome.runtime.lastError) {
50 console.log(UTIL_fmt('lastError: ' + chrome.runtime.lastError));
51 }
52 resolve(false);
53 });
54 });
55 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698