Skip to content

Commit

Permalink
Add a virtual keyboard webui at chrome://keyboard/
Browse files Browse the repository at this point in the history
This is just the old virtual keyboard that was removed a couple of years
ago, being used as a temporary stand-in.

BUG=222801

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=194579

Review URL: https://codereview.chromium.org/13652010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194635 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bryeung@chromium.org committed Apr 17, 2013
1 parent ef95114 commit d7aaed2
Show file tree
Hide file tree
Showing 32 changed files with 1,599 additions and 7 deletions.
12 changes: 12 additions & 0 deletions chrome/browser/extensions/component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "grit/browser_resources.h"
#include "ui/base/resource/resource_bundle.h"

#if defined(USE_AURA)
#include "grit/keyboard_resources.h"
#endif

#if defined(OFFICIAL_BUILD)
#include "chrome/browser/defaults.h"
#endif
Expand Down Expand Up @@ -333,6 +337,12 @@ void ComponentLoader::AddChromeApp() {
#endif
}

void ComponentLoader::AddKeyboardApp() {
#if defined(USE_AURA)
Add(IDR_KEYBOARD_MANIFEST, base::FilePath(FILE_PATH_LITERAL("keyboard")));
#endif
}

// static
void ComponentLoader::EnableBackgroundExtensionsForTesting() {
enable_background_extensions_during_testing = true;
Expand Down Expand Up @@ -387,6 +397,8 @@ void ComponentLoader::AddDefaultComponentExtensions(
AddChromeApp();
}

AddKeyboardApp();

AddDefaultComponentExtensionsWithBackgroundPages(skip_session_components);
}

