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

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

Issue 5464830253203456: Refactored the abstraction layer to address prerendered pages on Safari caused by leaky abstraction (Closed)
Left Patch Set: Rebased and addressed comments Created April 7, 2014, 1:14 p.m.
Right Patch Set: Addressed comments Created April 11, 2014, 2:47 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 | « background.js ('k') | chrome/ext/common.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 <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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 74 };
75 chrome.tabs.onUpdated.addListener(onUpdated); 75 chrome.tabs.onUpdated.addListener(onUpdated);
76 }); 76 });
77 } 77 }
78 else 78 else
79 chrome.tabs.create({url: url}); 79 chrome.tabs.create({url: url});
80 }, 80 },
81 query: function(info, callback) 81 query: function(info, callback)
82 { 82 {
83 var rawInfo = {}; 83 var rawInfo = {};
84 var visibleWindow = null;
85
86 for (var property in info) 84 for (var property in info)
87 { 85 {
88 switch (property) 86 switch (property)
89 { 87 {
90 case "active": 88 case "active":
91 case "lastFocusedWindow": 89 case "lastFocusedWindow":
92 rawInfo[property] = info[property]; 90 rawInfo[property] = info[property];
93 break;
94 case "visibleWindow":
95 visibleWindow = info[property];
96 break;
97 } 91 }
98 } 92 }
99 93
100 chrome.tabs.query(rawInfo, function(tabs) 94 chrome.tabs.query(rawInfo, function(tabs)
101 { 95 {
102 if (visibleWindow != null && tabs.length > 0) 96 callback(tabs.map(function(tab)
103 { 97 {
104 var windows = {__proto__: null}; 98 return new Page(tab);
105 var pending = 0; 99 }));
106
107 for (var i = 0; i < tabs.length; i++)
108 {
109 var windowId = tabs[i].windowId;
110 if (!(windowId in windows))
111 {
112 windows[windowId] = null;
113 pending++;
114
115 chrome.windows.get(windowId, null, function(win)
116 {
117 if (visibleWindow != (win.state != "minimized"))
118 {
119 for (var j = 0; j < tabs.length; j++)
120 {
121 if (tabs[j].windowId == win.id)
122 tabs.splice(j--, 1);
123 }
124 }
125
126 if (--pending == 0)
127 callback(tabs.map(function(tab)
128 {
129 return new Page(tab);
130 }));
131 });
132 }
133 }
134 }
135 else
136 {
137 callback(tabs.map(function(tab)
138 {
139 return new Page(tab);
140 }));
141 }
142 }); 100 });
143 }, 101 },
144 onLoading: new ext._EventTarget() 102 onLoading: new ext._EventTarget()
145 }; 103 };
146 104
147 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 105 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
148 { 106 {
149 if (changeInfo.status == "loading") 107 if (changeInfo.status == "loading")
150 ext.pages.onLoading._dispatch(new Page(tab)); 108 ext.pages.onLoading._dispatch(new Page(tab));
151 }); 109 });
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 page: new Page(sender.tab), 364 page: new Page(sender.tab),
407 frame: new Frame({url: sender.url, tabId: sender.tab.id}) 365 frame: new Frame({url: sender.url, tabId: sender.tab.id})
408 }; 366 };
409 }); 367 });
410 368
411 369
412 /* Storage */ 370 /* Storage */
413 371
414 ext.storage = localStorage; 372 ext.storage = localStorage;
415 })(); 373 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld