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

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

Issue 872603003: Only release the result of a register request to a tab if it's still the foreground tab when the re… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/resources/cryptotoken/cryptotokenbackground.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 Provides an implementation of approved origins that relies 6 * @fileoverview Provides an implementation of approved origins that relies
7 * on the chrome.cryptotokenPrivate.requestPermission API. 7 * on the chrome.cryptotokenPrivate.requestPermission API.
8 * (and only) allows google.com to use security keys. 8 * (and only) allows google.com to use security keys.
9 * 9 *
10 */ 10 */
(...skipping 12 matching lines...) Expand all
23 * approval prompt may be shown.) 23 * approval prompt may be shown.)
24 * @param {string} origin The origin to approve. 24 * @param {string} origin The origin to approve.
25 * @param {number=} opt_tabId A tab id to display approval prompt in. 25 * @param {number=} opt_tabId A tab id to display approval prompt in.
26 * For this implementation, the tabId is always necessary, even though 26 * For this implementation, the tabId is always necessary, even though
27 * the type allows undefined. 27 * the type allows undefined.
28 * @return {Promise.<boolean>} A promise for the result of the check. 28 * @return {Promise.<boolean>} A promise for the result of the check.
29 */ 29 */
30 CryptoTokenApprovedOrigin.prototype.isApprovedOrigin = 30 CryptoTokenApprovedOrigin.prototype.isApprovedOrigin =
31 function(origin, opt_tabId) { 31 function(origin, opt_tabId) {
32 return new Promise(function(resolve, reject) { 32 return new Promise(function(resolve, reject) {
33 if (!chrome.tabs || !chrome.tabs.get) { 33 if (opt_tabId === undefined) {
34 reject();
35 return;
36 }
37 if (!chrome.windows || !chrome.windows.get) {
38 reject();
39 return;
40 }
41 if (!opt_tabId) {
42 resolve(false); 34 resolve(false);
43 return; 35 return;
44 } 36 }
45 var tabId = /** @type {number} */ (opt_tabId); 37 var tabId = /** @type {number} */ (opt_tabId);
46 chrome.tabs.get(tabId, function(tab) { 38 tabInForeground(tabId).then(function(result) {
47 if (chrome.runtime.lastError) { 39 if (!result) {
48 resolve(false); 40 resolve(false);
49 return; 41 return;
50 } 42 }
51 if (!tab.active) { 43 if (!chrome.tabs || !chrome.tabs.get) {
52 resolve(false); 44 reject();
53 return; 45 return;
54 } 46 }
55 chrome.windows.get(tab.windowId, function(aWindow) { 47 chrome.tabs.get(tabId, function(tab) {
56 if (!aWindow || !aWindow.focused) { 48 if (chrome.runtime.lastError) {
57 resolve(false); 49 resolve(false);
58 return; 50 return;
59 } 51 }
60 var tabOrigin = getOriginFromUrl(tab.url); 52 var tabOrigin = getOriginFromUrl(tab.url);
61 resolve(tabOrigin == origin); 53 resolve(tabOrigin == origin);
62 }); 54 });
63 }); 55 });
64 }); 56 });
65 }; 57 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/cryptotoken/cryptotokenbackground.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698