Expand Down
1 change: 1 addition & 0 deletions chrome/browser/extensions/component_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class ComponentLoader {
void AddOrReloadEnterpriseWebStore();

void AddChromeApp();
void AddKeyboardApp();

// Unloads |component| from the memory.
void UnloadComponent(ComponentExtensionInfo* component);
Expand Down
20 changes: 20 additions & 0 deletions chrome/browser/extensions/image_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
#include "content/public/browser/browser_thread.h"
#include "grit/chrome_unscaled_resources.h"
#include "grit/component_extension_resources_map.h"
#include "grit/keyboard_resources.h"
#include "grit/theme_resources.h"
#include "skia/ext/image_operations.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
#include "webkit/glue/image_decoder.h"

#if defined(USE_AURA)
#include "grit/keyboard_resources.h"
#endif

using content::BrowserThread;
using extensions::Extension;
using extensions::ImageLoader;
Expand Down Expand Up @@ -169,6 +174,21 @@ bool ImageLoader::IsComponentExtensionResource(
{"settings_app/settings_app_icon_16.png", IDR_SETTINGS_APP_ICON_16},
{"settings_app/settings_app_icon_32.png", IDR_SETTINGS_APP_ICON_32},
{"settings_app/settings_app_icon_48.png", IDR_SETTINGS_APP_ICON_48},
#endif
#if defined(USE_AURA)
{"keyboard/index.html", IDR_KEYBOARD_INDEX},
{"keyboard/main.css", IDR_KEYBOARD_MAIN_CSS},
{"keyboard/main.js", IDR_KEYBOARD_MAIN_JS},
{"keyboard/common.js", IDR_KEYBOARD_COMMON_JS},
{"keyboard/layout_us.js", IDR_KEYBOARD_LAYOUT_US_JS},
{"keyboard/images/chevron.svg", IDR_KEYBOARD_IMAGES_CHEVRON},
{"keyboard/images/del.svg", IDR_KEYBOARD_IMAGES_DEL},
{"keyboard/images/keyboard.svg", IDR_KEYBOARD_IMAGES_KEYBOARD},
{"keyboard/images/mic.svg", IDR_KEYBOARD_IMAGES_MIC},
{"keyboard/images/ret.svg", IDR_KEYBOARD_IMAGES_RET},
{"keyboard/images/shift_down.svg", IDR_KEYBOARD_IMAGES_SHIFT_DOWN},
{"keyboard/images/shift.svg", IDR_KEYBOARD_IMAGES_SHIFT},
{"keyboard/images/tab.svg", IDR_KEYBOARD_IMAGES_TAB},
#endif
};
static const size_t kExtraComponentExtensionResourcesSize =
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@

#if defined(USE_AURA)
#include "chrome/browser/ui/webui/gesture_config_ui.h"
#include "ui/keyboard/keyboard_constants.h"
#include "ui/keyboard/keyboard_ui_controller.h"
#endif

#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
Expand Down Expand Up @@ -357,6 +359,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#if defined(USE_AURA)
if (url.host() == chrome::kChromeUIGestureConfigHost)
return &NewWebUI<GestureConfigUI>;
if (url.host() == keyboard::kKeyboardWebUIHost)
return &NewWebUI<keyboard::KeyboardUIController>;
#endif

#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
Expand Down
6 changes: 6 additions & 0 deletions chrome/chrome_browser_extensions.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'../third_party/libusb/libusb.gyp:libusb',
'../third_party/re2/re2.gyp:re2',
'../ui/base/strings/ui_strings.gyp:ui_strings',
'../ui/keyboard/keyboard.gyp:keyboard_resources',
'../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources',
'../webkit/support/webkit_support.gyp:glue',
Expand Down Expand Up @@ -827,6 +828,11 @@
'../third_party/libusb/libusb.gyp:libusb'
],
}],
['use_aura==1', {
'dependencies': [
'../ui/keyboard/keyboard.gyp:keyboard_resources',
],
}],
['OS=="linux" and use_aura==1', {
'dependencies': [
'../build/linux/system.gyp:dbus',
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome_browser_ui.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2498,6 +2498,8 @@
# aura uses some of ash resources.
'../ash/ash.gyp:ash_resources',
'../ui/aura/aura.gyp:aura',
'../ui/keyboard/keyboard.gyp:keyboard',
'../ui/keyboard/keyboard.gyp:keyboard_resources',
],
'conditions': [
['OS=="win"', {
Expand Down
6 changes: 6 additions & 0 deletions chrome/chrome_repack_resources.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
['OS != "ios" and OS != "android"', {
# New paks should be added here by default.
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/keyboard/keyboard_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak',
'<(grit_out_dir)/component_extension_resources.pak',
'<(grit_out_dir)/options_resources.pak',
Expand All @@ -26,6 +27,11 @@
'<(grit_out_dir)/devtools_discovery_page_resources.pak',
],
}],
['use_aura==1', {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/keyboard/keyboard_resources.pak',
],
}],
],
},
'inputs': [
Expand Down
7 changes: 7 additions & 0 deletions chrome/common/extensions/manifest_url_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

#if defined(USE_AURA)
#include "ui/keyboard/keyboard_constants.h"
#endif

namespace keys = extension_manifest_keys;
namespace errors = extension_manifest_errors;

Expand Down Expand Up @@ -276,6 +280,9 @@ bool URLOverridesHandler::Parse(Extension* extension, string16* error) {
!(extension->location() == Manifest::COMPONENT &&
page == chrome::kChromeUIFileManagerHost));
#endif
#if defined(USE_AURA)
is_override = (is_override && page != keyboard::kKeyboardWebUIHost);
#endif

if (is_override || !iter.value().GetAsString(&val)) {
*error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides);
Expand Down
2 changes: 0 additions & 2 deletions chrome/common/url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const char kChromeUIHistoryFrameURL[] = "chrome://history-frame/";
const char kChromeUIInspectURL[] = "chrome://inspect/";
const char kChromeUIInstantURL[] = "chrome://instant/";
const char kChromeUIIPCURL[] = "chrome://ipc/";
const char kChromeUIKeyboardURL[] = "chrome://keyboard/";
const char kChromeUIManagedUserPassphrasePageURL[] =
"chrome://managed-user-passphrase/";
const char kChromeUIMemoryRedirectURL[] = "chrome://memory-redirect/";
Expand Down Expand Up @@ -167,7 +166,6 @@ const char kChromeUIHistoryFrameHost[] = "history-frame";
const char kChromeUIInspectHost[] = "inspect";
const char kChromeUIInstantHost[] = "instant";
const char kChromeUIIPCHost[] = "ipc";
const char kChromeUIKeyboardHost[] = "keyboard";
const char kChromeUIKillHost[] = "kill";
const char kChromeUIManagedUserPassphrasePageHost[] = "managed-user-passphrase";
const char kChromeUIMemoryHost[] = "memory";
Expand Down
2 changes: 0 additions & 2 deletions chrome/common/url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ extern const char kChromeUIHistoryFrameURL[];
extern const char kChromeUIInspectURL[];
extern const char kChromeUIInstantURL[];
extern const char kChromeUIIPCURL[];
extern const char kChromeUIKeyboardURL[];
extern const char kChromeUIManagedUserPassphrasePageURL[];
extern const char kChromeUIMemoryRedirectURL[];
extern const char kChromeUIMemoryURL[];
Expand Down Expand Up @@ -160,7 +159,6 @@ extern const char kChromeUIHistoryFrameHost[];
extern const char kChromeUIInspectHost[];
extern const char kChromeUIInstantHost[];
extern const char kChromeUIIPCHost[];
extern const char kChromeUIKeyboardHost[];
extern const char kChromeUIKillHost[];
extern const char kChromeUIManagedUserPassphrasePageHost[];
extern const char kChromeUIMemoryHost[];
Expand Down
5 changes: 3 additions & 2 deletions tools/gritsettings/resource_ids
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@
"chrome/browser/resources/memory_internals_resources.grd": {
"includes": [27500],
},

"device/device_bluetooth_strings.grd": {
"messages": [28000],
},

"ui/keyboard/keyboard_resources.grd": {
"includes": [28050],
},
# Resource ids starting at 31000 are reserved for projects built on Chromium.
}
4 changes: 4 additions & 0 deletions ui/keyboard/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+content/public",
"+grit/keyboard_resources.h",
]
37 changes: 36 additions & 1 deletion ui/keyboard/keyboard.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,60 @@
'chromium_code': 1,
},
'targets': [
{
'target_name': 'keyboard_resources',
'type': 'none',
'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/ui/keyboard',
},
'actions': [
{
'action_name': 'keyboard_resources',
'variables': {
'grit_grd_file': 'keyboard_resources.grd',
},
'includes': [ '../../build/grit_action.gypi' ],
},
],
'includes': [ '../../build/grit_target.gypi' ],
},
{
'target_name': 'keyboard',
'type': '<(component)',
'dependencies': [
'../../base/base.gyp:base',
'../../content/content.gyp:content_browser',
'../../skia/skia.gyp:skia',
'../aura/aura.gyp:aura',
'../compositor/compositor.gyp:compositor',
'../ui.gyp:ui',
'keyboard_resources',
],
'defines': [
'KEYBOARD_IMPLEMENTATION',
],
'sources': [
'keyboard_constants.cc',
'keyboard_constants.h',
'keyboard_controller.cc',
'keyboard_controller.h',
'keyboard_controller_proxy.h',
'keyboard_export.h',
'keyboard_switches.cc',
'keyboard_switches.h',
'keyboard_ui_controller.cc',
'keyboard_ui_controller.h',
'keyboard_util.cc',
'keyboard_util.h',
]
},
{
'target_name': 'keyboard_unittests',
'type': 'executable',
'type': '<(gtest_target_type)',
'dependencies': [
'../../base/base.gyp:base',
'../../base/base.gyp:test_support_base',
'../../content/content.gyp:content_browser',
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
'../aura/aura.gyp:aura',
Expand All @@ -51,6 +75,17 @@
'keyboard_controller_unittest.cc',
'keyboard_test_suite.cc',
],
'conditions': [
[ 'os_posix == 1 and OS != "mac" and OS != "android" and OS != "ios"', {
'conditions': [
['linux_use_tcmalloc==1', {
'dependencies': [
'../../base/allocator/allocator.gyp:allocator',
],
}],
],
}],
],
},
],
}
12 changes: 12 additions & 0 deletions ui/keyboard/keyboard_constants.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/keyboard/keyboard_constants.h"

