| Index: chrome/renderer/extensions/tab_capture_custom_bindings.cc
|
| diff --git a/chrome/renderer/extensions/tab_capture_custom_bindings.cc b/chrome/renderer/extensions/tab_capture_custom_bindings.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42c04db8503d4a628e01100ff96bebbb86ef2727
|
| --- /dev/null
|
| +++ b/chrome/renderer/extensions/tab_capture_custom_bindings.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/renderer/extensions/tab_capture_custom_bindings.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "content/public/renderer/render_view.h"
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSource.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceMediaRequest.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
| +#include "v8/include/v8.h"
|
| +
|
| +namespace {
|
| +
|
| +static v8::Handle<v8::Value> RequestDeviceMedia(const v8::Arguments& args) {
|
| + if (args.Length() != 4
|
| + || !args[0]->IsString()
|
| + || !args[1]->IsObject()
|
| + || !args[2]->IsFunction()
|
| + || !args[3]->IsFunction()) {
|
| + NOTREACHED();
|
| + return v8::Undefined();
|
| + }
|
| +
|
| + WebKit::WebFrame* webFrame = WebKit::WebFrame::frameForCurrentContext();
|
| + content::RenderView* renderView =
|
| + content::RenderView::FromWebView(webFrame->view());
|
| + WebKit::WebUserMediaClient *client = renderView->GetUserMediaClient();
|
| +
|
| + std::string deviceId = *v8::String::Utf8Value(args[0]);
|
| + WebKit::WebDeviceMediaRequest* request =
|
| + WebKit::WebDeviceMediaRequest::createFromV8(
|
| + WebKit::WebString::fromUTF8(deviceId),
|
| + args[1]->ToObject(),
|
| + args[2],
|
| + args[3]);
|
| + if (!request)
|
| + return v8::Undefined();
|
| +
|
| + client->requestDeviceMedia(*request);
|
| + return v8::Integer::New(0);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +namespace extensions {
|
| +
|
| +TabCaptureCustomBindings::TabCaptureCustomBindings()
|
| + : ChromeV8Extension(NULL) {
|
| + RouteStaticFunction("RequestDeviceMedia", &RequestDeviceMedia);
|
| +}
|
| +
|
| +} // namespace extensions
|
| +
|
|
|