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

Side by Side Diff: chrome/ext/background.js

Issue 6276084194607104: Issue 338 - Updated minimum version to Chrome 28 and got rid of legacy compatibility code (Closed)
Patch Set: Created April 16, 2014, 9:54 a.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 | « no previous file | chrome/ext/common.js » ('j') | popupBlocker.js » ('J')
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() 18 (function()
19 { 19 {
20 /* Pages */ 20 /* Pages */
21 21
22 var sendMessage = chrome.tabs.sendMessage || chrome.tabs.sendRequest;
23
24 var Page = ext.Page = function(tab) 22 var Page = ext.Page = function(tab)
25 { 23 {
26 this._id = tab.id; 24 this._id = tab.id;
27 this._url = tab.url; 25 this._url = tab.url;
28 26
29 this.browserAction = new BrowserAction(tab.id); 27 this.browserAction = new BrowserAction(tab.id);
30 }; 28 };
31 Page.prototype = { 29 Page.prototype = {
32 get url() 30 get url()
33 { 31 {
(...skipping 12 matching lines...) Expand all
46 if (frame) 44 if (frame)
47 return frame.url; 45 return frame.url;
48 } 46 }
49 }, 47 },
50 activate: function() 48 activate: function()
51 { 49 {
52 chrome.tabs.update(this._id, {selected: true}); 50 chrome.tabs.update(this._id, {selected: true});
53 }, 51 },
54 sendMessage: function(message, responseCallback) 52 sendMessage: function(message, responseCallback)
55 { 53 {
56 sendMessage(this._id, message, responseCallback); 54 chrome.tabs.sendMessage(this._id, message, responseCallback);
57 } 55 }
58 }; 56 };
59 57
60 ext.pages = { 58 ext.pages = {
61 open: function(url, callback) 59 open: function(url, callback)
62 { 60 {
63 if (callback) 61 if (callback)
64 { 62 {
65 chrome.tabs.create({url: url}, function(openedTab) 63 chrome.tabs.create({url: url}, function(openedTab)
66 { 64 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 return; 308 return;
311 309
312 chrome.contextMenus.removeAll(); 310 chrome.contextMenus.removeAll();
313 isContextMenuHidden = true; 311 isContextMenuHidden = true;
314 } 312 }
315 }; 313 };
316 314
317 315
318 /* Message passing */ 316 /* Message passing */
319 317
320 ext._setupMessageListener(function(sender) 318 chrome.runtime.onMessage.addListener(function(message, rawSender, sendResponse )
321 { 319 {
322 return { 320 var sender = {
323 page: new Page(sender.tab), 321 page: new Page(rawSender.tab),
324 frame: { 322 frame: {
325 url: sender.url, 323 url: rawSender.url,
326 get parent() 324 get parent()
327 { 325 {
328 var frames = framesOfTabs[sender.tab.id]; 326 var frames = framesOfTabs[rawSender.tab.id];
329 327
330 if (!frames) 328 if (!frames)
331 return null; 329 return null;
332 330
333 for (var frameId in frames) 331 for (var frameId in frames)
334 { 332 {
335 if (frames[frameId].url == sender.url) 333 if (frames[frameId].url == rawSender.url)
336 return frames[frameId].parent; 334 return frames[frameId].parent;
337 } 335 }
338 336
339 return frames[0]; 337 return frames[0];
340 } 338 }
341 } 339 }
342 }; 340 };
341
342 return ext.onMessage._dispatch(message, sender, sendResponse);
343 }); 343 });
344 344
345 345
346 /* Storage */ 346 /* Storage */
347 347
348 ext.storage = localStorage; 348 ext.storage = localStorage;
349 })(); 349 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/ext/common.js » ('j') | popupBlocker.js » ('J')

Powered by Google App Engine
This is Rietveld