Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 delete chrome.extension.lastError; | 90 delete chrome.extension.lastError; |
| 91 } else { | 91 } else { |
| 92 if (!error) { | 92 if (!error) { |
| 93 error = "Unknown error."; | 93 error = "Unknown error."; |
| 94 } | 94 } |
| 95 console.error("Error during " + name + ": " + error); | 95 console.error("Error during " + name + ": " + error); |
| 96 chrome.extension.lastError = { | 96 chrome.extension.lastError = { |
| 97 "message": error | 97 "message": error |
| 98 }; | 98 }; |
| 99 } | 99 } |
| 100 | 100 console.log('handleResponse'); |
| 101 console.log(error); | |
|
abarth-chromium
2011/04/06 02:17:32
Do we want to land this code with console.log in i
zel
2011/04/06 05:25:17
this was here just for my debugging, it's been rem
| |
| 101 if (request.customCallback) { | 102 if (request.customCallback) { |
| 102 request.customCallback(name, request, response); | 103 request.customCallback(name, request, response); |
| 103 } | 104 } |
| 104 | 105 |
| 105 if (request.callback) { | 106 if (request.callback) { |
| 106 // Callbacks currently only support one callback argument. | 107 // Callbacks currently only support one callback argument. |
| 107 var callbackArgs = response ? [chromeHidden.JSON.parse(response)] : []; | 108 var callbackArgs = response ? [chromeHidden.JSON.parse(response)] : []; |
| 108 | 109 |
| 109 // Validate callback in debug only -- and only when the | 110 // Validate callback in debug only -- and only when the |
| 110 // caller has provided a callback. Implementations of api | 111 // caller has provided a callback. Implementations of api |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 try { | 654 try { |
| 654 if (responseCallback) | 655 if (responseCallback) |
| 655 responseCallback(response); | 656 responseCallback(response); |
| 656 } finally { | 657 } finally { |
| 657 port.disconnect(); | 658 port.disconnect(); |
| 658 port = null; | 659 port = null; |
| 659 } | 660 } |
| 660 }); | 661 }); |
| 661 }; | 662 }; |
| 662 | 663 |
| 664 apiFunctions["fileSystem.resolveLocalFileSystemURL"].customCallback = | |
| 665 function(name, request, response) { | |
| 666 var method_callback = request.callback; | |
| 667 var successCallback = function(entry) { | |
| 668 method_callback(entry); | |
| 669 }; | |
| 670 var errorCallback = function(err) { | |
| 671 chrome.extension.lastError = { | |
| 672 "message": "File retrieval error", | |
| 673 "code" : err.code | |
| 674 }; | |
| 675 method_callback(null); | |
| 676 }; | |
| 677 var fs = null; | |
| 678 console.log('response'); | |
| 679 console.log(response); | |
| 680 var resp = response ? [chromeHidden.JSON.parse(response)] : null; | |
| 681 console.log(resp); | |
| 682 if (!resp || !resp.length || !resp[0]) { | |
| 683 errorCallback({"code": -1}); | |
| 684 return; | |
| 685 } else if (resp[0].error) { | |
| 686 errorCallback({"code": resp[0].error}); | |
| 687 return; | |
| 688 } | |
| 689 // Get local file system instance. | |
| 690 fs = GetLocalFileSystem(resp[0].name, resp[0].path); | |
| 691 if (resp[0].fileUrl.substr(0, resp[0].path.length) != resp[0].path) { | |
| 692 errorCallback({"code": FileError.NOT_FOUND_ERR}); | |
| 693 return; | |
| 694 } | |
| 695 var file_path = resp[0].fileUrl.substr(resp[0].path.length); | |
| 696 // Try to get directory. | |
| 697 fs.root.getDirectory(file_path, {create: false}, | |
| 698 successCallback, function(err) { | |
| 699 // Not a directory? Maybe it's a file then. | |
| 700 fs.root.getFile(file_path, {create: false}, successCallback, | |
| 701 errorCallback); | |
| 702 }); | |
| 703 request.callback = null; | |
| 704 }; | |
| 705 | |
| 663 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = | 706 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = |
| 664 function(name, request, response) { | 707 function(name, request, response) { |
| 665 var resp = response ? [chromeHidden.JSON.parse(response)] : []; | 708 var resp = response ? [chromeHidden.JSON.parse(response)] : []; |
| 666 var fs = null; | 709 var fs = null; |
| 667 if (!resp[0].error) | 710 if (!resp[0].error) |
| 668 fs = GetLocalFileSystem(resp[0].name, resp[0].path); | 711 fs = GetLocalFileSystem(resp[0].name, resp[0].path); |
| 669 if (request.callback) | 712 if (request.callback) |
| 670 request.callback(fs); | 713 request.callback(fs); |
| 671 request.callback = null; | 714 request.callback = null; |
| 672 }; | 715 }; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 | 941 |
| 899 if (!chrome.experimental) | 942 if (!chrome.experimental) |
| 900 chrome.experimental = {}; | 943 chrome.experimental = {}; |
| 901 | 944 |
| 902 if (!chrome.experimental.accessibility) | 945 if (!chrome.experimental.accessibility) |
| 903 chrome.experimental.accessibility = {}; | 946 chrome.experimental.accessibility = {}; |
| 904 | 947 |
| 905 if (!chrome.experimental.tts) | 948 if (!chrome.experimental.tts) |
| 906 chrome.experimental.tts = {}; | 949 chrome.experimental.tts = {}; |
| 907 })(); | 950 })(); |
| OLD | NEW |