summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmazzoni <dmazzoni@chromium.org>2014-09-12 18:17:13 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-13 01:19:16 +0000
commitfecaedc03904c091897dea2926ec00756f6e53ed (patch)
tree95635888b730e05ac86c87e21b4bd300cac8a850
parent576a049e2372611da05e03b8ba61f4b60338cd44 (diff)
downloadchromium_src-fecaedc03904c091897dea2926ec00756f6e53ed.zip
chromium_src-fecaedc03904c091897dea2926ec00756f6e53ed.tar.gz
chromium_src-fecaedc03904c091897dea2926ec00756f6e53ed.tar.bz2
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}
-rw-r--r--chrome/browser/accessibility/accessibility_extension_api.cc30
-rw-r--r--chrome/browser/accessibility/accessibility_extension_api.h9
-rw-r--r--chrome/browser/accessibility/accessibility_extension_api_constants.cc3
-rw-r--r--chrome/browser/accessibility/accessibility_extension_api_constants.h3
-rw-r--r--chrome/common/extensions/api/accessibility_private.json24
-rw-r--r--extensions/browser/extension_function_histogram_value.h1
-rw-r--r--tools/metrics/histograms/histograms.xml1
7 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc
index cac4f2c..63957ae 100644
--- a/chrome/browser/accessibility/accessibility_extension_api.cc
+++ b/chrome/browser/accessibility/accessibility_extension_api.cc
@@ -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;
+}
diff --git a/chrome/browser/accessibility/accessibility_extension_api.h b/chrome/browser/accessibility/accessibility_extension_api.h
index 0c10d26..e16426e 100644
--- a/chrome/browser/accessibility/accessibility_extension_api.h
+++ b/chrome/browser/accessibility/accessibility_extension_api.h
@@ -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_
diff --git a/chrome/browser/accessibility/accessibility_extension_api_constants.cc b/chrome/browser/accessibility/accessibility_extension_api_constants.cc
index d4f8051..faa1f72 100644
--- a/chrome/browser/accessibility/accessibility_extension_api_constants.cc
+++ b/chrome/browser/accessibility/accessibility_extension_api_constants.cc
@@ -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
diff --git a/chrome/browser/accessibility/accessibility_extension_api_constants.h b/chrome/browser/accessibility/accessibility_extension_api_constants.h
index 5ed0a94..99b128a 100644
--- a/chrome/browser/accessibility/accessibility_extension_api_constants.h
+++ b/chrome/browser/accessibility/accessibility_extension_api_constants.h
@@ -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_
diff --git a/chrome/common/extensions/api/accessibility_private.json b/chrome/common/extensions/api/accessibility_private.json
index bdc3520..786bc45 100644
--- a/chrome/common/extensions/api/accessibility_private.json
+++ b/chrome/common/extensions/api/accessibility_private.json
@@ -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": [
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h
index aa27e1a..61db879 100644
--- a/extensions/browser/extension_function_histogram_value.h
+++ b/extensions/browser/extension_function_histogram_value.h
@@ -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
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index a793432..759fb73 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -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">