Skip to content

Commit 77c63ef

Browse files
author
Tim Barham
committed
CB-10023 Fix "proxy not found error" on Chrome.
We shouldn't be patching requestFileSystem and resolveLocalFileSystem on Chrome. Recent change broke the existing logic for this.
1 parent 554c692 commit 77c63ef

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

plugin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ to config.xml in order for the application to find previously stored files.
398398
</platform>
399399

400400
<platform name="browser">
401+
<js-module src="www/browser/isChrome.js" name="isChrome">
402+
<runs />
403+
</js-module>
404+
401405
<!-- File for Chrome -->
402406
<js-module src="www/browser/Preparing.js" name="Preparing">
403407
<runs />

src/browser/FileProxy.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@
2525

2626
/* Heavily based on https://github.com/ebidel/idb.filesystem.js */
2727

28-
// window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL
29-
// are available only in Chrome and possible a good flag to indicate
30-
// that we're running in Chrome
31-
var isChrome = window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
32-
3328
// For chrome we don't need to implement proxy methods
3429
// All functionality can be accessed natively.
35-
if (isChrome) {
30+
if (require('./isChrome')()) {
3631
var pathsPrefix = {
3732
// Read-only directory where the application is installed.
3833
applicationDirectory: location.origin + "/",

www/browser/Preparing.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
/*global require*/
2323

2424
//Only Chrome uses this file.
25-
var isChrome = window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
26-
if (!isChrome) {
25+
if (!require('./isChrome')()) {
2726
return;
2827
}
2928

www/browser/isChrome.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*
20+
*/
21+
22+
module.exports = function () {
23+
// window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and
24+
// possibly a good flag to indicate that we're running in Chrome
25+
return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
26+
};

www/requestFileSystem.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121

2222
//For browser platform: not all browsers use this file.
2323
function checkBrowser() {
24-
if (cordova.platformId === "browser" && navigator.userAgent.search(/Chrome/) > 0) {
25-
var requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
26-
module.exports = requestFileSystem;
27-
return;
24+
if (cordova.platformId === "browser" && require('./isChrome')()) {
25+
module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
26+
return true;
2827
}
28+
return false;
29+
}
30+
if (checkBrowser()) {
31+
return;
2932
}
30-
checkBrowser();
3133

3234
var argscheck = require('cordova/argscheck'),
3335
FileError = require('./FileError'),

www/resolveLocalFileSystemURI.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121

2222
//For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.
2323
function checkBrowser() {
24-
if (cordova.platformId === "browser" && navigator.userAgent.search(/Chrome/) > 0) {
25-
var resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
26-
module.exports.resolveLocalFileSystemURL = resolveLocalFileSystemURL;
27-
return;
24+
if (cordova.platformId === "browser" && require('./isChrome')()) {
25+
module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
26+
return true;
2827
}
28+
return false;
29+
}
30+
if (checkBrowser()) {
31+
return;
2932
}
30-
checkBrowser();
3133

3234
var argscheck = require('cordova/argscheck'),
3335
DirectoryEntry = require('./DirectoryEntry'),

0 commit comments

Comments
 (0)