| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This script contains privileged chrome extension related javascript APIs. | 5 // This script contains privileged chrome extension related javascript APIs. |
| 6 // It is loaded by pages whose URL has the chrome-extension protocol. | 6 // It is loaded by pages whose URL has the chrome-extension protocol. |
| 7 | 7 |
| 8 var chrome = chrome || {}; | 8 var chrome = chrome || {}; |
| 9 (function() { | 9 (function() { |
| 10 native function GetExtensionAPIDefinition(); | 10 native function GetExtensionAPIDefinition(); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 try { | 653 try { |
| 654 if (responseCallback) | 654 if (responseCallback) |
| 655 responseCallback(response); | 655 responseCallback(response); |
| 656 } finally { | 656 } finally { |
| 657 port.disconnect(); | 657 port.disconnect(); |
| 658 port = null; | 658 port = null; |
| 659 } | 659 } |
| 660 }); | 660 }); |
| 661 }; | 661 }; |
| 662 | 662 |
| 663 apiFunctions["fileSystem.resolveLocalFileSystemURL"].customCallback = |
| 664 function(name, request, response) { |
| 665 var method_callback = request.callback; |
| 666 var successCallback = function(entry) { |
| 667 console.log('successCallback'); |
| 668 console.log(entry); |
| 669 method_callback(entry); |
| 670 }; |
| 671 var errorCallback = function(err) { |
| 672 console.log('errorCallback: code=' + err.code); |
| 673 chrome.extension.lastError = { |
| 674 "message": "File retrieval error", |
| 675 "code" : err.code |
| 676 }; |
| 677 method_callback(null); |
| 678 }; |
| 679 var fs = null; |
| 680 var resp = response ? [chromeHidden.JSON.parse(response)] : []; |
| 681 console.log(resp); |
| 682 if (resp[0].error) { |
| 683 console.log('Got error: '+resp[0].error); |
| 684 errorCallback({"code": error}); |
| 685 return; |
| 686 } |
| 687 // Get local file system instance. |
| 688 fs = GetLocalFileSystem(resp[0].name, resp[0].path); |
| 689 console.log(fs); |
| 690 if (resp[0].fileUrl.substr(0, resp[0].path.length) != resp[0].path) { |
| 691 console.log('bad file url: ' + resp[0].fileUrl); |
| 692 errorCallback({"code": FileError.NOT_FOUND_ERR}); |
| 693 return; |
| 694 } |
| 695 var file_path = resp[0].fileUrl.substr(resp[0].path.length); |
| 696 console.log("Getting fileUrl: " + resp[0].fileUrl); |
| 697 console.log("Getting file_path: " + file_path); |
| 698 // Try to get directory. |
| 699 fs.root.getDirectory(file_path, {create: false}, |
| 700 successCallback, function(err) { |
| 701 console.log('dir errorCallback : code=' + err.code); |
| 702 // Not a directory? Maybe it's a file then. |
| 703 fs.root.getFile(file_path, {create: false}, successCallback, |
| 704 errorCallback); |
| 705 }); |
| 706 request.callback = null; |
| 707 }; |
| 708 |
| 663 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = | 709 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = |
| 664 function(name, request, response) { | 710 function(name, request, response) { |
| 665 var resp = response ? [chromeHidden.JSON.parse(response)] : []; | 711 var resp = response ? [chromeHidden.JSON.parse(response)] : []; |
| 666 var fs = null; | 712 var fs = null; |
| 667 if (!resp[0].error) | 713 if (!resp[0].error) |
| 668 fs = GetLocalFileSystem(resp[0].name, resp[0].path); | 714 fs = GetLocalFileSystem(resp[0].name, resp[0].path); |
| 669 if (request.callback) | 715 if (request.callback) |
| 670 request.callback(fs); | 716 request.callback(fs); |
| 671 request.callback = null; | 717 request.callback = null; |
| 672 }; | 718 }; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 | 944 |
| 899 if (!chrome.experimental) | 945 if (!chrome.experimental) |
| 900 chrome.experimental = {}; | 946 chrome.experimental = {}; |
| 901 | 947 |
| 902 if (!chrome.experimental.accessibility) | 948 if (!chrome.experimental.accessibility) |
| 903 chrome.experimental.accessibility = {}; | 949 chrome.experimental.accessibility = {}; |
| 904 | 950 |
| 905 if (!chrome.experimental.tts) | 951 if (!chrome.experimental.tts) |
| 906 chrome.experimental.tts = {}; | 952 chrome.experimental.tts = {}; |
| 907 })(); | 953 })(); |
| OLD | NEW |