diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 08:39:20 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-16 08:39:20 +0000 |
commit | 76066e5180a794b39d8f9550937b37b05f7793e8 (patch) | |
tree | 7b8a709544d0293808452ac622f01a0de195f013 /chrome/renderer/extensions | |
parent | cb23cdd5107b3f809f1a5a04a99098842364a15b (diff) | |
download | chromium_src-76066e5180a794b39d8f9550937b37b05f7793e8.zip chromium_src-76066e5180a794b39d8f9550937b37b05f7793e8.tar.gz chromium_src-76066e5180a794b39d8f9550937b37b05f7793e8.tar.bz2 |
New fileBrowserPrivate and fileHandler APIs added + plus magic needed to safely hand over access to local file system elements from content extension to 3rd party extension.
As agreed with aa@ and asargent@, this new API defines following event:
chrome.fileHandler.onExecute.addListener(function(id, file_entries) {
}
This event is invoked when user selects files in ChromeOS file browser.
The extension needs to register itself as file content hanlder with following manifest changes:
...
"file_browser_actions": [
{
"id" : "ActionIdentifier",
"default_title" : "Action title",
"default_icon" : "icon.png",
"file_filters" : [ "filesystem:*.jpeg", ... ]
}
...
],
...
BUG=chromium-os:11996
TEST=ExtensionApiTest.FileBrowserTest, ExtensionManifestTest.FileBrowserActions
Review URL: http://codereview.chromium.org/6749021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/extensions')
-rw-r--r-- | chrome/renderer/extensions/event_bindings.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc index db26ed7..921a82e 100644 --- a/chrome/renderer/extensions/event_bindings.cc +++ b/chrome/renderer/extensions/event_bindings.cc @@ -85,6 +85,8 @@ class ExtensionImpl : public ExtensionBase { return v8::FunctionTemplate::New(AttachEvent); } else if (name->Equals(v8::String::New("DetachEvent"))) { return v8::FunctionTemplate::New(DetachEvent); + } else if (name->Equals(v8::String::New("GetExternalFileEntry"))) { + return v8::FunctionTemplate::New(GetExternalFileEntry); } return ExtensionBase::GetNativeFunction(name); } @@ -148,6 +150,38 @@ class ExtensionImpl : public ExtensionBase { return v8::Undefined(); } + + // Attach an event name to an object. + static v8::Handle<v8::Value> GetExternalFileEntry( + const v8::Arguments& args) { + // TODO(zelidrag): Make this magic work on other platforms when file browser + // matures enough on ChromeOS. +#if defined(OS_CHROMEOS) + DCHECK(args.Length() == 1); + DCHECK(args[0]->IsObject()); + v8::Local<v8::Object> file_def = args[0]->ToObject(); + std::string file_system_name( + *v8::String::Utf8Value(file_def->Get( + v8::String::New("fileSystemName")))); + std::string file_system_path( + *v8::String::Utf8Value(file_def->Get( + v8::String::New("fileSystemRoot")))); + std::string file_full_path( + *v8::String::Utf8Value(file_def->Get( + v8::String::New("fileFullPath")))); + bool is_directory = + file_def->Get(v8::String::New("fileIsDirectory"))->ToBoolean()->Value(); + WebFrame* webframe = WebFrame::frameForCurrentContext(); + return webframe->createFileEntry( + WebKit::WebFileSystem::TypeExternal, + WebKit::WebString::fromUTF8(file_system_name.c_str()), + WebKit::WebString::fromUTF8(file_system_path.c_str()), + WebKit::WebString::fromUTF8(file_full_path.c_str()), + is_directory); +#else + return v8::Undefined(); +#endif + } }; // Returns true if the extension running in the given |context| has sufficient |