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

Unified Diff: ext/background.js

Issue 29527662: Noissue - Open options.html directly on Firefox for Android (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Don't check for tabs being null Created Aug. 25, 2017, 11:26 a.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
@@ -732,58 +732,56 @@
else
{
// Edge does not yet support runtime.openOptionsPage (tested version 38)
// nor does Firefox for Android,
// 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/
- 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 && !win.incognito)
- queryInfo.windowId = win.id;
-
- chrome.tabs.query(queryInfo, tabs =>
- {
- if (tabs && tabs.length > 0)
- {
- let tab = tabs[0];
-
- 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);
+ chrome.windows.getLastFocused(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)
+ queryInfo.windowId = win.id;
+
+ chrome.tabs.query(queryInfo, tabs =>
+ {
+ if (tabs.length > 0)
+ {
+ let tab = tabs[0];
+
+ 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);
+ }
+ });
+ });
}
else
{
// Firefox for Android does not support the windows API. Since there is
// effectively only one window on the mobile browser, there's no need
// to bring it into focus.
- open();
+ ext.pages.open("options.html", callback);
}
}
};
/* Windows */
ext.windows = {
create(createData, callback)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld