OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/web_view/public/cpp/web_view.h" | 5 #include "components/web_view/public/cpp/web_view.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
9 #include "mojo/application/public/cpp/application_impl.h" | 11 #include "mojo/application/public/cpp/application_impl.h" |
10 | 12 |
11 namespace web_view { | 13 namespace web_view { |
12 namespace { | 14 namespace { |
13 | 15 |
14 void OnEmbed(bool success, uint16 connection_id) { | 16 void OnEmbed(bool success, uint16_t connection_id) { |
15 CHECK(success); | 17 CHECK(success); |
16 } | 18 } |
17 | 19 |
18 } // namespace | 20 } // namespace |
19 | 21 |
20 WebView::WebView(mojom::WebViewClient* client) : binding_(client) {} | 22 WebView::WebView(mojom::WebViewClient* client) : binding_(client) {} |
21 WebView::~WebView() {} | 23 WebView::~WebView() {} |
22 | 24 |
23 void WebView::Init(mojo::ApplicationImpl* app, mus::Window* window) { | 25 void WebView::Init(mojo::ApplicationImpl* app, mus::Window* window) { |
24 mojom::WebViewClientPtr client; | 26 mojom::WebViewClientPtr client; |
25 mojo::InterfaceRequest<mojom::WebViewClient> client_request = | 27 mojo::InterfaceRequest<mojom::WebViewClient> client_request = |
26 GetProxy(&client); | 28 GetProxy(&client); |
27 binding_.Bind(client_request.Pass()); | 29 binding_.Bind(client_request.Pass()); |
28 | 30 |
29 mojom::WebViewFactoryPtr factory; | 31 mojom::WebViewFactoryPtr factory; |
30 app->ConnectToService("mojo:web_view", &factory); | 32 app->ConnectToService("mojo:web_view", &factory); |
31 factory->CreateWebView(client.Pass(), GetProxy(&web_view_)); | 33 factory->CreateWebView(client.Pass(), GetProxy(&web_view_)); |
32 | 34 |
33 mus::mojom::WindowTreeClientPtr window_tree_client; | 35 mus::mojom::WindowTreeClientPtr window_tree_client; |
34 web_view_->GetWindowTreeClient(GetProxy(&window_tree_client)); | 36 web_view_->GetWindowTreeClient(GetProxy(&window_tree_client)); |
35 window->Embed(window_tree_client.Pass(), | 37 window->Embed(window_tree_client.Pass(), |
36 mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, | 38 mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, |
37 base::Bind(&OnEmbed)); | 39 base::Bind(&OnEmbed)); |
38 } | 40 } |
39 | 41 |
40 } // namespace web_view | 42 } // namespace web_view |
OLD | NEW |