| 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(Navigator& navigator) |
| 13 : Supplement<Navigator>(navigator) {} |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 const char* NavigatorPresentation::supplementName() { | 16 const char* NavigatorPresentation::supplementName() { |
| 16 return "NavigatorPresentation"; | 17 return "NavigatorPresentation"; |
| 17 } | 18 } |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) { | 21 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) { |
| 21 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>( | 22 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>( |
| 22 Supplement<Navigator>::from(navigator, supplementName())); | 23 Supplement<Navigator>::from(navigator, supplementName())); |
| 23 if (!supplement) { | 24 if (!supplement) { |
| 24 supplement = new NavigatorPresentation(); | 25 supplement = new NavigatorPresentation(navigator); |
| 25 provideTo(navigator, supplementName(), supplement); | 26 provideTo(navigator, supplementName(), supplement); |
| 26 } | 27 } |
| 27 return *supplement; | 28 return *supplement; |
| 28 } | 29 } |
| 29 | 30 |
| 30 // static | 31 // static |
| 31 Presentation* NavigatorPresentation::presentation(Navigator& navigator) { | 32 Presentation* NavigatorPresentation::presentation(Navigator& navigator) { |
| 32 NavigatorPresentation& self = NavigatorPresentation::from(navigator); | 33 NavigatorPresentation& self = NavigatorPresentation::from(navigator); |
| 33 if (!self.m_presentation) { | 34 if (!self.m_presentation) { |
| 34 if (!navigator.frame()) | 35 if (!navigator.frame()) |
| 35 return nullptr; | 36 return nullptr; |
| 36 self.m_presentation = Presentation::create(navigator.frame()); | 37 self.m_presentation = Presentation::create(navigator.frame()); |
| 37 } | 38 } |
| 38 return self.m_presentation; | 39 return self.m_presentation; |
| 39 } | 40 } |
| 40 | 41 |
| 41 DEFINE_TRACE(NavigatorPresentation) { | 42 DEFINE_TRACE(NavigatorPresentation) { |
| 42 visitor->trace(m_presentation); | 43 visitor->trace(m_presentation); |
| 43 Supplement<Navigator>::trace(visitor); | 44 Supplement<Navigator>::trace(visitor); |
| 44 } | 45 } |
| 45 | 46 |
| 46 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |