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: Addressed some initial feedback Created Feb. 10, 2016, 2:18 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 { 50 {
51 chrome.tabs.sendMessage(this.id, message, responseCallback); 51 chrome.tabs.sendMessage(this.id, message, responseCallback);
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, getTab) 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 if (getTab) 66 if (tabId == openedTab.id && changeInfo.status == "complete")
67 openedTab = getTab(openedTab); 67 {
68 68 chrome.tabs.onUpdated.removeListener(onUpdated);
69 var onUpdated = function(tabId, changeInfo, tab) 69 callback(new Page(openedTab));
70 { 70 }
71 if (tabId == openedTab.id && changeInfo.status == "complete") 71 };
72 { 72 chrome.tabs.onUpdated.addListener(onUpdated);
73 chrome.tabs.onUpdated.removeListener(onUpdated); 73 };
74 callback(new Page(openedTab));
75 }
76 };
77 chrome.tabs.onUpdated.addListener(onUpdated);
78 };
79 }
80 } 74 }
81 75
82 ext.pages = { 76 ext.pages = {
83 open: function(url, callback) 77 open: function(url, callback)
84 { 78 {
85 chrome.tabs.create({url: url}, afterTabLoaded(callback)); 79 chrome.tabs.create({url: url}, callback && afterTabLoaded(callback));
86 }, 80 },
87 query: function(info, callback) 81 query: function(info, callback)
88 { 82 {
89 var rawInfo = {}; 83 var rawInfo = {};
90 for (var property in info) 84 for (var property in info)
91 { 85 {
92 switch (property) 86 switch (property)
93 { 87 {
94 case "active": 88 case "active":
95 case "lastFocusedWindow": 89 case "lastFocusedWindow":
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 ext.pages.open(optionsUrl, callback); 587 ext.pages.open(optionsUrl, callback);
594 } 588 }
595 }); 589 });
596 }); 590 });
597 }; 591 };
598 592
599 /* Windows */ 593 /* Windows */
600 ext.windows = { 594 ext.windows = {
601 create: function(createData, callback) 595 create: function(createData, callback)
602 { 596 {
603 function getFirstTab(createdWindow) 597 chrome.windows.create(createData, function(createdWindow)
604 { 598 {
605 return createdWindow.tabs[0]; 599 afterTabLoaded(callback)(createdWindow.tabs[0]);
Sebastian Noack 2016/02/10 14:43:24 Why don't you simply pass the tab in instead of a
kzar 2016/02/11 15:20:21 Done.
606 } 600 });
607 chrome.windows.create(createData, afterTabLoaded(callback, getFirstTab));
608 } 601 }
609 }; 602 };
610 })(); 603 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld