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

Delta Between Two Patch Sets: lib/appSupport.js

Issue 6286955629248512: disable acceptable ads from first run page (Closed)
Left Patch Set: trigger popstate event Created May 2, 2014, 11:09 a.m.
Right Patch Set: Description to getAddonsByTypes method and minore changes Created May 8, 2014, 2:37 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 | « no previous file | no next file » | 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
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 /** 18 /**
19 * @fileOverview Various application-specific functions. 19 * @fileOverview Various application-specific functions.
20 */ 20 */
21 21
22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
23 Cu.import("resource://gre/modules/Services.jsm"); 23 Cu.import("resource://gre/modules/Services.jsm");
24 Cu.import("resource://gre/modules/AddonManager.jsm");
24 25
25 /** 26 /**
26 * Checks whether an application window is known and should get Adblock Plus 27 * Checks whether an application window is known and should get Adblock Plus
27 * user interface elements. 28 * user interface elements.
28 * @result Boolean 29 * @result Boolean
29 */ 30 */
30 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) false; 31 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) false;
31 32
32 /** 33 /**
33 * HACK: In some applications the window finishes initialization during load 34 * HACK: In some applications the window finishes initialization during load
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 UI.openSubscriptionDialog = function(window, url, title, mainURL, mainTitle) 913 UI.openSubscriptionDialog = function(window, url, title, mainURL, mainTitle)
913 { 914 {
914 let dialogTitle = this.overlay.attributes.subscriptionDialogTitle; 915 let dialogTitle = this.overlay.attributes.subscriptionDialogTitle;
915 let dialogMessage = this.overlay.attributes.subscriptionDialogMessage.repl ace(/\?1\?/, title).replace(/\?2\?/, url); 916 let dialogMessage = this.overlay.attributes.subscriptionDialogMessage.repl ace(/\?1\?/, title).replace(/\?2\?/, url);
916 if (Utils.confirm(window, dialogMessage, dialogTitle)) 917 if (Utils.confirm(window, dialogMessage, dialogTitle))
917 this.setSubscription(url, title); 918 this.setSubscription(url, title);
918 }; 919 };
919 920
920 UI.openFiltersDialog = function() 921 UI.openFiltersDialog = function()
921 { 922 {
922 let window = this.currentWindow; 923 let window = UI.currentWindow;
Wladimir Palant 2014/05/02 11:50:00 Please use UI.currentWindow explicitly - it wasn't
saroyanm 2014/05/02 14:07:27 Done.
923 if (!window) 924 if (!window)
924 return 925 return
925 926
926 let browser = window.BrowserApp.addTab("about:addons").browser; 927 let browser = exports.addTab(window, "about:addons").browser;
Wladimir Palant 2014/05/02 11:50:00 How about: let browser = exports.addTab(window,
saroyanm 2014/05/02 14:07:27 Sorry for not being attentive on that..
927 browser.addEventListener("load", function openAddonPrefs(event) 928 browser.addEventListener("load", function openAddonPrefs(event)
928 { 929 {
929 browser.removeEventListener("load", openAddonPrefs, true); 930 browser.removeEventListener("load", openAddonPrefs, true);
930 browser._contentWindow.setTimeout(function() 931 Utils.runAsync(function()
saroyanm 2014/05/02 11:18:30 Couldn't find better approach while aboutAddons.js
Wladimir Palant 2014/05/02 11:50:00 Yes, you need to run this immediately after the pa
saroyanm 2014/05/02 14:07:27 Thanks for pointing on the method, gave me underst
931 { 932 {
932 let event = new Event("Event"); 933 // The page won't be ready until the add-on manager data is loaded so we call this method
933 event.initEvent("popstate", true, false); 934 // to know when the data will be ready.
934 event.state = {id: require("info").addonID}; 935 AddonManager.getAddonsByTypes(["extension", "theme", "locale"], functi on()
935 browser._contentWindow.dispatchEvent(event); 936 {
936 }, 200); 937 let event = new Event("Event");
938 event.initEvent("popstate", true, false);
939 event.state = {id: require("info").addonID};
940 browser._contentWindow.dispatchEvent(event);
941 });
942 });
937 }, true); 943 }, true);
Wladimir Palant 2014/05/02 11:50:00 I don't really see a point for having a capturing
saroyanm 2014/05/02 14:07:27 Yes actually It will not be triggered, not sure wh
938 }; 944 };
939 945
940 break; 946 break;
941 } 947 }
942 } 948 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld