Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/presentation/NavigatorPresentation.h" | |
| 7 | |
| 8 #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
| |
| 9 #include "core/frame/LocalFrame.h" | |
| 10 #include "core/frame/Navigator.h" | |
| 11 #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.
| |
| 12 #include "platform/heap/Handle.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 NavigatorPresentation::NavigatorPresentation(LocalFrame* frame) | |
| 17 : DOMWindowProperty(frame) | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 NavigatorPresentation::~NavigatorPresentation() | |
| 22 { | |
| 23 } | |
| 24 | |
| 25 // static | |
| 26 const char* NavigatorPresentation::supplementName() | |
| 27 { | |
| 28 return "NavigatorPresentation"; | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) | |
| 33 { | |
| 34 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Will BeHeapSupplement<Navigator>::from(navigator, supplementName())); | |
| 35 if (!supplement) { | |
| 36 supplement = new NavigatorPresentation(navigator.frame()); | |
| 37 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | |
| 38 } | |
| 39 return *supplement; | |
| 40 } | |
| 41 | |
| 42 // static | |
| 43 Presentation& NavigatorPresentation::presentation(Navigator& navigator) | |
| 44 { | |
| 45 return NavigatorPresentation::from(navigator).presentation(); | |
| 46 } | |
| 47 | |
| 48 Presentation& NavigatorPresentation::presentation() | |
| 49 { | |
| 50 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
| |
| 51 if (!m_presentation) | |
| 52 m_presentation = Presentation::create(frame()); | |
| 53 return *m_presentation.get(); | |
| 54 } | |
| 55 | |
| 56 void NavigatorPresentation::trace(Visitor* visitor) | |
| 57 { | |
| 58 visitor->trace(m_presentation); | |
| 59 WillBeHeapSupplement<Navigator>::trace(visitor); | |
| 60 } | |
| 61 | |
| 62 } // namespace blink | |
| OLD | NEW |