OLD | NEW |
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 Loading... |
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 })(); |
OLD | NEW |