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" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 if (!args[1]->IsString()) { | 40 if (!args[1]->IsString()) { |
41 NOTREACHED(); | 41 NOTREACHED(); |
42 return v8::Undefined(); | 42 return v8::Undefined(); |
43 } | 43 } |
44 | 44 |
45 std::string fsid(*v8::String::Utf8Value(args[0])); | 45 std::string fsid(*v8::String::Utf8Value(args[0])); |
46 if (fsid.empty()) { | 46 if (fsid.empty()) { |
47 NOTREACHED(); | 47 NOTREACHED(); |
48 return v8::Undefined(); | 48 return v8::Undefined(); |
49 } | 49 } |
50 std::string dirname(*v8::String::Utf8Value(args[1])); | 50 std::string name(*v8::String::Utf8Value(args[1])); |
51 if (dirname.empty()) { | 51 if (name.empty()) { |
52 NOTREACHED(); | 52 NOTREACHED(); |
53 return v8::Undefined(); | 53 return v8::Undefined(); |
54 } | 54 } |
55 | 55 |
56 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); | 56 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); |
57 const GURL origin = GURL(webframe->document().securityOrigin().toString()); | 57 const GURL origin = GURL(webframe->document().securityOrigin().toString()); |
58 const GURL root_url = | 58 const GURL root_url = |
59 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); | 59 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); |
60 const std::string fsname = fileapi::GetIsolatedFileSystemName(origin, fsid); | 60 const std::string url = base::StringPrintf("%s%s/_/", |
Lei Zhang
2012/07/30 20:56:32
Hard coding the '_' is a bit hacky. This has to ma
vandebo (ex-Chrome)
2012/07/31 18:27:17
Changed to a constant.
| |
61 const std::string url = base::StringPrintf("%s%s/%s/", | |
62 root_url.spec().c_str(), | 61 root_url.spec().c_str(), |
63 fsid.c_str(), | 62 fsid.c_str()); |
64 dirname.c_str()); | |
65 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, | 63 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, |
66 WebKit::WebString::fromUTF8(fsname), | 64 WebKit::WebString::fromUTF8(name), |
67 WebKit::WebString::fromUTF8(url)); | 65 WebKit::WebString::fromUTF8(url)); |
68 } | 66 } |
69 | 67 |
70 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( | 68 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( |
71 const v8::Arguments& args) { | 69 const v8::Arguments& args) { |
72 if (args.Length() != 1) { | 70 if (args.Length() != 1) { |
73 NOTREACHED() << "Bad arguments"; | 71 NOTREACHED() << "Bad arguments"; |
74 return v8::Undefined(); | 72 return v8::Undefined(); |
75 } | 73 } |
76 // TODO(vandebo) Check that the object is a FileEntry. | 74 // TODO(vandebo) Check that the object is a FileEntry. |
77 | 75 |
78 // TODO(vandebo) Create and return a Directory entry object. | 76 // TODO(vandebo) Create and return a Directory entry object. |
79 return v8::Null(); | 77 return v8::Null(); |
80 } | 78 } |
81 | 79 |
82 } // namespace extensions | 80 } // namespace extensions |
OLD | NEW |