| 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 "content/shell/test_runner/accessibility_controller.h" | 5 #include "content/shell/test_runner/accessibility_controller.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "content/shell/test_runner/web_view_test_proxy.h" | 8 #include "content/shell/test_runner/web_view_test_proxy.h" |
| 9 #include "gin/handle.h" | 9 #include "gin/handle.h" |
| 10 #include "gin/object_template_builder.h" | 10 #include "gin/object_template_builder.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 void AccessibilityController::NotificationReceived( | 159 void AccessibilityController::NotificationReceived( |
| 160 const blink::WebAXObject& target, | 160 const blink::WebAXObject& target, |
| 161 const std::string& notification_name) { | 161 const std::string& notification_name) { |
| 162 v8::Isolate* isolate = blink::MainThreadIsolate(); | 162 v8::Isolate* isolate = blink::MainThreadIsolate(); |
| 163 v8::HandleScope handle_scope(isolate); | 163 v8::HandleScope handle_scope(isolate); |
| 164 | 164 |
| 165 blink::WebFrame* frame = web_view()->MainFrame(); | 165 blink::WebFrame* frame = web_view()->MainFrame(); |
| 166 if (!frame || frame->IsWebRemoteFrame()) | 166 if (!frame || frame->IsWebRemoteFrame()) |
| 167 return; | 167 return; |
| 168 blink::WebLocalFrame* local_frame = frame->ToWebLocalFrame(); |
| 168 | 169 |
| 169 v8::Local<v8::Context> context = frame->MainWorldScriptContext(); | 170 v8::Local<v8::Context> context = local_frame->MainWorldScriptContext(); |
| 170 if (context.IsEmpty()) | 171 if (context.IsEmpty()) |
| 171 return; | 172 return; |
| 172 | 173 |
| 173 v8::Context::Scope context_scope(context); | 174 v8::Context::Scope context_scope(context); |
| 174 | 175 |
| 175 // Call notification listeners on the element. | 176 // Call notification listeners on the element. |
| 176 v8::Local<v8::Object> element_handle = elements_.GetOrCreate(target); | 177 v8::Local<v8::Object> element_handle = elements_.GetOrCreate(target); |
| 177 if (element_handle.IsEmpty()) | 178 if (element_handle.IsEmpty()) |
| 178 return; | 179 return; |
| 179 | 180 |
| 180 WebAXObjectProxy* element; | 181 WebAXObjectProxy* element; |
| 181 bool result = gin::ConvertFromV8(isolate, element_handle, &element); | 182 bool result = gin::ConvertFromV8(isolate, element_handle, &element); |
| 182 DCHECK(result); | 183 DCHECK(result); |
| 183 element->NotificationReceived(frame, notification_name); | 184 element->NotificationReceived(local_frame, notification_name); |
| 184 | 185 |
| 185 if (notification_callback_.IsEmpty()) | 186 if (notification_callback_.IsEmpty()) |
| 186 return; | 187 return; |
| 187 | 188 |
| 188 // Call global notification listeners. | 189 // Call global notification listeners. |
| 189 v8::Local<v8::Value> argv[] = { | 190 v8::Local<v8::Value> argv[] = { |
| 190 element_handle, v8::String::NewFromUtf8(isolate, notification_name.data(), | 191 element_handle, v8::String::NewFromUtf8(isolate, notification_name.data(), |
| 191 v8::String::kNormalString, | 192 v8::String::kNormalString, |
| 192 notification_name.size()), | 193 notification_name.size()), |
| 193 }; | 194 }; |
| 194 frame->CallFunctionEvenIfScriptDisabled( | 195 local_frame->CallFunctionEvenIfScriptDisabled( |
| 195 v8::Local<v8::Function>::New(isolate, notification_callback_), | 196 v8::Local<v8::Function>::New(isolate, notification_callback_), |
| 196 context->Global(), arraysize(argv), argv); | 197 context->Global(), arraysize(argv), argv); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void AccessibilityController::LogAccessibilityEvents() { | 200 void AccessibilityController::LogAccessibilityEvents() { |
| 200 log_accessibility_events_ = true; | 201 log_accessibility_events_ = true; |
| 201 } | 202 } |
| 202 | 203 |
| 203 void AccessibilityController::SetNotificationListener( | 204 void AccessibilityController::SetNotificationListener( |
| 204 v8::Local<v8::Function> callback) { | 205 v8::Local<v8::Function> callback) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 265 } |
| 265 | 266 |
| 266 return v8::Local<v8::Object>(); | 267 return v8::Local<v8::Object>(); |
| 267 } | 268 } |
| 268 | 269 |
| 269 blink::WebView* AccessibilityController::web_view() { | 270 blink::WebView* AccessibilityController::web_view() { |
| 270 return web_view_test_proxy_base_->web_view(); | 271 return web_view_test_proxy_base_->web_view(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 } // namespace test_runner | 274 } // namespace test_runner |
| OLD | NEW |