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 "config.h" | 5 #include "config.h" |
6 #include "modules/presentation/NavigatorPresentation.h" | 6 #include "modules/presentation/NavigatorPresentation.h" |
7 | 7 |
8 #include "core/dom/Document.h" | |
9 #include "core/frame/LocalFrame.h" | |
10 #include "core/frame/Navigator.h" | 8 #include "core/frame/Navigator.h" |
11 #include "modules/presentation/Presentation.h" | 9 #include "modules/presentation/Presentation.h" |
12 #include "platform/heap/Handle.h" | |
13 | 10 |
14 namespace blink { | 11 namespace blink { |
15 | 12 |
16 NavigatorPresentation::NavigatorPresentation(LocalFrame* frame) | 13 NavigatorPresentation::NavigatorPresentation() |
17 : DOMWindowProperty(frame) | |
18 { | 14 { |
19 } | 15 } |
20 | 16 |
21 NavigatorPresentation::~NavigatorPresentation() | 17 NavigatorPresentation::~NavigatorPresentation() |
22 { | 18 { |
23 } | 19 } |
24 | 20 |
25 // static | 21 // static |
26 const char* NavigatorPresentation::supplementName() | 22 const char* NavigatorPresentation::supplementName() |
27 { | 23 { |
28 return "NavigatorPresentation"; | 24 return "NavigatorPresentation"; |
29 } | 25 } |
30 | 26 |
31 // static | 27 // static |
32 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) | 28 NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator) |
33 { | 29 { |
34 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Will
BeHeapSupplement<Navigator>::from(navigator, supplementName())); | 30 NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(Will
BeHeapSupplement<Navigator>::from(navigator, supplementName())); |
35 if (!supplement) { | 31 if (!supplement) { |
36 supplement = new NavigatorPresentation(navigator.frame()); | 32 supplement = new NavigatorPresentation(); |
37 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | 33 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); |
38 } | 34 } |
39 return *supplement; | 35 return *supplement; |
40 } | 36 } |
41 | 37 |
42 // static | 38 // static |
43 Presentation* NavigatorPresentation::presentation(Navigator& navigator) | 39 Presentation* NavigatorPresentation::presentation(Navigator& navigator) |
44 { | 40 { |
45 return NavigatorPresentation::from(navigator).presentation(); | 41 NavigatorPresentation& self = NavigatorPresentation::from(navigator); |
46 } | 42 if (!self.m_presentation) { |
47 | 43 if (!navigator.frame()) |
48 Presentation* NavigatorPresentation::presentation() | 44 return nullptr; |
49 { | 45 self.m_presentation = Presentation::create(navigator.frame()); |
50 if (!m_presentation) { | |
51 if (!frame()) | |
52 return 0; | |
53 m_presentation = Presentation::create(frame()->document()); | |
54 } | 46 } |
55 return m_presentation.get(); | 47 return self.m_presentation.get(); |
56 } | 48 } |
57 | 49 |
58 void NavigatorPresentation::trace(Visitor* visitor) | 50 void NavigatorPresentation::trace(Visitor* visitor) |
59 { | 51 { |
60 visitor->trace(m_presentation); | 52 visitor->trace(m_presentation); |
61 WillBeHeapSupplement<Navigator>::trace(visitor); | 53 WillBeHeapSupplement<Navigator>::trace(visitor); |
62 DOMWindowProperty::trace(visitor); | |
63 } | 54 } |
64 | 55 |
65 } // namespace blink | 56 } // namespace blink |
OLD | NEW |