1 // Copyright 2015 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.
5 #include "components/web_view/public/cpp/web_view.h"
8 #include "components/mus/public/cpp/view.h"
9 #include "mojo/application/public/cpp/application_impl.h"
14 void OnEmbed(bool success
, uint16 connection_id
) {
20 WebView::WebView(mojom::WebViewClient
* client
) : binding_(client
) {}
21 WebView::~WebView() {}
23 void WebView::Init(mojo::ApplicationImpl
* app
, mus::View
* view
) {
24 mojo::URLRequestPtr
request(mojo::URLRequest::New());
25 request
->url
= "mojo:web_view";
27 mojom::WebViewClientPtr client
;
28 mojo::InterfaceRequest
<mojom::WebViewClient
> client_request
=
30 binding_
.Bind(client_request
.Pass());
32 mojom::WebViewFactoryPtr factory
;
33 app
->ConnectToService(request
.Pass(), &factory
);
34 factory
->CreateWebView(client
.Pass(), GetProxy(&web_view_
));
36 mojo::ViewTreeClientPtr view_tree_client
;
37 web_view_
->GetViewTreeClient(GetProxy(&view_tree_client
));
38 view
->Embed(view_tree_client
.Pass(), mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT
,
39 base::Bind(&OnEmbed
));
42 } // namespace web_view