OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/renderer/extensions/media_gallery_custom_bindings.h" |
| 6 |
| 7 #include "content/public/renderer/render_view.h" |
| 8 #include "grit/renderer_resources.h" |
| 9 #include "v8/include/v8.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 12 |
| 13 namespace extensions { |
| 14 |
| 15 MediaGalleryCustomBindings::MediaGalleryCustomBindings() |
| 16 : ChromeV8Extension(NULL) { |
| 17 RouteStaticFunction("CreateMediaGalleryObject", &CreateMediaGalleryObject); |
| 18 } |
| 19 |
| 20 // static |
| 21 v8::Handle<v8::Value> MediaGalleryCustomBindings::CreateMediaGalleryObject( |
| 22 const v8::Arguments& args) { |
| 23 if (args.Length() != 3 || !args[0]->IsUint32() || args[1]->IsNull() || |
| 24 !args[1]->IsString() || !args[2]->IsUint32()) { |
| 25 NOTREACHED() << "Bad arguments"; |
| 26 return v8::Undefined(); |
| 27 } |
| 28 |
| 29 int id = args[0]->Uint32Value(); |
| 30 std::string name; |
| 31 name = *v8::String::Utf8Value(args[1]->ToString()); |
| 32 if (name.empty()) |
| 33 return v8::Undefined(); |
| 34 int flags = args[2]->Uint32Value(); |
| 35 |
| 36 return WebKit::WebFrame::frameForCurrentContext()->createMediaGallery( |
| 37 id, WebKit::WebString::fromUTF8(name.c_str()), flags); |
| 38 } |
| 39 |
| 40 } // namespace extensions |
OLD | NEW |