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 "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_hand
ler.h" | 10 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_hand
ler.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_data_source.h" | 14 #include "content/public/browser/web_ui_data_source.h" |
15 #include "grit/browser_resources.h" | 15 #include "grit/browser_resources.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Create data source for chrome://device-emulator/. | 20 // Create data source for chrome://device-emulator/. |
21 content::WebUIDataSource* CreateDeviceEmulatorUIDataSource() { | 21 content::WebUIDataSource* CreateDeviceEmulatorUIDataSource() { |
22 content::WebUIDataSource* html = | 22 content::WebUIDataSource* html = |
23 content::WebUIDataSource::Create(chrome::kChromeUIDeviceEmulatorHost); | 23 content::WebUIDataSource::Create(chrome::kChromeUIDeviceEmulatorHost); |
24 | 24 |
25 html->SetJsonPath("strings.js"); | 25 html->SetJsonPath("strings.js"); |
26 | 26 |
27 // Add resources. | 27 // Add resources. |
28 html->AddResourcePath("device_emulator.css", IDR_DEVICE_EMULATOR_CSS); | 28 html->AddResourcePath("device_emulator.css", IDR_DEVICE_EMULATOR_CSS); |
29 html->AddResourcePath("device_emulator.js", IDR_DEVICE_EMULATOR_JS); | 29 html->AddResourcePath("device_emulator.js", IDR_DEVICE_EMULATOR_JS); |
| 30 html->AddResourcePath("audio_settings.html", IDR_AUDIO_SETTINGS_HTML); |
| 31 html->AddResourcePath("audio_settings.css", IDR_AUDIO_SETTINGS_CSS); |
| 32 html->AddResourcePath("audio_settings.js", IDR_AUDIO_SETTINGS_JS); |
30 html->AddResourcePath("battery_settings.html", IDR_BATTERY_SETTINGS_HTML); | 33 html->AddResourcePath("battery_settings.html", IDR_BATTERY_SETTINGS_HTML); |
31 html->AddResourcePath("battery_settings.css", IDR_BATTERY_SETTINGS_CSS); | 34 html->AddResourcePath("battery_settings.css", IDR_BATTERY_SETTINGS_CSS); |
32 html->AddResourcePath("battery_settings.js", IDR_BATTERY_SETTINGS_JS); | 35 html->AddResourcePath("battery_settings.js", IDR_BATTERY_SETTINGS_JS); |
33 html->AddResourcePath("bluetooth_settings.html", IDR_BLUETOOTH_SETTINGS_HTML); | 36 html->AddResourcePath("bluetooth_settings.html", IDR_BLUETOOTH_SETTINGS_HTML); |
34 html->AddResourcePath("bluetooth_settings.css", IDR_BLUETOOTH_SETTINGS_CSS); | 37 html->AddResourcePath("bluetooth_settings.css", IDR_BLUETOOTH_SETTINGS_CSS); |
35 html->AddResourcePath("bluetooth_settings.js", IDR_BLUETOOTH_SETTINGS_JS); | 38 html->AddResourcePath("bluetooth_settings.js", IDR_BLUETOOTH_SETTINGS_JS); |
36 html->SetDefaultResource(IDR_DEVICE_EMULATOR_HTML); | 39 html->SetDefaultResource(IDR_DEVICE_EMULATOR_HTML); |
37 | 40 |
38 return html; | 41 return html; |
39 } | 42 } |
40 | 43 |
41 } // namespace | 44 } // namespace |
42 | 45 |
43 DeviceEmulatorUI::DeviceEmulatorUI(content::WebUI* web_ui) | 46 DeviceEmulatorUI::DeviceEmulatorUI(content::WebUI* web_ui) |
44 : WebUIController(web_ui) { | 47 : WebUIController(web_ui) { |
45 chromeos::DeviceEmulatorMessageHandler* handler = | 48 chromeos::DeviceEmulatorMessageHandler* handler = |
46 new chromeos::DeviceEmulatorMessageHandler(); | 49 new chromeos::DeviceEmulatorMessageHandler(); |
47 handler->Init(); | 50 handler->Init(); |
48 web_ui->AddMessageHandler(handler); | 51 web_ui->AddMessageHandler(handler); |
49 | 52 |
50 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | 53 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
51 CreateDeviceEmulatorUIDataSource()); | 54 CreateDeviceEmulatorUIDataSource()); |
52 } | 55 } |
53 | 56 |
54 DeviceEmulatorUI::~DeviceEmulatorUI() { | 57 DeviceEmulatorUI::~DeviceEmulatorUI() { |
55 } | 58 } |
OLD | NEW |