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