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

Side by Side Diff: safari/ext/common.js

Issue 4966645353152512: Handle XMLHttpRequest with bad status in Safari's i18n code (Closed)
Patch Set: Created Jan. 20, 2014, 5:17 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 /* 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messag es.json", false); 144 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messag es.json", false);
145 145
146 try { 146 try {
147 xhr.send(); 147 xhr.send();
148 } 148 }
149 catch (e) 149 catch (e)
150 { 150 {
151 return null; 151 return null;
152 } 152 }
153 153
154 if (xhr.status != 200 && xhr.status != 0)
155 return null;
156
154 return JSON.parse(xhr.responseText); 157 return JSON.parse(xhr.responseText);
155 }, 158 },
156 getMessage: function(msgId, substitutions) 159 getMessage: function(msgId, substitutions)
157 { 160 {
158 if (msgId == "@@ui_locale") 161 if (msgId == "@@ui_locale")
159 return this._uiLocale; 162 return this._uiLocale;
160 163
161 for (var i = 0; i < this._localeCandidates.length; i++) 164 for (var i = 0; i < this._localeCandidates.length; i++)
162 { 165 {
163 var catalog = this._getCatalog(this._localeCandidates[i]); 166 var catalog = this._getCatalog(this._localeCandidates[i]);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 /* API */ 212 /* API */
210 213
211 ext = { 214 ext = {
212 getURL: function(path) 215 getURL: function(path)
213 { 216 {
214 return safari.extension.baseURI + path; 217 return safari.extension.baseURI + path;
215 }, 218 },
216 i18n: new I18n() 219 i18n: new I18n()
217 }; 220 };
218 })(); 221 })();
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