summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/file_system/file_system_api.cc14
-rw-r--r--chrome/common/extensions/api/file_system.idl2
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.cc2
-rw-r--r--chrome/renderer/renderer_resources.grd1
-rw-r--r--chrome/renderer/resources/extensions/file_system_custom_bindings.js16
-rw-r--r--chrome/test/data/extensions/platform_apps/get_display_path/test.js6
6 files changed, 29 insertions, 12 deletions
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc
index d9a3104..7c3fa9a 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
@@ -5,33 +5,31 @@
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "base/file_path.h"
-#include "chrome/common/extensions/api/file_system.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_process_host.h"
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/isolated_context.h"
-namespace GetDisplayPath = extensions::api::file_system::GetDisplayPath;
-
namespace extensions {
const char kInvalidParameters[] = "Invalid parameters";
const char kSecurityError[] = "Security error";
bool FileSystemGetDisplayPathFunction::RunImpl() {
- scoped_ptr<GetDisplayPath::Params> params(GetDisplayPath::Params::Create(
- *args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
+ std::string filesystem_name;
+ std::string filesystem_path;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name));
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path));
std::string filesystem_id;
- if (!fileapi::CrackIsolatedFileSystemName(params->fsname, &filesystem_id)) {
+ if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) {
error_ = kInvalidParameters;
return false;
}
fileapi::IsolatedContext* context = fileapi::IsolatedContext::GetInstance();
- FilePath relative_path = FilePath::FromUTF8Unsafe(params->fspath);
+ FilePath relative_path = FilePath::FromUTF8Unsafe(filesystem_path);
FilePath virtual_path = context->CreateVirtualPath(filesystem_id,
relative_path);
FilePath file_path;
diff --git a/chrome/common/extensions/api/file_system.idl b/chrome/common/extensions/api/file_system.idl
index 502a26c..a4e6e9d 100644
--- a/chrome/common/extensions/api/file_system.idl
+++ b/chrome/common/extensions/api/file_system.idl
@@ -8,7 +8,7 @@
callback GetDisplayPathCallback = void (DOMString displayPath);
interface Functions {
- static void getDisplayPath(DOMString fsname, DOMString fspath,
+ static void getDisplayPath([instanceOf=FileEntry] object fileEntry,
GetDisplayPathCallback onSuccess);
};
};
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc
index 838746a..1104566 100644
--- a/chrome/renderer/extensions/extension_dispatcher.cc
+++ b/chrome/renderer/extensions/extension_dispatcher.cc
@@ -570,6 +570,8 @@ void ExtensionDispatcher::PopulateSourceMap() {
IDR_FILE_BROWSER_HANDLER_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("fileBrowserPrivate",
IDR_FILE_BROWSER_PRIVATE_CUSTOM_BINDINGS_JS);
+ source_map_.RegisterSource("fileSystem",
+ IDR_FILE_SYSTEM_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("i18n", IDR_I18N_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("experimental.input.ime",
IDR_INPUT_IME_CUSTOM_BINDINGS_JS);
diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd
index 421a70d..475bf8c 100644
--- a/chrome/renderer/renderer_resources.grd
+++ b/chrome/renderer/renderer_resources.grd
@@ -50,6 +50,7 @@ without changes to the corresponding grd file. fb9 -->
<include name="IDR_EXTENSION_CUSTOM_BINDINGS_JS" file="resources\extensions\extension_custom_bindings.js" type="BINDATA" />
<include name="IDR_FILE_BROWSER_HANDLER_CUSTOM_BINDINGS_JS" file="resources\extensions\file_browser_handler_custom_bindings.js" type="BINDATA" />
<include name="IDR_FILE_BROWSER_PRIVATE_CUSTOM_BINDINGS_JS" file="resources\extensions\file_browser_private_custom_bindings.js" type="BINDATA" />
+ <include name="IDR_FILE_SYSTEM_CUSTOM_BINDINGS_JS" file="resources\extensions\file_system_custom_bindings.js" type="BINDATA" />
<include name="IDR_I18N_CUSTOM_BINDINGS_JS" file="resources\extensions\i18n_custom_bindings.js" type="BINDATA" />
<include name="IDR_INPUT_IME_CUSTOM_BINDINGS_JS" file="resources\extensions\input.ime_custom_bindings.js" type="BINDATA" />
<include name="IDR_MEDIA_GALLERY_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.media_galleries_custom_bindings.js" type="BINDATA" />
diff --git a/chrome/renderer/resources/extensions/file_system_custom_bindings.js b/chrome/renderer/resources/extensions/file_system_custom_bindings.js
new file mode 100644
index 0000000..0e6da3a
--- /dev/null
+++ b/chrome/renderer/resources/extensions/file_system_custom_bindings.js
@@ -0,0 +1,16 @@
+// 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.
+
+// Custom bindings for the fileSystem API.
+
+var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
+
+chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) {
+ bindingsAPI.apiFunctions.setUpdateArgumentsPostValidate(
+ 'getDisplayPath', function(fileEntry, callback) {
+ var fileSystemName = fileEntry.filesystem.name;
+ var relativePath = fileEntry.fullPath.slice(1);
+ return [fileSystemName, relativePath, callback];
+ });
+});
diff --git a/chrome/test/data/extensions/platform_apps/get_display_path/test.js b/chrome/test/data/extensions/platform_apps/get_display_path/test.js
index 2ab01ea..e43fe9b 100644
--- a/chrome/test/data/extensions/platform_apps/get_display_path/test.js
+++ b/chrome/test/data/extensions/platform_apps/get_display_path/test.js
@@ -6,7 +6,7 @@
// FileEntry in launchData.intent.data can be read.
function onLaunched(launchData) {
chrome.test.runTests([
- function testIntent() {
+ function testGetDisplayPath() {
chrome.test.assertFalse(!launchData, "No launchData");
chrome.test.assertFalse(!launchData.intent, "No launchData.intent");
chrome.test.assertEq(launchData.intent.action,
@@ -16,8 +16,8 @@ function onLaunched(launchData) {
chrome.test.assertFalse(!launchData.intent.data,
"No launchData.intent.data");
var entry = launchData.intent.data;
- chrome.fileSystem.getDisplayPath(entry.filesystem.name,
- entry.fullPath.slice(1), chrome.test.callbackPass(function(path) {
+ chrome.fileSystem.getDisplayPath(entry,
+ chrome.test.callbackPass(function(path) {
chrome.test.assertFalse(path.indexOf('test.txt') == -1);
}));
}