Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" | 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/chrome_extension_messages.h" | |
| 10 #include "chrome/common/extensions/manifest_handlers/automation.h" | 11 #include "chrome/common/extensions/manifest_handlers/automation.h" |
| 11 #include "content/public/child/v8_value_converter.h" | 12 #include "content/public/child/v8_value_converter.h" |
| 13 #include "content/public/renderer/render_frame.h" | |
| 14 #include "content/public/renderer/render_view.h" | |
| 12 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 13 #include "extensions/common/manifest.h" | 16 #include "extensions/common/manifest.h" |
| 14 #include "extensions/renderer/script_context.h" | 17 #include "extensions/renderer/script_context.h" |
| 15 #include "ui/accessibility/ax_enums.h" | 18 #include "ui/accessibility/ax_enums.h" |
| 19 #include "ui/accessibility/ax_node.h" | |
| 16 | 20 |
| 17 namespace { | 21 namespace { |
| 18 | 22 |
| 19 // Helper to convert an enum to a V8 object. | 23 // Helper to convert an enum to a V8 object. |
| 20 template <typename EnumType> | 24 template <typename EnumType> |
| 21 v8::Local<v8::Object> ToEnumObject(v8::Isolate* isolate, | 25 v8::Local<v8::Object> ToEnumObject(v8::Isolate* isolate, |
| 22 EnumType start_after, | 26 EnumType start_after, |
| 23 EnumType end_at) { | 27 EnumType end_at) { |
| 24 v8::Local<v8::Object> object = v8::Object::New(isolate); | 28 v8::Local<v8::Object> object = v8::Object::New(isolate); |
| 25 for (int i = start_after + 1; i <= end_at; ++i) { | 29 for (int i = start_after + 1; i <= end_at; ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 42 base::Unretained(this))); | 46 base::Unretained(this))); |
| 43 RouteFunction( | 47 RouteFunction( |
| 44 "GetSchemaAdditions", | 48 "GetSchemaAdditions", |
| 45 base::Bind(&AutomationInternalCustomBindings::GetSchemaAdditions, | 49 base::Bind(&AutomationInternalCustomBindings::GetSchemaAdditions, |
| 46 base::Unretained(this))); | 50 base::Unretained(this))); |
| 47 } | 51 } |
| 48 | 52 |
| 49 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { | 53 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { |
| 50 } | 54 } |
| 51 | 55 |
| 56 bool AutomationInternalCustomBindings::OnMessageReceived( | |
| 57 const IPC::Message& message) { | |
| 58 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) | |
| 59 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, | |
| 60 OnAccessibilityEvent) | |
| 61 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") | |
|
not at google - send to devlin
2015/06/02 23:59:25
How does this work out?
(btw, personally I prefer
dmazzoni
2015/06/04 20:07:39
Moot now that this is a MessageFilter.
| |
| 62 IPC_END_MESSAGE_MAP() | |
| 63 return true; | |
| 64 } | |
| 65 | |
| 52 void AutomationInternalCustomBindings::IsInteractPermitted( | 66 void AutomationInternalCustomBindings::IsInteractPermitted( |
| 53 const v8::FunctionCallbackInfo<v8::Value>& args) { | 67 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 54 const Extension* extension = context()->extension(); | 68 const Extension* extension = context()->extension(); |
| 55 CHECK(extension); | 69 CHECK(extension); |
| 56 const AutomationInfo* automation_info = AutomationInfo::Get(extension); | 70 const AutomationInfo* automation_info = AutomationInfo::Get(extension); |
| 57 CHECK(automation_info); | 71 CHECK(automation_info); |
| 58 args.GetReturnValue().Set( | 72 args.GetReturnValue().Set( |
| 59 v8::Boolean::New(GetIsolate(), automation_info->interact)); | 73 v8::Boolean::New(GetIsolate(), automation_info->interact)); |
| 60 } | 74 } |
| 61 | 75 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 75 v8::String::NewFromUtf8(GetIsolate(), "StateType"), | 89 v8::String::NewFromUtf8(GetIsolate(), "StateType"), |
| 76 ToEnumObject(GetIsolate(), ui::AX_STATE_NONE, ui::AX_STATE_LAST)); | 90 ToEnumObject(GetIsolate(), ui::AX_STATE_NONE, ui::AX_STATE_LAST)); |
| 77 | 91 |
| 78 additions->Set( | 92 additions->Set( |
| 79 v8::String::NewFromUtf8(GetIsolate(), "TreeChangeType"), | 93 v8::String::NewFromUtf8(GetIsolate(), "TreeChangeType"), |
| 80 ToEnumObject(GetIsolate(), ui::AX_MUTATION_NONE, ui::AX_MUTATION_LAST)); | 94 ToEnumObject(GetIsolate(), ui::AX_MUTATION_NONE, ui::AX_MUTATION_LAST)); |
| 81 | 95 |
| 82 args.GetReturnValue().Set(additions); | 96 args.GetReturnValue().Set(additions); |
| 83 } | 97 } |
| 84 | 98 |
| 99 void AutomationInternalCustomBindings::OnAccessibilityEvent( | |
| 100 const ExtensionMsg_AccessibilityEventParams& params) { | |
| 101 // TODO(dmazzoni): finish implementing this. | |
| 102 } | |
| 103 | |
| 85 } // namespace extensions | 104 } // namespace extensions |
| OLD | NEW |