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

Delta Between Two Patch Sets: safari/ext/background.js

Issue 5735785512828928: Remove tabs from TabMap onLoading instead of onBeforeNavigate on Safari (Closed)
Left Patch Set: Created Jan. 23, 2014, 11:33 a.m.
Right Patch Set: Apparently you can used the reserved keyword "delete" as key when defining inline objects Created Jan. 23, 2014, 3:24 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 | « chrome/ext/background.js ('k') | 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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }, 103 },
104 sendMessage: function(message, responseCallback) 104 sendMessage: function(message, responseCallback)
105 { 105 {
106 _sendMessage( 106 _sendMessage(
107 message, responseCallback, 107 message, responseCallback,
108 this._tab.page, this._tab 108 this._tab.page, this._tab
109 ); 109 );
110 } 110 }
111 }; 111 };
112 112
113 TabMap = function(deleteTabOnLoading) 113 TabMap = function(deleteOnPageUnload)
Wladimir Palant 2014/01/23 13:34:13 Having to change a parameter name just because the
Sebastian Noack 2014/01/23 13:51:13 Done.
114 { 114 {
115 this._tabs = [];
Wladimir Palant 2014/01/23 13:34:13 This property is no longer in use.
Sebastian Noack 2014/01/23 13:51:13 Done.
116 this._data = []; 115 this._data = [];
116 this._deleteOnPageUnload = deleteOnPageUnload;
117 117
118 this.delete = this.delete.bind(this); 118 this.delete = this.delete.bind(this);
119 this._delete = this._delete.bind(this); 119 this._delete = this._delete.bind(this);
120
121 this._deleteTabOnLoading = deleteTabOnLoading;
122 }; 120 };
123 TabMap.prototype = 121 TabMap.prototype =
124 { 122 {
125 _indexOf: function(tab) 123 _indexOf: function(tab)
126 { 124 {
127 for (var i = 0; i < this._data.length; i++) 125 for (var i = 0; i < this._data.length; i++)
128 if (this._data[i].tab._tab == tab._tab) 126 if (this._data[i].tab._tab == tab._tab)
129 return i; 127 return i;
130 128
131 return -1; 129 return -1;
(...skipping 15 matching lines...) Expand all
147 { 145 {
148 var idx = this._indexOf(tab); 146 var idx = this._indexOf(tab);
149 147
150 if (idx != -1) 148 if (idx != -1)
151 this._data[idx].value = value; 149 this._data[idx].value = value;
152 else 150 else
153 { 151 {
154 this._data.push({value: value, tab: tab}); 152 this._data.push({value: value, tab: tab});
155 153
156 tab.onRemoved.addListener(this._delete); 154 tab.onRemoved.addListener(this._delete);
157 if (this._deleteTabOnLoading) 155 if (this._deleteOnPageUnload)
158 tab.onLoading.addListener(this.delete); 156 tab.onLoading.addListener(this.delete);
Wladimir Palant 2014/01/23 13:34:13 What if about:blank is loaded into the tab or some
Sebastian Noack 2014/01/23 13:51:13 I've just checked that. And surprisingly our conte
159 } 157 }
160 }, 158 },
161 has: function(tab) 159 has: function(tab)
162 { 160 {
163 return this._indexOf(tab) != -1; 161 return this._indexOf(tab) != -1;
164 }, 162 },
165 clear: function() 163 clear: function()
166 { 164 {
167 while (this._data.length > 0) 165 while (this._data.length > 0)
168 this.delete(this._data[0].tab); 166 this.delete(this._data[0].tab);
169 } 167 },
170 }; 168 delete: function(tab)
171 TabMap.prototype["delete"] = function(tab) 169 {
Wladimir Palant 2014/01/23 13:34:13 I am still wondering why this method isn't defined
Sebastian Noack 2014/01/23 13:51:13 It leads to a syntax error, at least in Safari and
Wladimir Palant 2014/01/23 14:44:37 No, for me it doesn't (tested in Safari 7.0 and Ch
Sebastian Noack 2014/01/23 15:27:44 You are right. I tried it in the console, and in t
172 { 170 var idx = this._indexOf(tab);
173 var idx = this._indexOf(tab); 171
174 172 if (idx != -1)
175 if (idx != -1) 173 {
176 { 174 tab = this._data[idx].tab;
177 tab = this._data[idx].tab; 175 this._data.splice(idx, 1);
178 this._data.splice(idx, 1); 176
179 177 tab.onRemoved.removeListener(this._delete);
180 tab.onRemoved.removeListener(this._delete); 178 tab.onLoading.removeListener(this.delete);
181 tab.onLoading.removeListener(this.delete); 179 }
182 } 180 }
183 }; 181 };
184 182
185 ext.tabs = { 183 ext.tabs = {
186 onLoading: new LoadingTabEventTarget(safari.application), 184 onLoading: new LoadingTabEventTarget(safari.application),
187 onCompleted: new TabEventTarget(safari.application, "navigate", true), 185 onCompleted: new TabEventTarget(safari.application, "navigate", true),
188 onActivated: new TabEventTarget(safari.application, "activate", true), 186 onActivated: new TabEventTarget(safari.application, "activate", true),
189 onRemoved: new TabEventTarget(safari.application, "close", true) 187 onRemoved: new TabEventTarget(safari.application, "close", true)
190 }; 188 };
191 189
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 for (var i = 0; i < contextMenuItems.length; i++) 706 for (var i = 0; i < contextMenuItems.length; i++)
709 { 707 {
710 if (contextMenuItems[i].id == event.command) 708 if (contextMenuItems[i].id == event.command)
711 { 709 {
712 contextMenuItems[i].onclick(event.userInfo.srcUrl, new Tab(safari.applic ation.activeBrowserWindow.activeTab)); 710 contextMenuItems[i].onclick(event.userInfo.srcUrl, new Tab(safari.applic ation.activeBrowserWindow.activeTab));
713 break; 711 break;
714 } 712 }
715 } 713 }
716 }, false); 714 }, false);
717 })(); 715 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld