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

Side by Side Diff: chrome/content/ui/sidebar.js

Issue 29333172: Issue 3259 - Store blockable items selection in the content process (Closed)
Patch Set: Created Jan. 4, 2016, 8:08 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 | lib/child/requestNotifier.js » ('j') | lib/requestNotifier.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 <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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 let defaults = {screenX: 0, screenY: 0, width: 600, height: 300}; 82 let defaults = {screenX: 0, screenY: 0, width: 600, height: 300};
83 if (params && params.position) 83 if (params && params.position)
84 defaults = params.position; 84 defaults = params.position;
85 85
86 let wnd = parent.document.documentElement; 86 let wnd = parent.document.documentElement;
87 for (let attr in defaults) 87 for (let attr in defaults)
88 if (!wnd.hasAttribute(attr)) 88 if (!wnd.hasAttribute(attr))
89 wnd.setAttribute(attr, defaults[attr]); 89 wnd.setAttribute(attr, defaults[attr]);
90 } 90 }
91 91
92 let {getBrowser, addBrowserLocationListener} = require("appSupport"); 92 let {addBrowserLocationListener} = require("appSupport");
93 updateContentLocation(); 93 updateContentLocation();
94 Object.defineProperty(window, "content", { get: () => getBrowser(mainWin).cont entWindow });
95 94
96 // Initialize matcher for disabled filters 95 // Initialize matcher for disabled filters
97 reloadDisabledFilters(); 96 reloadDisabledFilters();
98 FilterNotifier.addListener(reloadDisabledFilters); 97 FilterNotifier.addListener(reloadDisabledFilters);
99 Prefs.addListener(onPrefChange); 98 Prefs.addListener(onPrefChange);
100 99
101 // Activate flasher 100 // Activate flasher
102 list.addEventListener("select", onSelectionChange, false); 101 list.addEventListener("select", onSelectionChange, false);
103 102
104 // Initialize data 103 // Initialize data
(...skipping 14 matching lines...) Expand all
119 118
120 function updateContentLocation() 119 function updateContentLocation()
121 { 120 {
122 let {getCurrentLocation} = require("appSupport"); 121 let {getCurrentLocation} = require("appSupport");
123 let location = getCurrentLocation(mainWin); 122 let location = getCurrentLocation(mainWin);
124 if (location instanceof Ci.nsIURI) 123 if (location instanceof Ci.nsIURI)
125 location = location.spec; 124 location = location.spec;
126 contentLocation = location; 125 contentLocation = location;
127 } 126 }
128 127
128 function getOuterWindowID()
129 {
130 let {getBrowser} = require("appSupport");
131 let browser = getBrowser(mainWin);
132 if ("selectedBrowser" in browser)
133 browser = browser.selectedBrowser;
134 return browser.outerWindowID;
135 }
136
129 function getFilter(item) 137 function getFilter(item)
130 { 138 {
131 if ("filter" in item && item.filter) 139 if ("filter" in item && item.filter)
132 return Filter.fromText(item.filter); 140 return Filter.fromText(item.filter);
133 else 141 else
134 return null; 142 return null;
135 } 143 }
136 144
137 // To be called on unload 145 // To be called on unload
138 function cleanUp() { 146 function cleanUp() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 203 }
196 204
197 // Called whenever list selection changes - triggers flasher 205 // Called whenever list selection changes - triggers flasher
198 function onSelectionChange() { 206 function onSelectionChange() {
199 var item = treeView.getSelectedItem(); 207 var item = treeView.getSelectedItem();
200 if (item) 208 if (item)
201 E("copy-command").removeAttribute("disabled"); 209 E("copy-command").removeAttribute("disabled");
202 else 210 else
203 E("copy-command").setAttribute("disabled", "true"); 211 E("copy-command").setAttribute("disabled", "true");
204 212
205 if (item && window.content) 213 if (item)
206 { 214 {
207 let key = item.location + " " + item.type + " " + item.docDomain; 215 let key = item.location + " " + item.type + " " + item.docDomain;
208 RequestNotifier.storeSelection(window.content, key); 216 RequestNotifier.storeWindowData(getOuterWindowID(), key);
209 treeView.itemToSelect = null; 217 treeView.itemToSelect = null;
210 } 218 }
211 219
212 if (requestNotifier) 220 if (requestNotifier)
213 requestNotifier.flashNodes(item ? item.ids : null, Prefs.flash_scrolltoitem) ; 221 requestNotifier.flashNodes(item ? item.ids : null, Prefs.flash_scrolltoitem) ;
214 } 222 }
215 223
216 function handleLocationChange() 224 function handleLocationChange()
217 { 225 {
218 if (requestNotifier) 226 if (requestNotifier)
219 requestNotifier.shutdown(); 227 requestNotifier.shutdown();
220 228
221 updateContentLocation(); 229 updateContentLocation();
222 treeView.clearData(); 230 treeView.clearData();
223 231
224 let {getBrowser, addBrowserLocationListener} = require("appSupport"); 232 let outerWindowID = getOuterWindowID();
225 let browser = getBrowser(mainWin); 233 RequestNotifier.retrieveWindowData(outerWindowID, key =>
226 if ("selectedBrowser" in browser) 234 {
227 browser = browser.selectedBrowser; 235 treeView.itemToSelect = key;
228 let outerWindowID = browser.outerWindowID; 236 });
229 if (window.content) 237 requestNotifier = new RequestNotifier(outerWindowID, (item, scanComplete) =>
230 treeView.itemToSelect = RequestNotifier.getSelection(window.content);
231 requestNotifier = new RequestNotifier(outerWindowID, function(item, scanComple te)
232 { 238 {
233 if (item) 239 if (item)
234 treeView.addItem(item, scanComplete); 240 treeView.addItem(item, scanComplete);
235 }); 241 });
236 cacheStorage = null; 242 cacheStorage = null;
237 } 243 }
238 244
239 // Fills a box with text splitting it up into multiple lines if necessary 245 // Fills a box with text splitting it up into multiple lines if necessary
240 function setMultilineContent(box, text, noRemove) 246 function setMultilineContent(box, text, noRemove)
241 { 247 {
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 return {tooltip: this.itemsDummyTooltip}; 1336 return {tooltip: this.itemsDummyTooltip};
1331 }, 1337 },
1332 1338
1333 invalidateItem: function(item) 1339 invalidateItem: function(item)
1334 { 1340 {
1335 let row = this.data.indexOf(item); 1341 let row = this.data.indexOf(item);
1336 if (row >= 0) 1342 if (row >= 0)
1337 this.boxObject.invalidateRow(row); 1343 this.boxObject.invalidateRow(row);
1338 } 1344 }
1339 } 1345 }
OLDNEW
« no previous file with comments | « no previous file | lib/child/requestNotifier.js » ('j') | lib/requestNotifier.js » ('J')

Powered by Google App Engine
This is Rietveld