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

Delta Between Two Patch Sets: background.js

Issue 8560083: adblockplusopera: Port UI code from Chrome (Closed)
Left Patch Set: Created Oct. 18, 2012, 1:26 p.m.
Right Patch Set: Created Oct. 19, 2012, 4:04 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 | button.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 var DownloadableSubscription = require("subscriptionClasses").DownloadableSubscr iption; 1 var DownloadableSubscription = require("subscriptionClasses").DownloadableSubscr iption;
2 var WhitelistFilter = require("filterClasses").WhitelistFilter; 2 var WhitelistFilter = require("filterClasses").WhitelistFilter;
3 var FilterNotifier = require("filterNotifier").FilterNotifier; 3 var FilterNotifier = require("filterNotifier").FilterNotifier;
4 var FilterStorage = require("filterStorage").FilterStorage; 4 var FilterStorage = require("filterStorage").FilterStorage;
5 var Prefs = require("prefs").Prefs; 5 var Prefs = require("prefs").Prefs;
6 var Synchronizer = require("synchronizer").Synchronizer; 6 var Synchronizer = require("synchronizer").Synchronizer;
7 var Subscription = require("subscriptionClasses").Subscription; 7 var Subscription = require("subscriptionClasses").Subscription;
8 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; 8 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription;
9 var Utils = require("utils").Utils; 9 var Utils = require("utils").Utils;
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 toolbar.addItem(toolbarButton); 181 toolbar.addItem(toolbarButton);
182 else 182 else
183 toolbar.removeItem(toolbarButton); 183 toolbar.removeItem(toolbarButton);
184 } 184 }
185 185
186 function getJson(url) 186 function getJson(url)
187 { 187 {
188 var request = new XMLHttpRequest(); 188 var request = new XMLHttpRequest();
189 request.open("GET", url, false); 189 request.open("GET", url, false);
190 request.responseType = "json"; 190 request.responseType = "json";
191 request.send(); 191 request.send();
Wladimir Palant 2012/10/19 15:47:41 There is still a potential unhandled exception her
Felix Dahlke 2012/10/19 16:07:27 Yes, it will return an undefined value. My first a
Wladimir Palant 2012/10/22 08:57:51 Ok, it seems that the widget:// protocol behaves d
192 return request.response; 192 return request.response;
193 } 193 }
194 194
195 function loadMessagesForLocale(locale) 195 function loadMessagesForLocale(locale)
196 { 196 {
197 var messagesFileName = "messages.json"; 197 var messagesFileName = "messages.json";
198 var messagesPath; 198 var messagesPath;
199 if (locale) 199 if (locale)
200 messagesPath = "locales/" + locale + "/" + messagesFileName; 200 messagesPath = "locales/" + locale + "/" + messagesFileName;
201 else 201 else
202 messagesPath = messagesFileName; 202 messagesPath = messagesFileName;
203 203
204 var messages = getJson(messagesPath); 204 var messages = getJson(messagesPath);
205 if (!messages) 205 if (!messages)
206 { 206 {
207 console.error("Failed to load messages for locale " 207 console.error("Failed to load messages for locale "
208 + (locale ? locale : "default")); 208 + (locale ? locale : "default"));
209 return; 209 return;
210 } 210 }
211 211
212 for (var i in messages) 212 for (var i in messages)
213 i18nMessages[i] = messages[i]; 213 i18nMessages[i] = messages[i];
214 } 214 }
215 215
216 function loadI18nMessages() 216 function loadI18nMessages()
217 { 217 {
218 i18nMessages = {};
219
220 // Could be parsed from config.xml 218 // Could be parsed from config.xml
221 var defaultLocale = "en"; 219 var defaultLocale = "en";
222 220
223 if (locale !== defaultLocale) 221 i18nMessages = {};
Wladimir Palant 2012/10/19 15:47:41 I'm not really happy with the hack you use to defi
Felix Dahlke 2012/10/19 16:07:27 Done. It's not necessary anymore and I'm frankly h
224 loadMessagesForLocale(defaultLocale); 222 loadMessagesForLocale(defaultLocale);
225
226 loadMessagesForLocale(); 223 loadMessagesForLocale();
227 } 224 }
228 225
229 setDefaultOptions(); 226 setDefaultOptions();
230 createToolbarButton(); 227 createToolbarButton();
231 refreshToolbarButton(); 228 refreshToolbarButton();
232 loadI18nMessages(); 229 loadI18nMessages();
LEFTRIGHT
« no previous file | button.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld