Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 6749021: Added new fileBrowserPrivate and fileHandler extension APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 try { 652 try {
653 if (responseCallback) 653 if (responseCallback)
654 responseCallback(response); 654 responseCallback(response);
655 } finally { 655 } finally {
656 port.disconnect(); 656 port.disconnect();
657 port = null; 657 port = null;
658 } 658 }
659 }); 659 });
660 }; 660 };
661 661
662 apiFunctions["fileSystem.resolveLocalFileSystemURL"].customCallback =
663 function(name, request, response) {
664 var method_callback = request.callback;
665 var successCallback = function(entry) {
666 console.log('successCallback');
667 console.log(entry);
668 method_callback(entry);
669 };
670 var errorCallback = function(err) {
671 console.log('errorCallback: code=' + err.code);
672 chrome.extension.lastError = {
673 "message": "File retrieval error",
674 "code" : err.code
675 };
676 method_callback(null);
677 };
678 var fs = null;
679 var resp = response ? [chromeHidden.JSON.parse(response)] : [];
680 console.log(resp);
681 if (resp[0].error) {
ericu 2011/03/31 21:31:06 Won't this throw if !response? Is that what you w
zel 2011/04/01 03:01:35 I am not sure that we want to throw here since thi
ericu 2011/04/02 01:16:05 Then you don't want to set resp to [] if !response
zel 2011/04/06 00:06:32 Done.
682 console.log('Got error: '+resp[0].error);
683 errorCallback({"code": error});
684 return;
685 }
686 // Get locak file system instance.
ericu 2011/03/31 21:31:06 typo: local
zel 2011/04/06 00:06:32 Done.
687 fs = GetLocalFileSystem(resp[0].name, resp[0].path);
688 console.log(fs);
689 if (resp[0].fileUrl.substr(0, resp[0].path.length) != resp[0].path) {
690 console.log('bad file url: ' + resp[0].fileUrl);
691 errorCallback({"code": FileError.NOT_FOUND_ERR});
692 return;
693 }
694 var file_path = resp[0].fileUrl.substr(resp[0].path.length);
695 console.log("Getting fileUrl: " + resp[0].fileUrl);
696 console.log("Getting file_path: " + file_path);
697 // Try to get directory.
698 fs.root.getDirectory(file_path, {create: true},
ericu 2011/03/31 21:31:06 I think we don't want to create the directory here
zel 2011/04/01 03:01:35 Whooops! Good catch. Done.
699 successCallback, function(err) {
700 console.log('dir errorCallback : code=' + err.code);
701 // Not a directory? Maybe it's a file then.
702 fs.root.getFile(file_path, {create: false}, successCallback,
703 errorCallback);
704 });
705 request.callback = null;
706 };
707
662 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = 708 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback =
663 function(name, request, response) { 709 function(name, request, response) {
664 var resp = response ? [chromeHidden.JSON.parse(response)] : []; 710 var resp = response ? [chromeHidden.JSON.parse(response)] : [];
665 var fs = null; 711 var fs = null;
666 if (!resp[0].error) 712 if (!resp[0].error)
667 fs = GetLocalFileSystem(resp[0].name, resp[0].path); 713 fs = GetLocalFileSystem(resp[0].name, resp[0].path);
668 if (request.callback) 714 if (request.callback)
669 request.callback(fs); 715 request.callback(fs);
670 request.callback = null; 716 request.callback = null;
671 }; 717 };
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 943
898 if (!chrome.experimental) 944 if (!chrome.experimental)
899 chrome.experimental = {}; 945 chrome.experimental = {};
900 946
901 if (!chrome.experimental.accessibility) 947 if (!chrome.experimental.accessibility)
902 chrome.experimental.accessibility = {}; 948 chrome.experimental.accessibility = {};
903 949
904 if (!chrome.experimental.tts) 950 if (!chrome.experimental.tts)
905 chrome.experimental.tts = {}; 951 chrome.experimental.tts = {};
906 })(); 952 })();
OLDNEW
« chrome/common/extensions/api/extension_api.json ('K') | « chrome/common/extensions/url_pattern.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698