Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Unified Diff: chrome/renderer/extensions/media_gallery_custom_bindings.cc

Issue 10409084: Media Gallery: Implement a basic version of GetMediaFileSystems(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/media_gallery_custom_bindings.cc
===================================================================
--- chrome/renderer/extensions/media_gallery_custom_bindings.cc (revision 138924)
+++ chrome/renderer/extensions/media_gallery_custom_bindings.cc (working copy)
@@ -4,9 +4,14 @@
#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"
+#include "webkit/fileapi/file_system_util.h"
namespace extensions {
@@ -24,7 +29,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 +37,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 GURL origin = GURL(webframe->document().securityOrigin().toString());
+ const GURL root_url =
+ fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated);
+ const std::string fsname_prefix =
+ fileapi::GetFileSystemName(origin, fileapi::kFileSystemTypeIsolated);
+ const std::string fsname =
+ base::StringPrintf("%s_%s", fsname_prefix.c_str(), fsid.c_str());
+ const std::string url = base::StringPrintf("%s%s/%s/",
+ root_url.spec().c_str(),
+ fsid.c_str(),
+ dirname.c_str());
+ return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated,
+ WebKit::WebString::fromUTF8(fsname),
+ WebKit::WebString::fromUTF8(url));
}
v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails(

Powered by Google App Engine
This is Rietveld 408576698