Chromium Code Reviews| 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..75b48dd6eee06a5a5d8dcb1a6139da410a0c2636 |
| --- /dev/null |
| +++ b/Source/modules/presentation/NavigatorPresentation.cpp |
| @@ -0,0 +1,62 @@ |
| +// 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" |
|
Peter Beverloo
2014/07/25 18:01:17
nit: This seems to be unused.
whywhat
2014/08/19 18:07:34
It's needed for the compiler to know that Document
|
| +#include "core/frame/LocalFrame.h" |
| +#include "core/frame/Navigator.h" |
| +#include "modules/presentation/Presentation.h" |
|
Peter Beverloo
2014/07/25 18:01:17
nit: You include this in the header.
whywhat
2014/08/19 18:07:34
Done.
|
| +#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() |
| +{ |
| + ASSERT(frame()); |
|
Peter Beverloo
2014/07/25 18:01:17
Actually, I think frame() can return NULL when a d
whywhat
2014/08/19 18:07:34
So how do I create a presentation object then? Or
|
| + if (!m_presentation) |
| + m_presentation = Presentation::create(frame()); |
| + return *m_presentation.get(); |
| +} |
| + |
| +void NavigatorPresentation::trace(Visitor* visitor) |
| +{ |
| + visitor->trace(m_presentation); |
| + WillBeHeapSupplement<Navigator>::trace(visitor); |
| +} |
| + |
| +} // namespace blink |