Commit db9105d3 authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

[Chromecast] Port stub brailleDisplayPrivate API

This will be implemented if necessary

Bug: b/73383411
Test: local build
Change-Id: I895c9e58e301a94d9814cb4f95247dd8e0131469
Reviewed-on: https://chromium-review.googlesource.com/1026465Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553608}
parent 57e2ceec
......@@ -226,6 +226,8 @@ cast_source_set("browser") {
"extension_request_protocol_handler.h",
"extensions/api/bookmarks/bookmarks_api.cc",
"extensions/api/bookmarks/bookmarks_api.h",
"extensions/api/braille_display_private/braille_display_private_api.cc",
"extensions/api/braille_display_private/braille_display_private_api.h",
"extensions/api/history/history_api.cc",
"extensions/api/history/history_api.h",
"extensions/api/identity/identity_api.cc",
......
// Copyright 2018 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 "chromecast/browser/extensions/api/braille_display_private/braille_display_private_api.h"
namespace extensions {
namespace cast {
namespace api {
bool BrailleDisplayPrivateGetDisplayStateFunction::Prepare() {
return true;
}
void BrailleDisplayPrivateGetDisplayStateFunction::Work() {
braille_display_private::DisplayState state;
state.available = false;
state.text_column_count.reset(new int(0));
state.text_row_count.reset(new int(0));
SetResult(state.ToValue());
}
bool BrailleDisplayPrivateGetDisplayStateFunction::Respond() {
return true;
}
BrailleDisplayPrivateWriteDotsFunction::
BrailleDisplayPrivateWriteDotsFunction() {}
BrailleDisplayPrivateWriteDotsFunction::
~BrailleDisplayPrivateWriteDotsFunction() {}
bool BrailleDisplayPrivateWriteDotsFunction::Prepare() {
params_ = braille_display_private::WriteDots::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_);
EXTENSION_FUNCTION_VALIDATE(
params_->cells.size() >=
static_cast<size_t>(params_->columns * params_->rows));
return true;
}
void BrailleDisplayPrivateWriteDotsFunction::Work() {
NOTIMPLEMENTED() << "BrailleDisplayPrivateWriteDotsFunction";
}
bool BrailleDisplayPrivateWriteDotsFunction::Respond() {
return true;
}
} // namespace api
} // namespace cast
} // namespace extensions
// Copyright 2018 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 CHROMECAST_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PRIVATE_API_H_
#define CHROMECAST_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PRIVATE_API_H_
#include "chromecast/common/extensions_api/braille_display_private.h"
#include "extensions/browser/api/async_api_function.h"
namespace extensions {
namespace cast {
namespace api {
class BrailleDisplayPrivateGetDisplayStateFunction : public AsyncApiFunction {
DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.getDisplayState",
BRAILLEDISPLAYPRIVATE_GETDISPLAYSTATE)
protected:
~BrailleDisplayPrivateGetDisplayStateFunction() override {}
bool Prepare() override;
void Work() override;
bool Respond() override;
};
class BrailleDisplayPrivateWriteDotsFunction : public AsyncApiFunction {
DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.writeDots",
BRAILLEDISPLAYPRIVATE_WRITEDOTS);
public:
BrailleDisplayPrivateWriteDotsFunction();
protected:
~BrailleDisplayPrivateWriteDotsFunction() override;
bool Prepare() override;
void Work() override;
bool Respond() override;
private:
std::unique_ptr<braille_display_private::WriteDots::Params> params_;
};
} // namespace api
} // namespace cast
} // namespace extensions
#endif // CHROMECAST_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PRIVATE_API_H_
......@@ -11,6 +11,7 @@ assert(enable_extensions,
schema_sources = [
"bookmarks.json",
"braille_display_private.idl",
"history.json",
"identity.idl",
]
......
......@@ -7,6 +7,10 @@
// feature.h, simple_feature.h, and feature_provider.h.
{
"brailleDisplayPrivate": {
"dependencies": ["permission:brailleDisplayPrivate"],
"contexts": ["blessed_extension"]
},
// Stub implementation of chrome.identity for app_shell.
"identity": {
"channel": "dev",
......
......@@ -7,6 +7,11 @@
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
},
"brailleDisplayPrivate": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app", "platform_app"],
"location": "component"
},
"history": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
......
// Copyright 2018 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.
// Braille display access private API.
namespace brailleDisplayPrivate {
// Braille display keyboard command.
enum KeyCommand {
line_up,
line_down,
pan_left,
pan_right,
top,
bottom,
routing,
secondary_routing,
dots,
chord,
standard_key
};
// A keyboard event. This is not a standard keyboard event because
// braille display keyboards look significantly different from standard
// keyboards.
dictionary KeyEvent {
KeyCommand command;
// 0-based display position for commands that involve a routing key.
long? displayPosition;
// Braille dot keys that were pressed, stored in the low-order bits.
// Dot 1 is stored in bit 0, dot2 in bit 1, etc.
long? brailleDots;
// DOM keyboard event code. This is present when command is standard_key
// and the braille display event represents a non-alphanumeric key such
// as an arrow key or function key.
// The value is as defined by the |code| property in
// http://www.w3.org/TR/uievents/#keyboard-event-interface
DOMString? standardKeyCode;
// DOM keyboard event character value. This is present if the
// braille key event corresponds to a character.
DOMString? standardKeyChar;
// Whether the space key was pressed.
boolean? spaceKey;
// Whether the alt key was pressed.
boolean? altKey;
// Whether the shift key was pressed.
boolean? shiftKey;
// Whether the ctrl key was pressed.
boolean? ctrlKey;
};
// The current braille display state.
dictionary DisplayState {
// Whether a braille display is currently available.
boolean available;
// Number of rows of braille cells on the currently connected display.
long? textRowCount;
// Number of columns of braille cells on the currently connected display.
long? textColumnCount;
};
callback DisplayStateCallback = void(DisplayState result);
interface Functions {
// Gets the current display state.
static void getDisplayState(DisplayStateCallback callback);
// Write the given dot patterns to the display. The buffer contains one
// byte for each braille cell on the display, starting from the leftmost
// cell. Each byte contains a bit pattern indicating which dots should be
// raised in the corresponding cell with the low-order bit representing
// dot 1 and so on until bit 7 which corresponds to dot 8. If the number
// of bytes in the buffer is not equal to the display size, the buffer
// will either be clipped or padded with blank cells on the right. The
// buffer is a 2D array compressed into 1D. The |columns| and |rows|
// parameters give the original 2D dimensions of the buffer. To access
// an element cells[r][c], simply access cells[r * columns + c].
static void writeDots(ArrayBuffer cells, long columns, long rows);
};
interface Events {
// Fired when a braille display is connected or disconnected.
static void onDisplayStateChanged(DisplayState state);
// Fired when an input event is received from the display.
static void onKeyEvent(KeyEvent event);
};
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment