| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/html/HTMLIFrameElement.h" | |
| 6 | |
| 7 #include "gen/sky/core/HTMLNames.h" | |
| 8 #include "sky/engine/core/frame/LocalFrame.h" | |
| 9 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" | |
| 10 #include "sky/engine/core/loader/FrameLoaderClient.h" | |
| 11 #include "sky/engine/core/rendering/RenderIFrame.h" | |
| 12 #include "sky/engine/tonic/mojo_converter.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(Document& document) | |
| 17 { | |
| 18 return adoptRef(new HTMLIFrameElement(document)); | |
| 19 } | |
| 20 | |
| 21 HTMLIFrameElement::HTMLIFrameElement(Document& document) | |
| 22 : HTMLElement(HTMLNames::iframeTag, document), | |
| 23 m_contentView(nullptr) | |
| 24 { | |
| 25 } | |
| 26 | |
| 27 HTMLIFrameElement::~HTMLIFrameElement() | |
| 28 { | |
| 29 if (m_contentView) | |
| 30 m_contentView->RemoveObserver(this); | |
| 31 } | |
| 32 | |
| 33 void HTMLIFrameElement::insertedInto(ContainerNode* insertionPoint) | |
| 34 { | |
| 35 HTMLElement::insertedInto(insertionPoint); | |
| 36 if (insertionPoint->inDocument()) { | |
| 37 if (LocalFrame* frame = document().frame()) { | |
| 38 m_contentView = frame->loaderClient()->createChildFrame(); | |
| 39 m_contentView->AddObserver(this); | |
| 40 } | |
| 41 navigateView(); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) | |
| 46 { | |
| 47 HTMLElement::removedFrom(insertionPoint); | |
| 48 if (m_contentView) | |
| 49 m_contentView->Destroy(); | |
| 50 } | |
| 51 | |
| 52 void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | |
| 53 { | |
| 54 if (name == HTMLNames::srcAttr) { | |
| 55 navigateView(); | |
| 56 } else { | |
| 57 HTMLElement::parseAttribute(name, value); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) | |
| 62 { | |
| 63 return new RenderIFrame(this); | |
| 64 } | |
| 65 | |
| 66 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view) | |
| 67 { | |
| 68 DCHECK_EQ(view, m_contentView); | |
| 69 m_contentView = nullptr; | |
| 70 } | |
| 71 | |
| 72 PassRefPtr<DartValue> HTMLIFrameElement::takeServicesHandle(DartState*) | |
| 73 { | |
| 74 return DartValue::Create(); | |
| 75 } | |
| 76 | |
| 77 PassRefPtr<DartValue> HTMLIFrameElement::takeExposedServicesHandle(DartState*) | |
| 78 { | |
| 79 return DartValue::Create(); | |
| 80 } | |
| 81 | |
| 82 void HTMLIFrameElement::embedViewManagerClient(RefPtr<DartValue> client) | |
| 83 { | |
| 84 if (!m_contentView) | |
| 85 return; | |
| 86 | |
| 87 mojo::ScopedMessagePipeHandle handle = DartConverter<mojo::ScopedMessagePipe
Handle>::FromDart(client->dart_value()); | |
| 88 mojo::ViewManagerClientPtr client_ptr = mojo::MakeProxy( | |
| 89 mojo::InterfacePtrInfo<mojo::ViewManagerClient>(handle.Pass(), 0u)); | |
| 90 m_contentView->Embed(client_ptr.Pass()); | |
| 91 } | |
| 92 | |
| 93 void HTMLIFrameElement::navigateView() | |
| 94 { | |
| 95 if (!m_contentView) | |
| 96 return; | |
| 97 | |
| 98 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames:
:srcAttr)); | |
| 99 if (urlString.isEmpty()) | |
| 100 urlString = blankURL().string(); | |
| 101 | |
| 102 KURL url = document().completeURL(urlString); | |
| 103 | |
| 104 mojo::MessagePipe exposedServicesPipe; | |
| 105 m_exposedServices = exposedServicesPipe.handle0.Pass(); | |
| 106 | |
| 107 m_contentView->Embed(mojo::String::From(url.string().utf8().data()), | |
| 108 mojo::GetProxy(&m_services), | |
| 109 mojo::MakeProxy(mojo::InterfacePtrInfo<mojo::ServiceProvider>(exposedSer
vicesPipe.handle1.Pass(), 0u))); | |
| 110 } | |
| 111 | |
| 112 } | |
| OLD | NEW |