NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / ui / keyboard / keyboard_ui_controller.cc
blob420b933cf1f5209603bd0e0170cd19e704c88edc
1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_ui_controller.h"
7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_ui.h"
10 #include "content/public/browser/web_ui_data_source.h"
11 #include "grit/keyboard_resources.h"
12 #include "ui/keyboard/keyboard_constants.h"
13 #include "ui/keyboard/keyboard_ui_handler.h"
15 namespace {
17 content::WebUIDataSource* CreateKeyboardUIDataSource() {
18 content::WebUIDataSource* source =
19 content::WebUIDataSource::Create(keyboard::kKeyboardWebUIHost);
21 source->SetDefaultResource(IDR_KEYBOARD_WEBUI_INDEX);
22 source->AddResourcePath("elements/kb-altkey.html",
23 IDR_KEYBOARD_ELEMENTS_ALTKEY);
24 source->AddResourcePath("elements/kb-altkey-container.html",
25 IDR_KEYBOARD_ELEMENTS_ALTKEY_CONTAINER);
26 source->AddResourcePath("elements/kb-altkey-data.html",
27 IDR_KEYBOARD_ELEMENTS_ALTKEY_DATA);
28 source->AddResourcePath("elements/kb-altkey-set.html",
29 IDR_KEYBOARD_ELEMENTS_ALTKEY_SET);
30 source->AddResourcePath("elements/kb-key.html", IDR_KEYBOARD_ELEMENTS_KEY);
31 source->AddResourcePath("elements/kb-key-base.html",
32 IDR_KEYBOARD_ELEMENTS_KEY_BASE);
33 source->AddResourcePath("elements/kb-key-codes.html",
34 IDR_KEYBOARD_ELEMENTS_KEY_CODES);
35 source->AddResourcePath("elements/kb-keyboard.html",
36 IDR_KEYBOARD_ELEMENTS_KEYBOARD);
37 source->AddResourcePath("elements/kb-keyset.html",
38 IDR_KEYBOARD_ELEMENTS_KEYSET);
39 source->AddResourcePath("elements/kb-modifier-key.html",
40 IDR_KEYBOARD_ELEMENTS_MODIFIER_KEY);
41 source->AddResourcePath("elements/kb-options-menu.html",
42 IDR_KEYBOARD_ELEMENTS_OPTIONS_MENU);
43 source->AddResourcePath("elements/kb-row.html", IDR_KEYBOARD_ELEMENTS_ROW);
44 source->AddResourcePath("elements/kb-shift-key.html",
45 IDR_KEYBOARD_ELEMENTS_SHIFT_KEY);
46 source->AddResourcePath("images/back.svg",
47 IDR_KEYBOARD_IMAGES_BACK);
48 source->AddResourcePath("images/brightness-down.svg",
49 IDR_KEYBOARD_IMAGES_BRIGHTNESS_DOWN);
50 source->AddResourcePath("images/brightness-up.svg",
51 IDR_KEYBOARD_IMAGES_BRIGHTNESS_UP);
52 source->AddResourcePath("images/change-window.svg",
53 IDR_KEYBOARD_IMAGES_CHANGE_WINDOW);
54 source->AddResourcePath("images/down.svg",
55 IDR_KEYBOARD_IMAGES_DOWN);
56 source->AddResourcePath("images/forward.svg",
57 IDR_KEYBOARD_IMAGES_FORWARD);
58 source->AddResourcePath("images/fullscreen.svg",
59 IDR_KEYBOARD_IMAGES_FULLSCREEN);
60 source->AddResourcePath("images/left.svg",
61 IDR_KEYBOARD_IMAGES_LEFT);
62 source->AddResourcePath("images/microphone.svg",
63 IDR_KEYBOARD_IMAGES_MICROPHONE);
64 source->AddResourcePath("images/microphone-green.svg",
65 IDR_KEYBOARD_IMAGES_MICROPHONE_GREEN);
66 source->AddResourcePath("images/mute.svg",
67 IDR_KEYBOARD_IMAGES_MUTE);
68 source->AddResourcePath("images/reload.svg",
69 IDR_KEYBOARD_IMAGES_RELOAD);
70 source->AddResourcePath("images/right.svg",
71 IDR_KEYBOARD_IMAGES_RIGHT);
72 source->AddResourcePath("images/search.svg",
73 IDR_KEYBOARD_IMAGES_SEARCH);
74 source->AddResourcePath("images/shutdown.svg",
75 IDR_KEYBOARD_IMAGES_SHUTDOWN);
76 source->AddResourcePath("images/up.svg",
77 IDR_KEYBOARD_IMAGES_UP);
78 source->AddResourcePath("images/volume-down.svg",
79 IDR_KEYBOARD_IMAGES_VOLUME_DOWN);
80 source->AddResourcePath("images/volume-up.svg",
81 IDR_KEYBOARD_IMAGES_VOLUME_UP);
82 source->AddResourcePath("layouts/latin-accents.js",
83 IDR_KEYBOARD_LAYOUTS_LATIN_ACCENTS);
84 source->AddResourcePath("layouts/numeric.html", IDR_KEYBOARD_LAYOUTS_NUMERIC);
85 source->AddResourcePath("layouts/system-qwerty.html",
86 IDR_KEYBOARD_LAYOUTS_SYSTEM_QWERTY);
87 source->AddResourcePath("main.js", IDR_KEYBOARD_MAIN_JS);
88 source->AddResourcePath("polymer_loader.js", IDR_KEYBOARD_POLYMER_LOADER);
89 source->AddResourcePath("roboto_bold.ttf", IDR_KEYBOARD_ROBOTO_BOLD_TTF);
90 source->AddResourcePath("voice_input.js", IDR_KEYBOARD_VOICE_INPUT_JS);
92 // These files are specific to the WebUI version
93 source->AddResourcePath("api_adapter.js", IDR_KEYBOARD_WEBUI_API_ADAPTER_JS);
94 source->AddResourcePath("constants.js", IDR_KEYBOARD_WEBUI_CONSTANTS_JS);
95 source->AddResourcePath("layouts/qwerty.html", IDR_KEYBOARD_WEBUI_QWERTY);
96 source->AddResourcePath("main.css", IDR_KEYBOARD_WEBUI_MAIN_CSS);
98 return source;
101 } // namespace
103 namespace keyboard {
105 KeyboardUIController::KeyboardUIController(content::WebUI* web_ui)
106 : WebUIController(web_ui) {
107 content::BrowserContext* browser_context =
108 web_ui->GetWebContents()->GetBrowserContext();
109 web_ui->AddMessageHandler(new KeyboardUIHandler());
110 content::WebUIDataSource::Add(
111 browser_context,
112 CreateKeyboardUIDataSource());
115 KeyboardUIController::~KeyboardUIController() {}
117 } // namespace keyboard