diff options
author | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 08:57:11 +0000 |
---|---|---|
committer | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 08:57:11 +0000 |
commit | c07b0f8087e8e04bad589c3acf5e9358bbc168ec (patch) | |
tree | f29f3f33be5c97a4a24f1e0ef6f037cf655ecaf5 /chrome/common | |
parent | a9b36c942fad35cc8fa821c97589910f1f12e152 (diff) | |
download | chromium_src-c07b0f8087e8e04bad589c3acf5e9358bbc168ec.zip chromium_src-c07b0f8087e8e04bad589c3acf5e9358bbc168ec.tar.gz chromium_src-c07b0f8087e8e04bad589c3acf5e9358bbc168ec.tar.bz2 |
Reland 142611 - Return FileEntry object from fileBrowserHandler.selectFile function.
r142611 was reverted because it broke FileSystemExtensionApi tests on chromiumos dbg build.
this change was originally reviewed here:
http://codereview.chromium.org/10535051/
Currently, the function returns file's filesystem URL, and the caller has to resolve it to get the entry.
It would be more convenient for the function caller it the file entry is returned in the first place.
Also this is more in line with onExecute event which dispatches an array of entries.
BUG=131716
TEST=*FileBrowserHandler*
TBR=tbarzic@chromium.org, aa@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10560031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
8 files changed, 99 insertions, 8 deletions
diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp index 86b98df..b87826c 100644 --- a/chrome/common/extensions/api/api.gyp +++ b/chrome/common/extensions/api/api.gyp @@ -21,7 +21,7 @@ 'events.json', 'experimental_font_settings.json', 'experimental_record.json', - 'file_browser_handler.json', + 'file_browser_handler_internal.json', 'permissions.json', 'storage.json', 'tabs.json', @@ -51,7 +51,7 @@ }], ['OS!="chromeos"', { 'json_schema_files!': [ - 'file_browser_handler.json', + 'file_browser_handler_internal.json', ], }], ], diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index 883dd06..c2553af 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -390,6 +390,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXTENSION)); RegisterSchema("fileBrowserHandler", ReadFromResource( IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER)); + RegisterSchema("fileBrowserHandlerInternal", ReadFromResource( + IDR_EXTENSION_API_JSON_FILEBROWSERHANDLERINTERNAL)); RegisterSchema("fileBrowserPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE)); RegisterSchema("history", ReadFromResource( diff --git a/chrome/common/extensions/api/file_browser_handler.json b/chrome/common/extensions/api/file_browser_handler.json index 539a1a7..65209fd 100644 --- a/chrome/common/extensions/api/file_browser_handler.json +++ b/chrome/common/extensions/api/file_browser_handler.json @@ -13,7 +13,8 @@ "description": "Event details payload for fileBrowserHandler.onExecute event.", "properties": { "entries": { - "type": "any", + "type": "array", + "items": { "type": "any" }, "description": "Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser)." }, "tab_id" : { @@ -49,12 +50,12 @@ { "name": "selectFile", "type": "function", - "description": "Prompts user to select file path under which a new file will be created. If the user selects file, the file gets created or, if it already exists, truncated. The function has to be called with user gesture.", + "description": "Prompts user to select file path under which a new file will be created. When the user selects file, the file gets created or, if it already existed, truncated. The function has to be called with a user gesture.", "parameters": [ { "name": "selectionParams", "type": "object", - "description": "Parameters that will be used to create new file.", + "description": "Parameters that will be used to create a new file.", "properties": { "suggestedName": { "type": "string", @@ -76,9 +77,11 @@ "type": "boolean", "description": "Has the file been selected." }, - "fileURL": { - "type": "string", - "description": "Filesystem URL of the selected file." + "entry": { + "type": "object", + "constructor": "Entry", + "optional": true, + "description": "Selected file entry. It will be null if a file hasn't been selected." } } } diff --git a/chrome/common/extensions/api/file_browser_handler_internal.json b/chrome/common/extensions/api/file_browser_handler_internal.json new file mode 100644 index 0000000..455bce8 --- /dev/null +++ b/chrome/common/extensions/api/file_browser_handler_internal.json @@ -0,0 +1,77 @@ +// 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. + +[ + { + "namespace": "fileBrowserHandlerInternal", + "nodoc": true, + "internal": true, + "platforms": ["chromeos"], + "types": [ + { + "id": "FileEntryInfo", + "type": "object", + "description": "Information needed to build a file entry that will be returned through the API.", + "properties": { + "fileSystemName": { + "type": "string" + }, + "fileSystemRoot": { + "type": "string" + }, + "fileFullPath": { + "type": "string" + }, + "fileIsDirectory": { + "type": "boolean" + } + } + } + ], + + "functions": [ + { + "name": "selectFile", + "type": "function", + "description": "Prompts user to select file path under which a new file will be created. If the user selects file, the file gets created or, if it already exists, truncated. The function has to be called with user gesture.", + "parameters": [ + { + "name": "selectionParams", + "type": "object", + "description": "Parameters that will be used to create new file.", + "properties": { + "suggestedName": { + "type": "string", + "description": "Suggested name for the new file." + } + } + }, + { + "name": "callback", + "type": "function", + "description": "Function called upon completion.", + "parameters": [ + { + "name": "result", + "description": "Result of the method.", + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Has the file been selected." + }, + "entry": { + "$ref": "FileEntryInfo", + "optional": true, + "description": "Selected file entry." + } + } + } + ] + } + ] + } + ] + } +] diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc index c62b9ba..1380f9e 100644 --- a/chrome/common/extensions/extension_permission_set.cc +++ b/chrome/common/extensions/extension_permission_set.cc @@ -255,6 +255,8 @@ void ExtensionAPIPermission::RegisterAllPermissions( // Register private permissions. { kChromeosInfoPrivate, "chromeosInfoPrivate", kFlagCannotBeOptional }, + { kFileBrowserHandlerInternal, "fileBrowserHandlerInternal", + kFlagCannotBeOptional }, { kFileBrowserPrivate, "fileBrowserPrivate", kFlagCannotBeOptional }, { kManagedModePrivate, "managedModePrivate", kFlagCannotBeOptional }, { kMediaPlayerPrivate, "mediaPlayerPrivate", kFlagCannotBeOptional }, @@ -846,6 +848,10 @@ void ExtensionPermissionSet::InitImplicitExtensionPermissions( if (apis_.find(ExtensionAPIPermission::kWebRequest) != apis_.end()) apis_.insert(ExtensionAPIPermission::kWebRequestInternal); + // The fileBrowserHandler permission implies the internal version as well. + if (apis_.find(ExtensionAPIPermission::kFileBrowserHandler) != apis_.end()) + apis_.insert(ExtensionAPIPermission::kFileBrowserHandlerInternal); + // Add the scriptable hosts. for (UserScriptList::const_iterator content_script = extension->content_scripts().begin(); diff --git a/chrome/common/extensions/extension_permission_set.h b/chrome/common/extensions/extension_permission_set.h index 2b247df..239d266 100644 --- a/chrome/common/extensions/extension_permission_set.h +++ b/chrome/common/extensions/extension_permission_set.h @@ -122,6 +122,7 @@ class ExtensionAPIPermission { kEchoPrivate, kExperimental, kFileBrowserHandler, + kFileBrowserHandlerInternal, kFileBrowserPrivate, kFileSystem, kGeolocation, diff --git a/chrome/common/extensions/extension_permission_set_unittest.cc b/chrome/common/extensions/extension_permission_set_unittest.cc index a5e0473..24efd54 100644 --- a/chrome/common/extensions/extension_permission_set_unittest.cc +++ b/chrome/common/extensions/extension_permission_set_unittest.cc @@ -619,6 +619,7 @@ TEST(ExtensionPermissionsTest, PermissionMessages) { // These are private. skip.insert(ExtensionAPIPermission::kChromeAuthPrivate); skip.insert(ExtensionAPIPermission::kChromeosInfoPrivate); + skip.insert(ExtensionAPIPermission::kFileBrowserHandlerInternal); skip.insert(ExtensionAPIPermission::kFileBrowserPrivate); skip.insert(ExtensionAPIPermission::kInputMethodPrivate); skip.insert(ExtensionAPIPermission::kManagedModePrivate); diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index 904a92a..e45c446 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -40,6 +40,7 @@ <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_SPEECHINPUT" file="extensions\api\experimental_speech_input.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXTENSION" file="extensions\api\extension.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER" file="extensions\api\file_browser_handler.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_FILEBROWSERHANDLERINTERNAL" file="extensions\api\file_browser_handler_internal.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE" file="extensions\api\file_browser_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_HISTORY" file="extensions\api\history.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_I18N" file="extensions\api\i18n.json" type="BINDATA" /> |