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

Delta Between Two Patch Sets: chrome/ext/background.js

Issue 29336084: Issue 2426 - Open block.html as a popup window (Closed)
Left Patch Set: Pass tab directly instead of getTab callback Created Feb. 11, 2016, 3:19 p.m.
Right Patch Set: Assume createData parameter has been given Created Feb. 17, 2016, 8:50 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « blockElement.postload.js ('k') | ext/background.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 }; 53 };
54 54
55 ext.getPage = function(id) 55 ext.getPage = function(id)
56 { 56 {
57 return new Page({id: parseInt(id, 10)}); 57 return new Page({id: parseInt(id, 10)});
58 }; 58 };
59 59
60 function afterTabLoaded(callback) 60 function afterTabLoaded(callback)
61 { 61 {
62 if (callback) 62 return function(openedTab)
63 { 63 {
64 return function(openedTab) 64 var onUpdated = function(tabId, changeInfo, tab)
65 { 65 {
66 var onUpdated = function(tabId, changeInfo, tab) 66 if (tabId == openedTab.id && changeInfo.status == "complete")
67 { 67 {
68 if (tabId == openedTab.id && changeInfo.status == "complete") 68 chrome.tabs.onUpdated.removeListener(onUpdated);
69 { 69 callback(new Page(openedTab));
70 chrome.tabs.onUpdated.removeListener(onUpdated); 70 }
71 callback(new Page(openedTab)); 71 };
72 } 72 chrome.tabs.onUpdated.addListener(onUpdated);
73 }; 73 };
74 chrome.tabs.onUpdated.addListener(onUpdated);
75 };
76 }
77 } 74 }
78 75
79 ext.pages = { 76 ext.pages = {
80 open: function(url, callback) 77 open: function(url, callback)
81 { 78 {
82 chrome.tabs.create({url: url}, afterTabLoaded(callback)); 79 chrome.tabs.create({url: url}, callback && afterTabLoaded(callback));
Sebastian Noack 2016/02/12 17:00:00 I'd rather check here for the callback: callbac
kzar 2016/02/13 14:18:12 Done.
83 }, 80 },
84 query: function(info, callback) 81 query: function(info, callback)
85 { 82 {
86 var rawInfo = {}; 83 var rawInfo = {};
87 for (var property in info) 84 for (var property in info)
88 { 85 {
89 switch (property) 86 switch (property)
90 { 87 {
91 case "active": 88 case "active":
92 case "lastFocusedWindow": 89 case "lastFocusedWindow":
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 ext.windows = { 594 ext.windows = {
598 create: function(createData, callback) 595 create: function(createData, callback)
599 { 596 {
600 chrome.windows.create(createData, function(createdWindow) 597 chrome.windows.create(createData, function(createdWindow)
601 { 598 {
602 afterTabLoaded(callback)(createdWindow.tabs[0]); 599 afterTabLoaded(callback)(createdWindow.tabs[0]);
603 }); 600 });
604 } 601 }
605 }; 602 };
606 })(); 603 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld