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

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

Issue 5721433737003008: Issue 1985 - Replaced __proto__ with Object.create() and Object.getPrototypeOf() (Closed)
Patch Set: Created Feb. 11, 2015, 11:51 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/popup.js » ('j') | no next file with comments »
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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 chrome.windows.onFocusChanged.addListener(function(windowId) 313 chrome.windows.onFocusChanged.addListener(function(windowId)
314 { 314 {
315 if (windowId != chrome.windows.WINDOW_ID_NONE) 315 if (windowId != chrome.windows.WINDOW_ID_NONE)
316 updateContextMenu(); 316 updateContextMenu();
317 }); 317 });
318 318
319 319
320 /* Web requests */ 320 /* Web requests */
321 321
322 var framesOfTabs = {__proto__: null}; 322 var framesOfTabs = Object.create(null);
323 323
324 ext.getFrame = function(tabId, frameId) 324 ext.getFrame = function(tabId, frameId)
325 { 325 {
326 return (framesOfTabs[tabId] || {})[frameId]; 326 return (framesOfTabs[tabId] || {})[frameId];
327 }; 327 };
328 328
329 ext.webRequest = { 329 ext.webRequest = {
330 onBeforeRequest: new ext._EventTarget(), 330 onBeforeRequest: new ext._EventTarget(),
331 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged 331 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged
332 }; 332 };
333 333
334 chrome.tabs.query({}, function(tabs) 334 chrome.tabs.query({}, function(tabs)
335 { 335 {
336 tabs.forEach(function(tab) 336 tabs.forEach(function(tab)
337 { 337 {
338 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details) 338 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details)
339 { 339 {
340 if (details && details.length > 0) 340 if (details && details.length > 0)
341 { 341 {
342 var frames = framesOfTabs[tab.id] = {__proto__: null}; 342 var frames = framesOfTabs[tab.id] = Object.create.(null);
343 343
344 for (var i = 0; i < details.length; i++) 344 for (var i = 0; i < details.length; i++)
345 frames[details[i].frameId] = {url: details[i].url, parent: null}; 345 frames[details[i].frameId] = {url: details[i].url, parent: null};
346 346
347 for (var i = 0; i < details.length; i++) 347 for (var i = 0; i < details.length; i++)
348 { 348 {
349 var parentFrameId = details[i].parentFrameId; 349 var parentFrameId = details[i].parentFrameId;
350 350
351 if (parentFrameId != -1) 351 if (parentFrameId != -1)
352 frames[details[i].frameId].parent = frames[parentFrameId]; 352 frames[details[i].frameId].parent = frames[parentFrameId];
(...skipping 19 matching lines...) Expand all
372 // assume that the first request belongs to the top frame. Chrome 372 // assume that the first request belongs to the top frame. Chrome
373 // may give the top frame the type "object" instead of "main_frame". 373 // may give the top frame the type "object" instead of "main_frame".
374 // https://code.google.com/p/chromium/issues/detail?id=281711 374 // https://code.google.com/p/chromium/issues/detail?id=281711
375 details.frameId == 0 && !(details.tabId in framesOfTabs) 375 details.frameId == 0 && !(details.tabId in framesOfTabs)
376 ); 376 );
377 377
378 var frames = null; 378 var frames = null;
379 if (!isMainFrame) 379 if (!isMainFrame)
380 frames = framesOfTabs[details.tabId]; 380 frames = framesOfTabs[details.tabId];
381 if (!frames) 381 if (!frames)
382 frames = framesOfTabs[details.tabId] = {__proto__: null}; 382 frames = framesOfTabs[details.tabId] = Object.create(null);
383 383
384 var frame = null; 384 var frame = null;
385 if (!isMainFrame) 385 if (!isMainFrame)
386 { 386 {
387 // we are looking for the frame that contains the element that 387 // we are looking for the frame that contains the element that
388 // is about to load, however if a frame is loading the surrounding 388 // is about to load, however if a frame is loading the surrounding
389 // frame is indicated by parentFrameId instead of frameId 389 // frame is indicated by parentFrameId instead of frameId
390 var frameId; 390 var frameId;
391 if (requestType == "sub_frame") 391 if (requestType == "sub_frame")
392 frameId = details.parentFrameId; 392 frameId = details.parentFrameId;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 callback(new Page(tab)); 513 callback(new Page(tab));
514 } 514 }
515 else 515 else
516 { 516 {
517 ext.pages.open(optionsUrl, callback); 517 ext.pages.open(optionsUrl, callback);
518 } 518 }
519 }); 519 });
520 }); 520 });
521 }; 521 };
522 })(); 522 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/ext/popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld