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

Unified Diff: Source/modules/presentation/NavigatorPresentation.cpp

Issue 408663002: Add the Presentation API module and a single event target (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changed Presentation to be ContextLifecycleObserver Created 6 years, 4 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/presentation/NavigatorPresentation.cpp
diff --git a/Source/modules/presentation/NavigatorPresentation.cpp b/Source/modules/presentation/NavigatorPresentation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efb1507daa7730875efe981eb60fb804bde50b86
--- /dev/null
+++ b/Source/modules/presentation/NavigatorPresentation.cpp
@@ -0,0 +1,61 @@
+// Copyright 2014 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/presentation/NavigatorPresentation.h"
+
+#include "core/dom/Document.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/Navigator.h"
+#include "modules/presentation/Presentation.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+NavigatorPresentation::NavigatorPresentation(LocalFrame* frame)
+ : DOMWindowProperty(frame)
+{
+}
+
+NavigatorPresentation::~NavigatorPresentation()
+{
+}
+
+// static
+const char* NavigatorPresentation::supplementName()
+{
+ return "NavigatorPresentation";
+}
+
+// static
+NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator)
+{
+ NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
+ if (!supplement) {
+ supplement = new NavigatorPresentation(navigator.frame());
+ provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
+ }
+ return *supplement;
+}
+
+// static
+Presentation& NavigatorPresentation::presentation(Navigator& navigator)
+{
+ return NavigatorPresentation::from(navigator).presentation();
+}
+
+Presentation& NavigatorPresentation::presentation()
+{
+ if (!m_presentation && frame())
+ m_presentation = Presentation::create(frame()->document());
+ return *m_presentation.get();
eseidel 2014/08/19 18:20:58 Won't this fail if frame is null?
whywhat 2014/08/20 16:40:42 Should I then change the return type to a pointer
+}
+
+void NavigatorPresentation::trace(Visitor* visitor)
+{
+ visitor->trace(m_presentation);
+ WillBeHeapSupplement<Navigator>::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698