Improved FTP support for Chromium extension

This commit is contained in:
Rob Wu 2014-03-30 00:08:02 +01:00
parent 7d5bf83ce8
commit d04f81b964
5 changed files with 88 additions and 6 deletions

View file

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* globals chrome */
/* globals chrome, Features */
'use strict';
@ -172,6 +172,27 @@ chrome.webRequest.onHeadersReceived.addListener(
},
['blocking','responseHeaders']);
chrome.webRequest.onBeforeRequest.addListener(
function onBeforeRequestForFTP(details) {
if (!Features.extensionSupportsFTP) {
chrome.webRequest.onBeforeRequest.removeListener(onBeforeRequestForFTP);
return;
}
if (isPdfDownloadable(details)) {
return;
}
var viewerUrl = getViewerURL(details.url);
return { redirectUrl: viewerUrl };
},
{
urls: [
'ftp://*/*.pdf',
'ftp://*/*.PDF'
],
types: ['main_frame', 'sub_frame']
},
['blocking']);
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (isPdfDownloadable(details)) {