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

Unified Diff: chrome/ext/background.js

Issue 6622721232338944: Issue 1268 - Correctly mimic Chrome's behavior when opening the options page (Closed)
Patch Set: Created Aug. 26, 2014, 2:43 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 | « background.js ('k') | popup.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -365,4 +365,40 @@
/* Storage */
ext.storage = localStorage;
+
+
+ /* Options */
+
+ ext.showOptions = function(callback)
+ {
+ chrome.windows.getLastFocused(function(win)
+ {
+ var optionsUrl = chrome.extension.getURL("options.html");
+ var 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, function(tabs)
+ {
+ if (tabs.length > 0)
+ {
+ var tab = tabs[0];
+
+ chrome.windows.update(tab.windowId, {focused: true});
+ chrome.tabs.update(tab.id, {selected: true});
+
+ if (callback)
+ callback(new Page(tab));
+ }
+ else
+ {
+ ext.pages.open(optionsUrl, callback);
+ }
+ });
+ });
+ };
})();
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld