OLD | NEW |
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "chrome/common/extensions/extension_constants.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
13 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
14 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
15 | 16 |
16 namespace extensions { | 17 namespace extensions { |
17 | 18 |
18 MediaGalleryCustomBindings::MediaGalleryCustomBindings() | 19 MediaGalleryCustomBindings::MediaGalleryCustomBindings() |
19 : ChromeV8Extension(NULL) { | 20 : ChromeV8Extension(NULL) { |
20 RouteFunction( | 21 RouteFunction( |
(...skipping 19 matching lines...) Expand all Loading... |
40 if (!args[1]->IsString()) { | 41 if (!args[1]->IsString()) { |
41 NOTREACHED(); | 42 NOTREACHED(); |
42 return v8::Undefined(); | 43 return v8::Undefined(); |
43 } | 44 } |
44 | 45 |
45 std::string fsid(*v8::String::Utf8Value(args[0])); | 46 std::string fsid(*v8::String::Utf8Value(args[0])); |
46 if (fsid.empty()) { | 47 if (fsid.empty()) { |
47 NOTREACHED(); | 48 NOTREACHED(); |
48 return v8::Undefined(); | 49 return v8::Undefined(); |
49 } | 50 } |
50 std::string dirname(*v8::String::Utf8Value(args[1])); | 51 std::string name(*v8::String::Utf8Value(args[1])); |
51 if (dirname.empty()) { | 52 if (name.empty()) { |
52 NOTREACHED(); | 53 NOTREACHED(); |
53 return v8::Undefined(); | 54 return v8::Undefined(); |
54 } | 55 } |
55 | 56 |
56 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); | 57 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
57 const GURL origin = GURL(webframe->document().securityOrigin().toString()); | 58 const GURL origin = GURL(webframe->document().securityOrigin().toString()); |
58 const GURL root_url = | 59 const GURL root_url = |
59 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); | 60 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); |
60 const std::string fsname = fileapi::GetIsolatedFileSystemName(origin, fsid); | 61 const std::string url = |
61 const std::string url = base::StringPrintf("%s%s/%s/", | 62 base::StringPrintf("%s%s/%s/", root_url.spec().c_str(), fsid.c_str(), |
62 root_url.spec().c_str(), | 63 extension_misc::kMediaFileSystemPathPart); |
63 fsid.c_str(), | |
64 dirname.c_str()); | |
65 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, | 64 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, |
66 WebKit::WebString::fromUTF8(fsname), | 65 WebKit::WebString::fromUTF8(name), |
67 WebKit::WebString::fromUTF8(url)); | 66 WebKit::WebString::fromUTF8(url)); |
68 } | 67 } |
69 | 68 |
70 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( | 69 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( |
71 const v8::Arguments& args) { | 70 const v8::Arguments& args) { |
72 if (args.Length() != 1) { | 71 if (args.Length() != 1) { |
73 NOTREACHED() << "Bad arguments"; | 72 NOTREACHED() << "Bad arguments"; |
74 return v8::Undefined(); | 73 return v8::Undefined(); |
75 } | 74 } |
76 // TODO(vandebo) Check that the object is a FileEntry. | 75 // TODO(vandebo) Check that the object is a FileEntry. |
77 | 76 |
78 // TODO(vandebo) Create and return a Directory entry object. | 77 // TODO(vandebo) Create and return a Directory entry object. |
79 return v8::Null(); | 78 return v8::Null(); |
80 } | 79 } |
81 | 80 |
82 } // namespace extensions | 81 } // namespace extensions |
OLD | NEW |