namespace keyboard {

const char kKeyboardWebUIURL[] = "chrome://keyboard";
const char kKeyboardWebUIHost[] = "keyboard";

} // namespace keyboard
20 changes: 20 additions & 0 deletions ui/keyboard/keyboard_constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_KEYBOARD_KEYBOARD_CONSTANTS_H_
#define UI_KEYBOARD_KEYBOARD_CONSTANTS_H_

#include "ui/keyboard/keyboard_export.h"

namespace keyboard {

// The URL of the keyboard WebUI.
KEYBOARD_EXPORT extern const char kKeyboardWebUIURL[];

// The host of the keyboard WebUI URL.
KEYBOARD_EXPORT extern const char kKeyboardWebUIHost[];

} // namespace keyboard

#endif // UI_KEYBOARD_KEYBOARD_CONSTANTS_H_
33 changes: 33 additions & 0 deletions ui/keyboard/keyboard_resources.grd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
NOTE: if you are adding resources here, you should probably also edit:
chrome/browser/ui/webui/virtual_keyboard_ui.cc // FIXME: this will move
chrome/browser/extensions/image_loader.cc
-->
<grit latest_public_release="0" current_release="1">
<outputs>
<output filename="grit/keyboard_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="keyboard_resources.pak" type="data_package" />
<output filename="keyboard_resources.rc" type="rc_all" />
</outputs>
<release seq="1">
<includes>
<include name="IDR_KEYBOARD_MANIFEST" file="resources/manifest.json" type="BINDATA" />
<include name="IDR_KEYBOARD_INDEX" file="resources/index.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_KEYBOARD_MAIN_CSS" file="resources/main.css" type="BINDATA" />
<include name="IDR_KEYBOARD_MAIN_JS" file="resources/main.js" type="BINDATA" />
<include name="IDR_KEYBOARD_COMMON_JS" file="resources/common.js" type="BINDATA" />
<include name="IDR_KEYBOARD_LAYOUT_US_JS" file="resources/layout_us.js" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_CHEVRON" file="resources/images/chevron.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_DEL" file="resources/images/del.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_KEYBOARD" file="resources/images/keyboard.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_MIC" file="resources/images/mic.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_RET" file="resources/images/ret.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_SHIFT_DOWN" file="resources/images/shift-down.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_SHIFT" file="resources/images/shift.svg" type="BINDATA" />
<include name="IDR_KEYBOARD_IMAGES_TAB" file="resources/images/tab.svg" type="BINDATA" />
</includes>
</release>
</grit>
Loading

0 comments on commit d7aaed2

Please sign in to comment.