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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
6 #include "sky/engine/core/html/HTMLIFrameElement.h" | 6 #include "sky/engine/core/html/HTMLIFrameElement.h" |
7 | 7 |
8 #include "gen/sky/core/HTMLNames.h" | 8 #include "gen/sky/core/HTMLNames.h" |
9 #include "mojo/edk/js/handle.h" | 9 #include "mojo/edk/js/handle.h" |
10 #include "sky/engine/core/frame/LocalFrame.h" | 10 #include "sky/engine/core/frame/LocalFrame.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 HTMLIFrameElement::~HTMLIFrameElement() | 28 HTMLIFrameElement::~HTMLIFrameElement() |
29 { | 29 { |
30 if (m_contentView) | 30 if (m_contentView) |
31 m_contentView->RemoveObserver(this); | 31 m_contentView->RemoveObserver(this); |
32 } | 32 } |
33 | 33 |
34 void HTMLIFrameElement::insertedInto(ContainerNode* insertionPoint) | 34 void HTMLIFrameElement::insertedInto(ContainerNode* insertionPoint) |
35 { | 35 { |
36 HTMLElement::insertedInto(insertionPoint); | 36 HTMLElement::insertedInto(insertionPoint); |
37 if (insertionPoint->inDocument()) | 37 if (insertionPoint->inDocument()) { |
38 createView(); | 38 if (LocalFrame* frame = document().frame()) |
| 39 m_contentView = frame->loaderClient()->createChildFrame(); |
| 40 navigateView(); |
| 41 } |
39 } | 42 } |
40 | 43 |
41 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) | 44 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) |
42 { | 45 { |
43 HTMLElement::removedFrom(insertionPoint); | 46 HTMLElement::removedFrom(insertionPoint); |
44 if (m_contentView) | 47 if (m_contentView) |
45 m_contentView->Destroy(); | 48 m_contentView->Destroy(); |
46 } | 49 } |
47 | 50 |
| 51 void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| 52 { |
| 53 if (name == HTMLNames::srcAttr) { |
| 54 navigateView(); |
| 55 } else { |
| 56 HTMLElement::parseAttribute(name, value); |
| 57 } |
| 58 } |
| 59 |
48 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) | 60 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) |
49 { | 61 { |
50 return new RenderIFrame(this); | 62 return new RenderIFrame(this); |
51 } | 63 } |
52 | 64 |
53 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view) | 65 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view) |
54 { | 66 { |
55 DCHECK_EQ(view, m_contentView); | 67 DCHECK_EQ(view, m_contentView); |
56 m_contentView = nullptr; | 68 m_contentView = nullptr; |
57 } | 69 } |
58 | 70 |
59 ScriptValue HTMLIFrameElement::takeServiceProvider(ScriptState* scriptState) | 71 ScriptValue HTMLIFrameElement::takeServicesHandle(ScriptState* scriptState) |
60 { | 72 { |
61 return ScriptValue(scriptState, gin::ConvertToV8(scriptState->isolate(), m_s
ervices.PassMessagePipe().release())); | 73 return ScriptValue(scriptState, gin::ConvertToV8(scriptState->isolate(), m_s
ervices.PassMessagePipe().release())); |
62 } | 74 } |
63 | 75 |
64 void HTMLIFrameElement::createView() | 76 ScriptValue HTMLIFrameElement::takeExposedServicesHandle(ScriptState* scriptStat
e) |
65 { | 77 { |
| 78 return ScriptValue(scriptState, gin::ConvertToV8(scriptState->isolate(), m_e
xposedServices.release())); |
| 79 } |
| 80 |
| 81 void HTMLIFrameElement::navigateView() |
| 82 { |
| 83 if (!m_contentView) |
| 84 return; |
| 85 |
66 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames:
:srcAttr)); | 86 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames:
:srcAttr)); |
67 if (urlString.isEmpty()) | 87 if (urlString.isEmpty()) |
68 urlString = blankURL().string(); | 88 urlString = blankURL().string(); |
69 | 89 |
70 LocalFrame* parentFrame = document().frame(); | 90 KURL url = document().completeURL(urlString); |
71 if (!parentFrame) | |
72 return; | |
73 | 91 |
74 KURL url = document().completeURL(urlString); | 92 mojo::MessagePipe exposedServicesPipe; |
75 m_contentView = parentFrame->loaderClient()->createChildFrame(); | 93 m_exposedServices = exposedServicesPipe.handle0.Pass(); |
76 if (!m_contentView) | |
77 return; | |
78 | 94 |
79 m_contentView->Embed(mojo::String::From(url.string().utf8().data()), | 95 m_contentView->Embed(mojo::String::From(url.string().utf8().data()), |
80 GetProxy(&m_services), | 96 mojo::GetProxy(&m_services), |
81 nullptr); // TODO(abarth) Expose the exposedService parameter. | 97 mojo::MakeProxy<mojo::ServiceProvider>(exposedServicesPipe.handle1.Pass(
))); |
82 m_contentView->AddObserver(this); | 98 m_contentView->AddObserver(this); |
83 } | 99 } |
84 | 100 |
85 } | 101 } |
OLD | NEW |