Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1481)

Unified Diff: Source/modules/mediastream/MediaDevices.cpp

Issue 1184743002: Implement enumerateDevices() according to spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix expected output of global interface listing test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/mediastream/MediaDevices.cpp
diff --git a/Source/modules/mediastream/MediaDevices.cpp b/Source/modules/mediastream/MediaDevices.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..24537ad028652b24b8f408fdaa2e7731527d617d
--- /dev/null
+++ b/Source/modules/mediastream/MediaDevices.cpp
@@ -0,0 +1,29 @@
+// Copyright 2015 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 "config.h"
+#include "modules/mediastream/MediaDevices.h"
+
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "core/dom/DOMException.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExceptionCode.h"
+#include "modules/mediastream/UserMediaController.h"
+
+namespace blink {
+
+ScriptPromise MediaDevices::enumerateDevices(ScriptState* scriptState)
+{
+ Document* document = toDocument(scriptState->executionContext());
+ UserMediaController* userMedia = UserMediaController::from(document->frame());
+ if (!userMedia)
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError, "No media device controller available; is this a detached window?"));
+
+ MediaDevicesRequest* request = MediaDevicesRequest::create(scriptState, userMedia);
+ return request->start();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698