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

Side by Side Diff: chrome/browser/resources/cryptotoken/webrequestsender.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 | « chrome/browser/resources/cryptotoken/cryptotokenbackground.js ('k') | no next file » | 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 a representation of a web request sender, and 6 * @fileoverview Provides a representation of a web request sender, and
7 * utility functions for creating them. 7 * utility functions for creating them.
8 */ 8 */
9 'use strict'; 9 'use strict';
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 reject(false); 124 reject(false);
125 } 125 }
126 }); 126 });
127 } 127 }
128 }); 128 });
129 }); 129 });
130 }); 130 });
131 }); 131 });
132 } 132 }
133 } 133 }
134
135 /**
136 * Checks whether the given tab is in the foreground, i.e. is the active tab
137 * of the focused window.
138 * @param {number} tabId The tab id to check.
139 * @return {Promise.<boolean>} A promise for the result of the check.
140 */
141 function tabInForeground(tabId) {
142 return new Promise(function(resolve, reject) {
143 if (!chrome.tabs || !chrome.tabs.get) {
144 reject();
145 return;
146 }
147 if (!chrome.windows || !chrome.windows.get) {
148 reject();
149 return;
150 }
151 chrome.tabs.get(tabId, function(tab) {
152 if (chrome.runtime.lastError) {
153 resolve(false);
154 return;
155 }
156 if (!tab.active) {
157 resolve(false);
158 return;
159 }
160 chrome.windows.get(tab.windowId, function(aWindow) {
161 resolve(aWindow && aWindow.focused);
162 });
163 });
164 });
165 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/cryptotoken/cryptotokenbackground.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698