Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. | |
|
Peter Beverloo
2014/07/19 10:16:12
nit: Need to use the new copyright comment (as in
whywhat
2014/07/23 00:39:25
Done.
| |
| 3 * | |
| 4 * This library is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Lesser General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * This library is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Lesser General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU Lesser General Public | |
| 15 * License along with this library; if not, write to the Free Software | |
| 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA | |
| 17 */ | |
| 18 | |
| 19 #include "config.h" | |
| 20 #include "modules/presentation/NavigatorPresentation.h" | |
| 21 | |
| 22 #include "core/dom/Document.h" | |
| 23 #include "core/frame/LocalFrame.h" | |
| 24 #include "core/frame/Navigator.h" | |
| 25 #include "modules/presentation/Presentation.h" | |
| 26 | |
| 27 namespace WebCore { | |
| 28 | |
| 29 NavigatorPresentation::NavigatorPresentation(LocalFrame* frame) | |
| 30 : DOMWindowProperty(frame) | |
| 31 { | |
| 32 } | |
| 33 | |
| 34 NavigatorPresentation::~NavigatorPresentation() | |
| 35 { | |
| 36 } | |
| 37 | |
| 38 // static | |
|
Peter Beverloo
2014/07/19 10:16:12
micro nit: The // static comments aren't part of t
whywhat
2014/07/23 00:39:25
Acknowledged.
| |
| 39 const char* NavigatorPresentation::supplementName() | |
| 40 { | |
| 41 return "NavigatorPresentation"; | |
| 42 } | |
| 43 | |
| 44 // static | |
| 45 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) | |
| 46 { | |
| 47 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Will BeHeapSupplement<Navigator>::from(navigator, supplementName())); | |
| 48 if (!supplement) { | |
| 49 supplement = new NavigatorPresentation(navigator.frame()); | |
| 50 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | |
| 51 } | |
| 52 return *supplement; | |
| 53 } | |
| 54 | |
| 55 // static | |
| 56 Presentation* NavigatorPresentation::presentation(Navigator& navigator) | |
|
Peter Beverloo
2014/07/19 10:16:12
You should return a reference since this won't eve
whywhat
2014/07/23 00:39:25
Done. I wonder if it should be NULL in cases when
Peter Beverloo
2014/07/25 18:01:17
Sounds like something you should have a design doc
| |
| 57 { | |
| 58 return NavigatorPresentation::from(navigator).presentation(); | |
| 59 } | |
| 60 | |
| 61 Presentation* NavigatorPresentation::presentation() const | |
| 62 { | |
| 63 if (!m_presentation && frame()) | |
|
Peter Beverloo
2014/07/19 10:16:12
ASSERT() on frame() instead? When wouldn't there b
whywhat
2014/07/23 00:39:25
No idea. Seems everyone's checking for it :)
| |
| 64 m_presentation = Presentation::create(frame()->document()); | |
| 65 return m_presentation.get(); | |
| 66 } | |
| 67 | |
| 68 void NavigatorPresentation::trace(Visitor* visitor) | |
| 69 { | |
| 70 visitor->trace(m_presentation); | |
| 71 WillBeHeapSupplement<Navigator>::trace(visitor); | |
| 72 } | |
| 73 | |
| 74 } // namespace WebCore | |
| OLD | NEW |