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..671c1f19612e456e84776bde1d57a023fee89a1c |
| --- /dev/null |
| +++ b/Source/modules/presentation/NavigatorPresentation.cpp |
| @@ -0,0 +1,74 @@ |
| +/* |
| + * 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.
|
| + * |
| + * This library is free software; you can redistribute it and/or |
| + * modify it under the terms of the GNU Lesser General Public |
| + * License as published by the Free Software Foundation; either |
| + * version 2 of the License, or (at your option) any later version. |
| + * |
| + * This library is distributed in the hope that it will be useful, |
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| + * Lesser General Public License for more details. |
| + * |
| + * You should have received a copy of the GNU Lesser General Public |
| + * License along with this library; if not, write to the Free Software |
| + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| + */ |
| + |
| +#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" |
| + |
| +namespace WebCore { |
| + |
| +NavigatorPresentation::NavigatorPresentation(LocalFrame* frame) |
| + : DOMWindowProperty(frame) |
| +{ |
| +} |
| + |
| +NavigatorPresentation::~NavigatorPresentation() |
| +{ |
| +} |
| + |
| +// 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.
|
| +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) |
|
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
|
| +{ |
| + return NavigatorPresentation::from(navigator).presentation(); |
| +} |
| + |
| +Presentation* NavigatorPresentation::presentation() const |
| +{ |
| + 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 :)
|
| + m_presentation = Presentation::create(frame()->document()); |
| + return m_presentation.get(); |
| +} |
| + |
| +void NavigatorPresentation::trace(Visitor* visitor) |
| +{ |
| + visitor->trace(m_presentation); |
| + WillBeHeapSupplement<Navigator>::trace(visitor); |
| +} |
| + |
| +} // namespace WebCore |