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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 358 }
359 }; 359 };
360 360
361 return ext.onMessage._dispatch(message, sender, sendResponse); 361 return ext.onMessage._dispatch(message, sender, sendResponse);
362 }); 362 });
363 363
364 364
365 /* Storage */ 365 /* Storage */
366 366
367 ext.storage = localStorage; 367 ext.storage = localStorage;
368
369
370 /* Options */
371
372 ext.showOptions = function(callback)
373 {
374 chrome.windows.getLastFocused(function(win)
375 {
376 var optionsUrl = chrome.extension.getURL("options.html");
377 var queryInfo = {url: optionsUrl};
378
379 // extension pages can't be accessed in incognito windows. In order to
380 // correctly mimic the way in which Chrome opens extension options,
381 // we have to focus the options page in any other window.
382 if (!win.incognito)
383 queryInfo.windowId = win.id;
384
385 chrome.tabs.query(queryInfo, function(tabs)
386 {
387 if (tabs.length > 0)
388 {
389 var tab = tabs[0];
390
391 chrome.windows.update(tab.windowId, {focused: true});
392 chrome.tabs.update(tab.id, {selected: true});
393
394 if (callback)
395 callback(new Page(tab));
396 }
397 else
398 {
399 ext.pages.open(optionsUrl, callback);
400 }
401 });
402 });
403 };
368 })(); 404 })();
OLDNEW
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld