Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js |
| diff --git a/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f2ae4ded6f35014cd263db835a39ba65ad9eb01d |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// The ID of the extension we want to talk to. |
| +var fileBrowserExtensionId = "ddammdhioacbehjngdmkjcjbnfginlla"; |
| + |
| +function errorCallback(error) { |
| + var msg = ''; |
| + if (!error.code) { |
| + msg = error.message; |
| + } else { |
| + switch (error.code) { |
| + case FileError.QUOTA_EXCEEDED_ERR: |
| + msg = 'QUOTA_EXCEEDED_ERR'; |
| + break; |
| + case FileError.NOT_FOUND_ERR: |
| + msg = 'NOT_FOUND_ERR'; |
| + break; |
| + case FileError.SECURITY_ERR: |
| + msg = 'SECURITY_ERR'; |
| + break; |
| + case FileError.INVALID_MODIFICATION_ERR: |
| + msg = 'INVALID_MODIFICATION_ERR'; |
| + break; |
| + case FileError.INVALID_STATE_ERR: |
| + msg = 'INVALID_STATE_ERR'; |
| + break; |
| + default: |
| + msg = 'Unknown Error'; |
| + break; |
| + }; |
| + } |
| + |
| + chrome.extension.sendRequest(fileBrowserExtensionId, |
| + {fileContent: null, |
| + error: {message: "File handler error: " + msg}}, |
| + function(response) {}); |
| +}; |
| + |
| +function onGotEntryByUrl(entry) { |
| + var reader = new FileReader(); |
| + reader.onloadend = function(e) { |
| + |
| + console.log(reader.result); |
|
tbarzic
2012/04/13 02:58:30
remove this log
|
| + // Send data back to the file browser extension |
| + chrome.extension.sendRequest( |
| + fileBrowserExtensionId, |
| + {fileContent: reader.result, error: null}, |
| + function(response) {}); |
| + }; |
| + reader.onerror = function(e) { |
| + errorCallback(reader.error); |
| + }; |
| + entry.file(function(file) { |
| + reader.readAsText(file); |
| + }, |
| + errorCallback); |
| +}; |
| + |
| +function readEntryByUrl(entryUrl) { |
| + window.webkitResolveLocalFileSystemURL(entryUrl, onGotEntryByUrl, |
| + errorCallback); |
| +}; |
| + |
| +readEntryByUrl(localStorage.entryURL); |