OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h" | 5 #include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter
_service.h" |
8 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
9 #include "chrome/grit/browser_resources.h" | 12 #include "chrome/grit/browser_resources.h" |
10 #include "content/public/browser/web_ui_data_source.h" | 13 #include "content/public/browser/web_ui_data_source.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
11 | 15 |
12 BluetoothInternalsUI::BluetoothInternalsUI(content::WebUI* web_ui) | 16 BluetoothInternalsUI::BluetoothInternalsUI(content::WebUI* web_ui) |
13 : content::WebUIController(web_ui) { | 17 : MojoWebUIController(web_ui) { |
14 // Set up the chrome://bluetooth-internals source. | 18 // Set up the chrome://bluetooth-internals source. |
15 content::WebUIDataSource* html_source = | 19 content::WebUIDataSource* html_source = |
16 content::WebUIDataSource::Create(chrome::kChromeUIBluetoothInternalsHost); | 20 content::WebUIDataSource::Create(chrome::kChromeUIBluetoothInternalsHost); |
17 | 21 |
18 // Add required resources. | 22 // Add required resources. |
19 html_source->AddResourcePath("bluetooth_internals.css", | 23 html_source->AddResourcePath("bluetooth_internals.css", |
20 IDR_BLUETOOTH_INTERNALS_CSS); | 24 IDR_BLUETOOTH_INTERNALS_CSS); |
21 html_source->AddResourcePath("bluetooth_internals.js", | 25 html_source->AddResourcePath("bluetooth_internals.js", |
22 IDR_BLUETOOTH_INTERNALS_JS); | 26 IDR_BLUETOOTH_INTERNALS_JS); |
| 27 html_source->AddResourcePath( |
| 28 "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom", |
| 29 IDR_BLUETOOTH_INTERNALS_MOJO_JS); |
| 30 html_source->AddResourcePath( |
| 31 "device/bluetooth/public/interfaces/bluetooth.mojom", |
| 32 IDR_BLUETOOTH_MOJO_JS); |
23 html_source->SetDefaultResource(IDR_BLUETOOTH_INTERNALS_HTML); | 33 html_source->SetDefaultResource(IDR_BLUETOOTH_INTERNALS_HTML); |
24 | 34 |
25 Profile* profile = Profile::FromWebUI(web_ui); | 35 Profile* profile = Profile::FromWebUI(web_ui); |
26 content::WebUIDataSource::Add(profile, html_source); | 36 content::WebUIDataSource::Add(profile, html_source); |
27 } | 37 } |
28 | 38 |
29 BluetoothInternalsUI::~BluetoothInternalsUI() {} | 39 BluetoothInternalsUI::~BluetoothInternalsUI() {} |
| 40 |
| 41 void BluetoothInternalsUI::BindUIHandler( |
| 42 mojom::InternalsPageHandlerRequest request) { |
| 43 binding_ptr_.reset( |
| 44 new mojo::Binding<mojom::InternalsPageHandler>(this, std::move(request))); |
| 45 } |
| 46 |
| 47 void BluetoothInternalsUI::GetAdapterService( |
| 48 bluetooth::mojom::AdapterRequest request, |
| 49 bluetooth::mojom::AdapterClientPtr client) { |
| 50 mojo::MakeStrongBinding( |
| 51 base::MakeUnique<BluetoothAdapterService>(std::move(client)), |
| 52 std::move(request)); |
| 53 } |
OLD | NEW |