Chromium Code Reviews| Index: chrome/renderer/extensions/media_gallery_custom_bindings.cc |
| =================================================================== |
| --- chrome/renderer/extensions/media_gallery_custom_bindings.cc (revision 138385) |
| +++ chrome/renderer/extensions/media_gallery_custom_bindings.cc (working copy) |
| @@ -4,10 +4,20 @@ |
| #include "chrome/renderer/extensions/media_gallery_custom_bindings.h" |
| -#include "content/public/renderer/render_view.h" |
| -#include "grit/renderer_resources.h" |
| +#include <string> |
| + |
| +#include "base/file_path.h" |
| +#include "base/stringprintf.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| #include "v8/include/v8.h" |
| +namespace { |
| + |
| +const char kIsolatedFileSystem[] = "isolated"; |
| + |
| +} // namespace |
| + |
| namespace extensions { |
| MediaGalleryCustomBindings::MediaGalleryCustomBindings() |
| @@ -24,7 +34,7 @@ |
| v8::Handle<v8::Value> MediaGalleryCustomBindings::GetMediaFileSystemObject( |
| const v8::Arguments& args) { |
| - if (args.Length() != 1) { |
| + if (args.Length() != 2) { |
| NOTREACHED(); |
| return v8::Undefined(); |
| } |
| @@ -32,14 +42,37 @@ |
| NOTREACHED(); |
| return v8::Undefined(); |
| } |
| + if (!args[1]->IsString()) { |
| + NOTREACHED(); |
| + return v8::Undefined(); |
| + } |
| - std::string file_system_url; |
| - file_system_url = *v8::String::Utf8Value(args[1]->ToString()); |
| - if (file_system_url.empty()) |
| + std::string fsid(*v8::String::Utf8Value(args[0])); |
| + if (fsid.empty()) { |
| + NOTREACHED(); |
| return v8::Undefined(); |
| + } |
| + std::string dirname(*v8::String::Utf8Value(args[1])); |
| + if (dirname.empty()) { |
| + NOTREACHED(); |
| + return v8::Undefined(); |
| + } |
| - // TODO(vandebo) Create and return a FileSystem object. |
| - return v8::Undefined(); |
| + WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
| + const std::string& origin = |
| + webframe->document().securityOrigin().toString().utf8(); |
| + const std::string name = base::StringPrintf("%s:%s_%s", |
| + origin.c_str(), |
| + kIsolatedFileSystem, |
| + fsid.c_str()); |
| + const std::string url = base::StringPrintf("filesystem:%s/%s/%s/%s/", |
| + origin.c_str(), |
| + kIsolatedFileSystem, |
| + fsid.c_str(), |
| + dirname.c_str()); |
|
kinuko
2012/05/24 05:17:05
Please use fileapi::GetFileSystemRootURI and GetFi
Lei Zhang
2012/05/24 22:55:41
I switched over to using GetFileSystemRootURI().
|
| + return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, |
| + WebKit::WebString::fromUTF8(name), |
| + WebKit::WebString::fromUTF8(url)); |
| } |
| v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( |