Index: chrome/renderer/extensions/automation_internal_custom_bindings.cc |
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
index 37406710aeac9b360070aa115883a852fa224bf6..59fcc74b23de4d55605e02b22e2bcf8a7c2df2f4 100644 |
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
@@ -8,9 +8,11 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/values.h" |
#include "chrome/common/extensions/manifest_handlers/automation.h" |
+#include "content/public/renderer/v8_value_converter.h" |
#include "extensions/common/extension.h" |
#include "extensions/common/manifest.h" |
#include "extensions/renderer/script_context.h" |
+#include "ui/accessibility/ax_enums.h" |
namespace extensions { |
@@ -20,6 +22,10 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( |
"IsInteractPermitted", |
base::Bind(&AutomationInternalCustomBindings::IsInteractPermitted, |
base::Unretained(this))); |
+ RouteFunction( |
+ "GetSchemaAdditions", |
+ base::Bind(&AutomationInternalCustomBindings::GetSchemaAdditions, |
+ base::Unretained(this))); |
} |
AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { |
@@ -35,4 +41,48 @@ void AutomationInternalCustomBindings::IsInteractPermitted( |
v8::Boolean::New(GetIsolate(), automation_info->interact)); |
} |
+void AutomationInternalCustomBindings::GetSchemaAdditions( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ using v8::Local; |
+ using v8::Object; |
+ using v8::String; |
+ |
+ Local<Object> ret = Object::New(GetIsolate()); |
not at google - send to devlin
2014/05/29 18:26:21
s/ret/additions/ ?
David Tseng
2014/05/29 19:04:40
Done.
|
+ |
+ Local<Object> event_enum = Object::New(GetIsolate()); |
+ for (int i = ui::AX_EVENT_NONE; |
+ i <= ui::AX_EVENT_LAST; |
+ ++i) { |
not at google - send to devlin
2014/05/29 18:26:21
should fit on 1 line? (might as well just "git cl
David Tseng
2014/05/29 19:04:40
Done.
|
+ Local<String> value = |
aboxhall
2014/05/29 18:35:49
The formatting here is also a little weird, I thin
David Tseng
2014/05/29 19:04:40
Done; (git cl formatted)
|
+ String::NewFromUtf8(GetIsolate(), |
+ ui::ToString(static_cast<ui::AXEvent>(i)).c_str()); |
+ event_enum->Set(value, value); |
+ } |
+ ret->Set(String::NewFromUtf8(GetIsolate(), "Event"), event_enum); |
+ |
+ Local<Object> role_enum = Object::New(GetIsolate()); |
+ for (int j = ui::AX_ROLE_NONE; |
+ j <= ui::AX_ROLE_LAST; |
+ ++j) { |
+ Local<String> value = |
+ String::NewFromUtf8(GetIsolate(), |
+ ui::ToString(static_cast<ui::AXRole>(j)).c_str()); |
+ role_enum->Set(value, value); |
+ } |
+ ret->Set(String::NewFromUtf8(GetIsolate(), "Role"), role_enum); |
+ |
+ Local<Object> state_enum = Object::New(GetIsolate()); |
+ for (int k = ui::AX_STATE_NONE; |
+ k <= ui::AX_STATE_LAST; |
+ ++k) { |
+ Local<String> value = |
+ String::NewFromUtf8(GetIsolate(), |
+ ui::ToString(static_cast<ui::AXState>(k)).c_str()); |
+ state_enum->Set(value, value); |
+ } |
not at google - send to devlin
2014/05/29 18:26:21
you should be able to simplify this a lot with tem
David Tseng
2014/05/29 19:04:40
No worries :); I like templates too (less code is
|
+ ret->Set(String::NewFromUtf8(GetIsolate(), "State"), state_enum); |
+ |
+ args.GetReturnValue().Set(ret); |
+} |
+ |
} // namespace extensions |