Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / emulator / device_emulator_ui.cc
blob1c549ee1d63721b1e04050daf2d7ee71c290442a
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 "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/browser_resources.h"
16 #include "grit/generated_resources.h"
18 namespace {
20 // Create data source for chrome://device-emulator/.
21 content::WebUIDataSource* CreateDeviceEmulatorUIDataSource() {
22 content::WebUIDataSource* html =
23 content::WebUIDataSource::Create(chrome::kChromeUIDeviceEmulatorHost);
25 html->SetJsonPath("strings.js");
27 // Add resources.
28 html->AddResourcePath("device_emulator.css", IDR_DEVICE_EMULATOR_CSS);
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);
33 html->AddResourcePath("battery_settings.html", IDR_BATTERY_SETTINGS_HTML);
34 html->AddResourcePath("battery_settings.css", IDR_BATTERY_SETTINGS_CSS);
35 html->AddResourcePath("battery_settings.js", IDR_BATTERY_SETTINGS_JS);
36 html->AddResourcePath("bluetooth_settings.html", IDR_BLUETOOTH_SETTINGS_HTML);
37 html->AddResourcePath("bluetooth_settings.css", IDR_BLUETOOTH_SETTINGS_CSS);
38 html->AddResourcePath("bluetooth_settings.js", IDR_BLUETOOTH_SETTINGS_JS);
39 html->SetDefaultResource(IDR_DEVICE_EMULATOR_HTML);
41 return html;
44 } // namespace
46 DeviceEmulatorUI::DeviceEmulatorUI(content::WebUI* web_ui)
47 : WebUIController(web_ui) {
48 chromeos::DeviceEmulatorMessageHandler* handler =
49 new chromeos::DeviceEmulatorMessageHandler();
50 handler->Init();
51 web_ui->AddMessageHandler(handler);
53 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
54 CreateDeviceEmulatorUIDataSource());
57 DeviceEmulatorUI::~DeviceEmulatorUI() {