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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/media_gallery_custom_bindings.h" 5 #include "chrome/renderer/extensions/media_gallery_custom_bindings.h"
6 6
7 #include "content/public/renderer/render_view.h" 7 #include <string>
8 #include "grit/renderer_resources.h" 8
9 #include "base/file_path.h"
10 #include "base/stringprintf.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
9 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
10 14
15 namespace {
16
17 const char kIsolatedFileSystem[] = "isolated";
18
19 } // namespace
20
11 namespace extensions { 21 namespace extensions {
12 22
13 MediaGalleryCustomBindings::MediaGalleryCustomBindings() 23 MediaGalleryCustomBindings::MediaGalleryCustomBindings()
14 : ChromeV8Extension(NULL) { 24 : ChromeV8Extension(NULL) {
15 RouteFunction( 25 RouteFunction(
16 "GetMediaFileSystemObject", 26 "GetMediaFileSystemObject",
17 base::Bind(&MediaGalleryCustomBindings::GetMediaFileSystemObject, 27 base::Bind(&MediaGalleryCustomBindings::GetMediaFileSystemObject,
18 base::Unretained(this))); 28 base::Unretained(this)));
19 RouteFunction( 29 RouteFunction(
20 "ExtractEmbeddedThumbnails", 30 "ExtractEmbeddedThumbnails",
21 base::Bind(&MediaGalleryCustomBindings::ExtractEmbeddedThumbnails, 31 base::Bind(&MediaGalleryCustomBindings::ExtractEmbeddedThumbnails,
22 base::Unretained(this))); 32 base::Unretained(this)));
23 } 33 }
24 34
25 v8::Handle<v8::Value> MediaGalleryCustomBindings::GetMediaFileSystemObject( 35 v8::Handle<v8::Value> MediaGalleryCustomBindings::GetMediaFileSystemObject(
26 const v8::Arguments& args) { 36 const v8::Arguments& args) {
27 if (args.Length() != 1) { 37 if (args.Length() != 2) {
28 NOTREACHED(); 38 NOTREACHED();
29 return v8::Undefined(); 39 return v8::Undefined();
30 } 40 }
31 if (!args[0]->IsString()) { 41 if (!args[0]->IsString()) {
32 NOTREACHED(); 42 NOTREACHED();
33 return v8::Undefined(); 43 return v8::Undefined();
34 } 44 }
45 if (!args[1]->IsString()) {
46 NOTREACHED();
47 return v8::Undefined();
48 }
35 49
36 std::string file_system_url; 50 std::string fsid(*v8::String::Utf8Value(args[0]));
37 file_system_url = *v8::String::Utf8Value(args[1]->ToString()); 51 if (fsid.empty()) {
38 if (file_system_url.empty()) 52 NOTREACHED();
39 return v8::Undefined(); 53 return v8::Undefined();
54 }
55 std::string dirname(*v8::String::Utf8Value(args[1]));
56 if (dirname.empty()) {
57 NOTREACHED();
58 return v8::Undefined();
59 }
40 60
41 // TODO(vandebo) Create and return a FileSystem object. 61 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
42 return v8::Undefined(); 62 const std::string& origin =
63 webframe->document().securityOrigin().toString().utf8();
64 const std::string name = base::StringPrintf("%s:%s_%s",
65 origin.c_str(),
66 kIsolatedFileSystem,
67 fsid.c_str());
68 const std::string url = base::StringPrintf("filesystem:%s/%s/%s/%s/",
69 origin.c_str(),
70 kIsolatedFileSystem,
71 fsid.c_str(),
72 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().
73 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated,
74 WebKit::WebString::fromUTF8(name),
75 WebKit::WebString::fromUTF8(url));
43 } 76 }
44 77
45 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( 78 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails(
46 const v8::Arguments& args) { 79 const v8::Arguments& args) {
47 if (args.Length() != 1) { 80 if (args.Length() != 1) {
48 NOTREACHED() << "Bad arguments"; 81 NOTREACHED() << "Bad arguments";
49 return v8::Undefined(); 82 return v8::Undefined();
50 } 83 }
51 // TODO(vandebo) Check that the object is a FileEntry. 84 // TODO(vandebo) Check that the object is a FileEntry.
52 85
53 // TODO(vandebo) Create and return a Directory entry object. 86 // TODO(vandebo) Create and return a Directory entry object.
54 return v8::Null(); 87 return v8::Null();
55 } 88 }
56 89
57 } // namespace extensions 90 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698