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" | |
| 9 #include "core/frame/LocalFrame.h" | |
| 10 #include "core/frame/Navigator.h" | |
| 11 #include "modules/presentation/Presentation.h" | |
| 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 if (!m_presentation && frame()) | |
| 51 m_presentation = Presentation::create(frame()->document()); | |
| 52 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
| |
| 53 } | |
| 54 | |
| 55 void NavigatorPresentation::trace(Visitor* visitor) | |
| 56 { | |
| 57 visitor->trace(m_presentation); | |
| 58 WillBeHeapSupplement<Navigator>::trace(visitor); | |
| 59 } | |
| 60 | |
| 61 } // namespace blink | |
| OLD | NEW |