| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/presentation/NavigatorPresentation.h" | 5 #include "modules/presentation/NavigatorPresentation.h" |
| 6 | 6 |
| 7 #include "core/frame/Navigator.h" | 7 #include "core/frame/Navigator.h" |
| 8 #include "modules/presentation/Presentation.h" | 8 #include "modules/presentation/Presentation.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 NavigatorPresentation::NavigatorPresentation() | 12 NavigatorPresentation::NavigatorPresentation() |
| 13 { | 13 { |
| 14 } | 14 } |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 const char* NavigatorPresentation::supplementName() | 17 const char* NavigatorPresentation::supplementName() |
| 18 { | 18 { |
| 19 return "NavigatorPresentation"; | 19 return "NavigatorPresentation"; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) | 23 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) |
| 24 { | 24 { |
| 25 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Heap
Supplement<Navigator>::from(navigator, supplementName())); | 25 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Supp
lement<Navigator>::from(navigator, supplementName())); |
| 26 if (!supplement) { | 26 if (!supplement) { |
| 27 supplement = new NavigatorPresentation(); | 27 supplement = new NavigatorPresentation(); |
| 28 provideTo(navigator, supplementName(), supplement); | 28 provideTo(navigator, supplementName(), supplement); |
| 29 } | 29 } |
| 30 return *supplement; | 30 return *supplement; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 Presentation* NavigatorPresentation::presentation(Navigator& navigator) | 34 Presentation* NavigatorPresentation::presentation(Navigator& navigator) |
| 35 { | 35 { |
| 36 NavigatorPresentation& self = NavigatorPresentation::from(navigator); | 36 NavigatorPresentation& self = NavigatorPresentation::from(navigator); |
| 37 if (!self.m_presentation) { | 37 if (!self.m_presentation) { |
| 38 if (!navigator.frame()) | 38 if (!navigator.frame()) |
| 39 return nullptr; | 39 return nullptr; |
| 40 self.m_presentation = Presentation::create(navigator.frame()); | 40 self.m_presentation = Presentation::create(navigator.frame()); |
| 41 } | 41 } |
| 42 return self.m_presentation; | 42 return self.m_presentation; |
| 43 } | 43 } |
| 44 | 44 |
| 45 DEFINE_TRACE(NavigatorPresentation) | 45 DEFINE_TRACE(NavigatorPresentation) |
| 46 { | 46 { |
| 47 visitor->trace(m_presentation); | 47 visitor->trace(m_presentation); |
| 48 HeapSupplement<Navigator>::trace(visitor); | 48 Supplement<Navigator>::trace(visitor); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace blink | 51 } // namespace blink |
| OLD | NEW |