You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2015/12/09 07:27:41 UTC
cordova-plugin-file git commit: CB-10023 Fix "proxy not found error"
on Chrome.
Repository: cordova-plugin-file
Updated Branches:
refs/heads/master 554c6925c -> 77c63ef18
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.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/77c63ef1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/77c63ef1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/77c63ef1
Branch: refs/heads/master
Commit: 77c63ef181313eba51652e1026cc730fc79ab9f2
Parents: 554c692
Author: Tim Barham <tb...@microsoft.com>
Authored: Mon Dec 7 11:08:26 2015 +1000
Committer: Tim Barham <tb...@microsoft.com>
Committed: Tue Dec 8 11:22:57 2015 +1000
----------------------------------------------------------------------
plugin.xml | 4 ++++
src/browser/FileProxy.js | 7 +------
www/browser/Preparing.js | 3 +--
www/browser/isChrome.js | 26 ++++++++++++++++++++++++++
www/requestFileSystem.js | 12 +++++++-----
www/resolveLocalFileSystemURI.js | 12 +++++++-----
6 files changed, 46 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 617e81f..7f5dfcc 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -398,6 +398,10 @@ to config.xml in order for the application to find previously stored files.
</platform>
<platform name="browser">
+ <js-module src="www/browser/isChrome.js" name="isChrome">
+ <runs />
+ </js-module>
+
<!-- File for Chrome -->
<js-module src="www/browser/Preparing.js" name="Preparing">
<runs />
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/src/browser/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/FileProxy.js b/src/browser/FileProxy.js
index c853db8..0e0e0de 100644
--- a/src/browser/FileProxy.js
+++ b/src/browser/FileProxy.js
@@ -25,14 +25,9 @@
/* Heavily based on https://github.com/ebidel/idb.filesystem.js */
-// window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL
-// are available only in Chrome and possible a good flag to indicate
-// that we're running in Chrome
-var isChrome = window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
-
// For chrome we don't need to implement proxy methods
// All functionality can be accessed natively.
-if (isChrome) {
+if (require('./isChrome')()) {
var pathsPrefix = {
// Read-only directory where the application is installed.
applicationDirectory: location.origin + "/",
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/www/browser/Preparing.js
----------------------------------------------------------------------
diff --git a/www/browser/Preparing.js b/www/browser/Preparing.js
index 13957e0..f302ee9 100644
--- a/www/browser/Preparing.js
+++ b/www/browser/Preparing.js
@@ -22,8 +22,7 @@
/*global require*/
//Only Chrome uses this file.
-var isChrome = window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
-if (!isChrome) {
+if (!require('./isChrome')()) {
return;
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/www/browser/isChrome.js
----------------------------------------------------------------------
diff --git a/www/browser/isChrome.js b/www/browser/isChrome.js
new file mode 100644
index 0000000..d5b0eff
--- /dev/null
+++ b/www/browser/isChrome.js
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.
+ *
+ */
+
+module.exports = function () {
+ // window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and
+ // possibly a good flag to indicate that we're running in Chrome
+ return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
+};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/www/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/www/requestFileSystem.js b/www/requestFileSystem.js
index 84715fa..098047c 100644
--- a/www/requestFileSystem.js
+++ b/www/requestFileSystem.js
@@ -21,13 +21,15 @@
//For browser platform: not all browsers use this file.
function checkBrowser() {
- if (cordova.platformId === "browser" && navigator.userAgent.search(/Chrome/) > 0) {
- var requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
- module.exports = requestFileSystem;
- return;
+ if (cordova.platformId === "browser" && require('./isChrome')()) {
+ module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
+ return true;
}
+ return false;
+}
+if (checkBrowser()) {
+ return;
}
-checkBrowser();
var argscheck = require('cordova/argscheck'),
FileError = require('./FileError'),
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/77c63ef1/www/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/www/resolveLocalFileSystemURI.js b/www/resolveLocalFileSystemURI.js
index f564f78..633c1d2 100644
--- a/www/resolveLocalFileSystemURI.js
+++ b/www/resolveLocalFileSystemURI.js
@@ -21,13 +21,15 @@
//For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.
function checkBrowser() {
- if (cordova.platformId === "browser" && navigator.userAgent.search(/Chrome/) > 0) {
- var resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
- module.exports.resolveLocalFileSystemURL = resolveLocalFileSystemURL;
- return;
+ if (cordova.platformId === "browser" && require('./isChrome')()) {
+ module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
+ return true;
}
+ return false;
+}
+if (checkBrowser()) {
+ return;
}
-checkBrowser();
var argscheck = require('cordova/argscheck'),
DirectoryEntry = require('./DirectoryEntry'),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org