Commit fecaedc0 authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Add private extension API to move the accessibility focus ring.

BUG=314889

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

Cr-Commit-Position: refs/heads/master@{#294719}
parent 576a049e
......@@ -25,6 +25,10 @@
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_handlers/background_info.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h"
#endif
namespace keys = extension_accessibility_api_constants;
namespace accessibility_private = extensions::api::accessibility_private;
......@@ -308,3 +312,29 @@ bool AccessibilityPrivateGetAlertsForTabFunction::RunSync() {
SetResult(alerts_value);
return true;
}
bool AccessibilityPrivateSetFocusRingFunction::RunSync() {
#if defined(OS_CHROMEOS)
base::ListValue* rect_values = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &rect_values));
std::vector<gfx::Rect> rects;
for (size_t i = 0; i < rect_values->GetSize(); ++i) {
base::DictionaryValue* rect_value = NULL;
EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value));
int left, top, width, height;
EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("left", &left));
EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("top", &top));
EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("width", &width));
EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("height", &height));
rects.push_back(gfx::Rect(left, top, width, height));
}
chromeos::AccessibilityFocusRingController::GetInstance()->SetFocusRing(
rects);
return true;
#endif // defined(OS_CHROMEOS)
error_ = keys:: kErrorNotSupported;
return false;
}
......@@ -135,4 +135,13 @@ class AccessibilityPrivateGetAlertsForTabFunction
ACCESSIBILITY_PRIVATE_GETALERTSFORTAB)
};
// API function that sets the location of the accessibility focus ring.
class AccessibilityPrivateSetFocusRingFunction
: public ChromeSyncExtensionFunction {
virtual ~AccessibilityPrivateSetFocusRingFunction() {}
virtual bool RunSync() OVERRIDE;
DECLARE_EXTENSION_FUNCTION("accessibilityPrivate.setFocusRing",
ACCESSIBILITY_PRIVATE_SETFOCUSRING)
};
#endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EXTENSION_API_H_
......@@ -42,4 +42,7 @@ const char kTypeTree[] = "tree";
const char kTypeTreeItem[] = "treeitem";
const char kTypeWindow[] = "window";
// Errors.
const char kErrorNotSupported[] = "This API is not supported on this platform.";
} // namespace extension_accessibility_api_constants
......@@ -46,6 +46,9 @@ extern const char kTypeTreeItem[];
extern const char kTypeVolume[];
extern const char kTypeWindow[];
// Errors.
extern const char kErrorNotSupported[];
}; // namespace extension_accessibility_api_constants
#endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_EXTENSION_API_CONSTANTS_H_
......@@ -159,6 +159,17 @@
]
}
}
},
{
"id": "ScreenRect",
"type": "object",
"description": "Bounding rectangle in global screen coordinates.",
"properties": {
"left": {"type": "integer", "description": "Left coordinate in global screen coordinates."},
"top": {"type": "integer", "description": "Top coordinate in global screen coordinates."},
"width": {"type": "integer", "description": "Width in pixels."},
"height": {"type": "integer", "description": "Height in pixels."}
}
}
],
"functions": [
......@@ -228,6 +239,19 @@
]
}
]
},
{
"name": "setFocusRing",
"type": "function",
"description": "Set the bounds of the accessibility focus ring.",
"parameters": [
{
"name": "rects",
"type": "array",
"items": { "$ref": "ScreenRect" },
"description": "Array of rectangles to draw the accessibility focus ring around."
}
]
}
],
"events": [
......
......@@ -951,6 +951,7 @@ enum HistogramValue {
APP_CURRENTWINDOWINTERNAL_SETVISIBLEONALLWORKSPACES,
EASYUNLOCKPRIVATE_GETSIGNINCHALLENGE,
EASYUNLOCKPRIVATE_TRYSIGNINSECRET,
ACCESSIBILITY_PRIVATE_SETFOCUSRING,
// Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms.xml.
ENUM_BOUNDARY
......
......@@ -41548,6 +41548,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="890" label="APP_CURRENTWINDOWINTERNAL_SETVISIBLEONALLWORKSPACES"/>
<int value="891" label="EASYUNLOCKPRIVATE_GETSIGNINCHALLENGE"/>
<int value="892" label="EASYUNLOCKPRIVATE_TRYSIGNINSECRET"/>
<int value="893" label="ACCESSIBILITY_PRIVATE_SETFOCUSRING"/>
</enum>
<enum name="ExtensionInstallCause" type="int">
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