| 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_galleries_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 "chrome/common/extensions/extension_constants.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 15 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 MediaGalleryCustomBindings::MediaGalleryCustomBindings() | 19 MediaGalleriesCustomBindings::MediaGalleriesCustomBindings() |
| 20 : ChromeV8Extension(NULL) { | 20 : ChromeV8Extension(NULL) { |
| 21 RouteFunction( | 21 RouteFunction( |
| 22 "GetMediaFileSystemObject", | 22 "GetMediaFileSystemObject", |
| 23 base::Bind(&MediaGalleryCustomBindings::GetMediaFileSystemObject, | 23 base::Bind(&MediaGalleriesCustomBindings::GetMediaFileSystemObject, |
| 24 base::Unretained(this))); | 24 base::Unretained(this))); |
| 25 RouteFunction( | 25 RouteFunction( |
| 26 "ExtractEmbeddedThumbnails", | 26 "ExtractEmbeddedThumbnails", |
| 27 base::Bind(&MediaGalleryCustomBindings::ExtractEmbeddedThumbnails, | 27 base::Bind(&MediaGalleriesCustomBindings::ExtractEmbeddedThumbnails, |
| 28 base::Unretained(this))); | 28 base::Unretained(this))); |
| 29 } | 29 } |
| 30 | 30 |
| 31 v8::Handle<v8::Value> MediaGalleryCustomBindings::GetMediaFileSystemObject( | 31 v8::Handle<v8::Value> MediaGalleriesCustomBindings::GetMediaFileSystemObject( |
| 32 const v8::Arguments& args) { | 32 const v8::Arguments& args) { |
| 33 if (args.Length() != 2) { | 33 if (args.Length() != 2) { |
| 34 NOTREACHED(); | 34 NOTREACHED(); |
| 35 return v8::Undefined(); | 35 return v8::Undefined(); |
| 36 } | 36 } |
| 37 if (!args[0]->IsString()) { | 37 if (!args[0]->IsString()) { |
| 38 NOTREACHED(); | 38 NOTREACHED(); |
| 39 return v8::Undefined(); | 39 return v8::Undefined(); |
| 40 } | 40 } |
| 41 if (!args[1]->IsString()) { | 41 if (!args[1]->IsString()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 const GURL root_url = | 59 const GURL root_url = |
| 60 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); | 60 fileapi::GetFileSystemRootURI(origin, fileapi::kFileSystemTypeIsolated); |
| 61 const std::string url = | 61 const std::string url = |
| 62 base::StringPrintf("%s%s/%s/", root_url.spec().c_str(), fsid.c_str(), | 62 base::StringPrintf("%s%s/%s/", root_url.spec().c_str(), fsid.c_str(), |
| 63 extension_misc::kMediaFileSystemPathPart); | 63 extension_misc::kMediaFileSystemPathPart); |
| 64 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, | 64 return webframe->createFileSystem(WebKit::WebFileSystem::TypeIsolated, |
| 65 WebKit::WebString::fromUTF8(name), | 65 WebKit::WebString::fromUTF8(name), |
| 66 WebKit::WebString::fromUTF8(url)); | 66 WebKit::WebString::fromUTF8(url)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 v8::Handle<v8::Value> MediaGalleryCustomBindings::ExtractEmbeddedThumbnails( | 69 v8::Handle<v8::Value> MediaGalleriesCustomBindings::ExtractEmbeddedThumbnails( |
| 70 const v8::Arguments& args) { | 70 const v8::Arguments& args) { |
| 71 if (args.Length() != 1) { | 71 if (args.Length() != 1) { |
| 72 NOTREACHED() << "Bad arguments"; | 72 NOTREACHED() << "Bad arguments"; |
| 73 return v8::Undefined(); | 73 return v8::Undefined(); |
| 74 } | 74 } |
| 75 // TODO(vandebo) Check that the object is a FileEntry. | 75 // TODO(vandebo) Check that the object is a FileEntry. |
| 76 | 76 |
| 77 // TODO(vandebo) Create and return a Directory entry object. | 77 // TODO(vandebo) Create and return a Directory entry object. |
| 78 return v8::Null(); | 78 return v8::Null(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace extensions | 81 } // namespace extensions |
| OLD | NEW |