Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/background.js

Issue 29516569: Issue 5347 - Check for windows API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Aug. 15, 2017, 2:08 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
===================================================================
--- a/ext/background.js
+++ b/ext/background.js
@@ -483,21 +483,24 @@
updateContextMenu();
}
}
}
};
chrome.tabs.onActivated.addListener(updateContextMenu);
- chrome.windows.onFocusChanged.addListener(windowId =>
+ if ("windows" in chrome)
{
- if (windowId != chrome.windows.WINDOW_ID_NONE)
- updateContextMenu();
- });
+ chrome.windows.onFocusChanged.addListener(windowId =>
+ {
+ if (windowId != chrome.windows.WINDOW_ID_NONE)
+ updateContextMenu();
+ });
+ }
/* Web requests */
let framesOfTabs = new Map();
ext.getFrame = (tabId, frameId) =>
{
@@ -698,51 +701,61 @@
{
// Edge does not yet support runtime.openOptionsPage (tested version 38)
Sebastian Noack 2017/08/15 14:40:19 This comment should be updated, also mentioning Fi
Manish Jethani 2017/08/15 16:24:12 I'm going to make another change for runtime.openO
// and so this workaround needs to stay for now.
// We are not using extension.getURL to get the absolute path here
// because of the Edge issue:
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10276332/
ext.showOptions = callback =>
{
- chrome.windows.getLastFocused(win =>
+ let optionsUrl = "options.html";
+ let queryInfo = {url: optionsUrl};
+
+ let open = win =>
{
- let optionsUrl = "options.html";
- let queryInfo = {url: optionsUrl};
-
// extension pages can't be accessed in incognito windows. In order to
// correctly mimic the way in which Chrome opens extension options,
// we have to focus the options page in any other window.
- if (!win.incognito)
+ if (win && !win.incognito)
queryInfo.windowId = win.id;
chrome.tabs.query(queryInfo, tabs =>
{
if (tabs.length > 0)
{
let tab = tabs[0];
- chrome.windows.update(tab.windowId, {focused: true});
+ if ("windows" in chrome)
+ chrome.windows.update(tab.windowId, {focused: true});
+
chrome.tabs.update(tab.id, {active: true});
if (callback)
callback(new Page(tab));
}
else
{
ext.pages.open(optionsUrl, callback);
}
});
- });
+ };
+
+ if ("windows" in chrome)
+ chrome.windows.getLastFocused(open);
+ else
+ open();
};
}
/* Windows */
- ext.windows = {
- create(createData, callback)
- {
- chrome.windows.create(createData, createdWindow =>
+ if ("windows" in chrome)
+ {
+ ext.windows = {
Sebastian Noack 2017/08/15 14:40:19 What is about the code using ext.windows? I suppos
Manish Jethani 2017/08/15 16:24:12 ext.windows is only used from lib/filterComposer.j
Sebastian Noack 2017/08/18 10:25:21 I guess we can just leave the code here unchanged
Manish Jethani 2017/08/18 14:09:58 I just checked and the only way ext.windows can be
+ create(createData, callback)
{
- afterTabLoaded(callback)(createdWindow.tabs[0]);
- });
- }
- };
+ chrome.windows.create(createData, createdWindow =>
+ {
+ afterTabLoaded(callback)(createdWindow.tabs[0]);
+ });
+ }
+ };
+ }
}());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld