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

Unified Diff: third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp

Issue 2252783004: Implement MediaSession (metadata) per frame [NOT READY, HAS DEPENDENCY] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Anton's comments Created 4 years, 3 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: third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp
diff --git a/third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp b/third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efdcd34c636b02789b08d3f837a74a5f5b3f3020
--- /dev/null
+++ b/third_party/WebKit/Source/modules/mediasession/NavigatorMediaSession.cpp
@@ -0,0 +1,47 @@
+// Copyright 2016 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 "modules/mediasession/NavigatorMediaSession.h"
+
+#include "bindings/core/v8/ExceptionStatePlaceholder.h"
+#include "modules/mediasession/MediaSession.h"
+#include "platform/Supplementable.h"
+
+namespace blink {
+
+NavigatorMediaSession::NavigatorMediaSession(Navigator& navigator)
+ : DOMWindowProperty(navigator.frame())
+{
+ if (!frame())
+ return;
+ m_session = MediaSession::create(frame(), IGNORE_EXCEPTION);
+}
+
+DEFINE_TRACE(NavigatorMediaSession)
+{
+ visitor->trace(m_session);
+ Supplement<Navigator>::trace(visitor);
+ DOMWindowProperty::trace(visitor);
+}
+
+const char* NavigatorMediaSession::supplementName()
+{
+ return "NavigatorMediaSession";
+}
+
+NavigatorMediaSession& NavigatorMediaSession::from(Navigator& navigator)
+{
+ NavigatorMediaSession* supplement = static_cast<NavigatorMediaSession*>(Supplement<Navigator>::from(navigator, supplementName()));
+ if (!supplement) {
+ supplement = new NavigatorMediaSession(navigator);
+ provideTo(navigator, supplementName(), supplement);
+ }
+ return *supplement;
+}
+
+MediaSession* NavigatorMediaSession::mediaSession(Navigator& navigator)
+{
+ return NavigatorMediaSession::from(navigator).m_session.get();
+}
+}

Powered by Google App Engine
This is Rietveld 408576698