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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/cryptotoken/cryptotokenbackground.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/cryptotoken/cryptotokenapprovedorigins.js
diff --git a/chrome/browser/resources/cryptotoken/cryptotokenapprovedorigins.js b/chrome/browser/resources/cryptotoken/cryptotokenapprovedorigins.js
index a28a934eb74c8699e5070cf0b3078058a8a4e75e..89fc759e6da9567d2ca13d22afb1984a5d98ad7a 100644
--- a/chrome/browser/resources/cryptotoken/cryptotokenapprovedorigins.js
+++ b/chrome/browser/resources/cryptotoken/cryptotokenapprovedorigins.js
@@ -30,36 +30,28 @@ function CryptoTokenApprovedOrigin() {}
CryptoTokenApprovedOrigin.prototype.isApprovedOrigin =
function(origin, opt_tabId) {
return new Promise(function(resolve, reject) {
- if (!chrome.tabs || !chrome.tabs.get) {
- reject();
- return;
- }
- if (!chrome.windows || !chrome.windows.get) {
- reject();
- return;
- }
- if (!opt_tabId) {
+ if (opt_tabId === undefined) {
resolve(false);
return;
}
var tabId = /** @type {number} */ (opt_tabId);
- chrome.tabs.get(tabId, function(tab) {
- if (chrome.runtime.lastError) {
- resolve(false);
- return;
- }
- if (!tab.active) {
- resolve(false);
- return;
- }
- chrome.windows.get(tab.windowId, function(aWindow) {
- if (!aWindow || !aWindow.focused) {
- resolve(false);
- return;
- }
- var tabOrigin = getOriginFromUrl(tab.url);
- resolve(tabOrigin == origin);
- });
- });
+ tabInForeground(tabId).then(function(result) {
+ if (!result) {
+ resolve(false);
+ return;
+ }
+ if (!chrome.tabs || !chrome.tabs.get) {
+ reject();
+ return;
+ }
+ chrome.tabs.get(tabId, function(tab) {
+ if (chrome.runtime.lastError) {
+ resolve(false);
+ return;
+ }
+ var tabOrigin = getOriginFromUrl(tab.url);
+ resolve(tabOrigin == origin);
+ });
+ });
});
};
« 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