Chromium Code Reviews| 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..aa160da89c9441460c8cf82e28a2dded8e7aba89 100644 |
| --- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| +++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
| @@ -8,9 +8,33 @@ |
| #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" |
| + |
| +using v8::Local; |
| +using v8::Object; |
| +using v8::String; |
|
not at google - send to devlin
2014/05/29 19:48:14
I would loosely prefer not doing "using" here, sin
David Tseng
2014/05/29 22:12:26
Reverted back to v8 prefixes.
|
| + |
| +namespace { |
| + |
| +// Helper to convert an enum to a V8 object. |
| +template <typename EnumType> |
| +Local<Object> ToEnumObject(v8::Isolate* isolate, |
| + EnumType start_after, |
| + EnumType end_at) { |
| + Local<Object> object = Object::New(isolate); |
| + for (int i = start_after + 1; i <= end_at; ++i) { |
| + Local<String> value = String::NewFromUtf8( |
| + isolate, ui::ToString(static_cast<EnumType>(i)).c_str()); |
| + object->Set(value, value); |
| + } |
| + return object; |
| +} |
| + |
| +} // namespace |
| namespace extensions { |
| @@ -20,6 +44,10 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( |
| "IsInteractPermitted", |
| base::Bind(&AutomationInternalCustomBindings::IsInteractPermitted, |
| base::Unretained(this))); |
| + RouteFunction( |
| + "GetSchemaAdditions", |
| + base::Bind(&AutomationInternalCustomBindings::GetSchemaAdditions, |
| + base::Unretained(this))); |
| } |
| AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { |
| @@ -35,4 +63,23 @@ void AutomationInternalCustomBindings::IsInteractPermitted( |
| v8::Boolean::New(GetIsolate(), automation_info->interact)); |
| } |
| +void AutomationInternalCustomBindings::GetSchemaAdditions( |
| + const v8::FunctionCallbackInfo<v8::Value>& args) { |
| + Local<Object> additions = Object::New(GetIsolate()); |
| + |
| + additions->Set(String::NewFromUtf8(GetIsolate(), "EventType"), |
| + ToEnumObject<ui::AXEvent>( |
|
not at google - send to devlin
2014/05/29 19:48:14
hm, can C++ not guess that this is ui::AXEvent (et
David Tseng
2014/05/29 22:12:26
Looks like clang can infer the type from the argum
|
| + GetIsolate(), ui::AX_EVENT_NONE, ui::AX_EVENT_LAST)); |
| + |
| + additions->Set(String::NewFromUtf8(GetIsolate(), "RoleType"), |
| + ToEnumObject<ui::AXRole>( |
| + GetIsolate(), ui::AX_ROLE_NONE, ui::AX_ROLE_LAST)); |
| + |
| + additions->Set(String::NewFromUtf8(GetIsolate(), "StateType"), |
| + ToEnumObject<ui::AXState>( |
| + GetIsolate(), ui::AX_STATE_NONE, ui::AX_STATE_LAST)); |
| + |
| + args.GetReturnValue().Set(additions); |
| +} |
| + |
| } // namespace extensions |