mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This removes the symmetrical nature of ServiceProvider and consistently passes and uses a ServiceProvider + ServiceProvider& pair in places that wish to bidirectionally expose services, such as the view manager. The view manager library now deals with InterfaceRequest<ServiceProvider> and ServiceProviderPtr objects (i.e. c++ wrappers for handles) instead of a concrete implementation of ServiceProvider to make it easier for callers. A number of places that were assuming a particular ServiceProvider would always exist are updated to reflect the nullability of the parameters in mojom and places that do not wish to ever look up or provide services now pass nullptr instead of doomed pipe handles. The JS application startup classes are reworked a bit to accomodate exposing services on the third ConnectToApplication/AcceptConnection parameter. BUG=449432 R=abarth@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/858103002
86 lines
2.3 KiB
C++
86 lines
2.3 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/core/html/HTMLIFrameElement.h"
|
|
|
|
#include "gen/sky/core/HTMLNames.h"
|
|
#include "mojo/edk/js/handle.h"
|
|
#include "sky/engine/core/frame/LocalFrame.h"
|
|
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
|
|
#include "sky/engine/core/loader/FrameLoaderClient.h"
|
|
#include "sky/engine/core/rendering/RenderIFrame.h"
|
|
|
|
namespace blink {
|
|
|
|
PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(Document& document)
|
|
{
|
|
return adoptRef(new HTMLIFrameElement(document));
|
|
}
|
|
|
|
HTMLIFrameElement::HTMLIFrameElement(Document& document)
|
|
: HTMLElement(HTMLNames::iframeTag, document),
|
|
m_contentView(nullptr)
|
|
{
|
|
}
|
|
|
|
HTMLIFrameElement::~HTMLIFrameElement()
|
|
{
|
|
if (m_contentView)
|
|
m_contentView->RemoveObserver(this);
|
|
}
|
|
|
|
void HTMLIFrameElement::insertedInto(ContainerNode* insertionPoint)
|
|
{
|
|
HTMLElement::insertedInto(insertionPoint);
|
|
if (insertionPoint->inDocument())
|
|
createView();
|
|
}
|
|
|
|
void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint)
|
|
{
|
|
HTMLElement::removedFrom(insertionPoint);
|
|
if (m_contentView)
|
|
m_contentView->Destroy();
|
|
}
|
|
|
|
RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style)
|
|
{
|
|
return new RenderIFrame(this);
|
|
}
|
|
|
|
void HTMLIFrameElement::OnViewDestroyed(mojo::View* view)
|
|
{
|
|
DCHECK_EQ(view, m_contentView);
|
|
m_contentView = nullptr;
|
|
}
|
|
|
|
ScriptValue HTMLIFrameElement::takeServiceProvider(ScriptState* scriptState)
|
|
{
|
|
return ScriptValue(scriptState, gin::ConvertToV8(scriptState->isolate(), m_services.PassMessagePipe().release()));
|
|
}
|
|
|
|
void HTMLIFrameElement::createView()
|
|
{
|
|
String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames::srcAttr));
|
|
if (urlString.isEmpty())
|
|
urlString = blankURL().string();
|
|
|
|
LocalFrame* parentFrame = document().frame();
|
|
if (!parentFrame)
|
|
return;
|
|
|
|
KURL url = document().completeURL(urlString);
|
|
m_contentView = parentFrame->loaderClient()->createChildFrame();
|
|
if (!m_contentView)
|
|
return;
|
|
|
|
m_contentView->Embed(mojo::String::From(url.string().utf8().data()),
|
|
GetProxy(&m_services),
|
|
nullptr); // TODO(abarth) Expose the exposedService parameter.
|
|
m_contentView->AddObserver(this);
|
|
}
|
|
|
|
}
|