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

Side by Side Diff: firstRun.js

Issue 8689042: adblockpluschrome: Handle invalid share popup sites (Closed)
Patch Set: Created Oct. 25, 2012, 3:38 p.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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var backgroundPage = chrome.extension.getBackgroundPage(); 1 var backgroundPage = chrome.extension.getBackgroundPage();
2 var require = backgroundPage.require; 2 var require = backgroundPage.require;
3 var Prefs = require("prefs").Prefs; 3 var Prefs = require("prefs").Prefs;
4 var Utils = require("utils").Utils; 4 var Utils = require("utils").Utils;
5 5
6 function openSharePopup(url) 6 function openSharePopup(url)
7 { 7 {
8 var iframe = document.getElementById("share-popup"); 8 var iframe = document.getElementById("share-popup");
9 var glassPane = document.getElementById("glass-pane"); 9 var glassPane = document.getElementById("glass-pane");
10 var popupMessageReceived = false;
10 11
11 var popupMessageListener = function(event) 12 var popupMessageListener = function(event)
12 { 13 {
13 if (event.origin !== url) 14 if (event.origin !== url)
14 return; 15 return;
15 16
16 iframe.width = event.data.width; 17 iframe.width = event.data.width;
17 iframe.height = event.data.height; 18 iframe.height = event.data.height;
19 popupMessageReceived = true;
18 window.removeEventListener("message", popupMessageListener); 20 window.removeEventListener("message", popupMessageListener);
19 }; 21 };
20 window.addEventListener("message", popupMessageListener, false); 22 window.addEventListener("message", popupMessageListener, false);
21 23
22 var popupLoadListener = function() 24 var popupLoadListener = function()
23 { 25 {
24 iframe.className = "visible"; 26 if (popupMessageReceived)
27 {
28 iframe.className = "visible";
25 29
26 var popupCloseListener = function() 30 var popupCloseListener = function()
27 { 31 {
28 iframe.className = glassPane.className = ""; 32 iframe.className = glassPane.className = "";
29 document.removeEventListener("click", popupCloseListener); 33 document.removeEventListener("click", popupCloseListener);
30 }; 34 };
31 document.addEventListener("click", popupCloseListener, false); 35 document.addEventListener("click", popupCloseListener, false);
36 }
37 else
38 glassPane.className = "";
Wladimir Palant 2012/10/25 15:54:15 Also remove message listener here?
Felix Dahlke 2012/10/25 15:57:11 Done.
39
32 iframe.removeEventListener("load", popupLoadListener); 40 iframe.removeEventListener("load", popupLoadListener);
33 }; 41 };
34 iframe.addEventListener("load", popupLoadListener, false); 42 iframe.addEventListener("load", popupLoadListener, false);
35 43
36 iframe.src = url; 44 iframe.src = url;
37 glassPane.className = "visible"; 45 glassPane.className = "visible";
38 } 46 }
39 47
40 function initSocialLinks(variant) 48 function initSocialLinks(variant)
41 { 49 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 111 }
104 } 112 }
105 } 113 }
106 114
107 function getDocLink(page, anchor) 115 function getDocLink(page, anchor)
108 { 116 {
109 return Prefs.documentation_link 117 return Prefs.documentation_link
110 .replace(/%LINK%/g, page) 118 .replace(/%LINK%/g, page)
111 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); 119 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" );
112 } 120 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld