| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/dom_automation_controller.h" | 5 #include "content/renderer/dom_automation_controller.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/child/v8_value_converter_impl.h" | 9 #include "content/child/v8_value_converter_impl.h" |
| 10 #include "content/common/child_process_messages.h" | 10 #include "content/common/child_process_messages.h" |
| 11 #include "content/common/frame_messages.h" | 11 #include "content/common/frame_messages.h" |
| 12 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
| 13 #include "gin/handle.h" | 13 #include "gin/handle.h" |
| 14 #include "gin/object_template_builder.h" | 14 #include "gin/object_template_builder.h" |
| 15 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
| 16 #include "third_party/WebKit/public/web/WebKit.h" | 16 #include "third_party/WebKit/public/web/WebKit.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 gin::WrapperInfo DomAutomationController::kWrapperInfo = { | 20 gin::WrapperInfo DomAutomationController::kWrapperInfo = { |
| 21 gin::kEmbedderNativeGin}; | 21 gin::kEmbedderNativeGin}; |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 void DomAutomationController::Install(RenderFrame* render_frame, | 24 void DomAutomationController::Install(RenderFrame* render_frame, |
| 25 blink::WebFrame* frame) { | 25 blink::WebFrame* frame) { |
| 26 v8::Isolate* isolate = blink::mainThreadIsolate(); | 26 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 27 v8::HandleScope handle_scope(isolate); | 27 v8::HandleScope handle_scope(isolate); |
| 28 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 28 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 29 if (context.IsEmpty()) | 29 if (context.IsEmpty()) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 v8::Context::Scope context_scope(context); | 32 v8::Context::Scope context_scope(context); |
| 33 | 33 |
| 34 gin::Handle<DomAutomationController> controller = | 34 gin::Handle<DomAutomationController> controller = |
| 35 gin::CreateHandle(isolate, new DomAutomationController(render_frame)); | 35 gin::CreateHandle(isolate, new DomAutomationController(render_frame)); |
| 36 if (controller.IsEmpty()) | 36 if (controller.IsEmpty()) |
| 37 return; | 37 return; |
| 38 | 38 |
| 39 v8::Handle<v8::Object> global = context->Global(); | 39 v8::Local<v8::Object> global = context->Global(); |
| 40 global->Set(gin::StringToV8(isolate, "domAutomationController"), | 40 global->Set(gin::StringToV8(isolate, "domAutomationController"), |
| 41 controller.ToV8()); | 41 controller.ToV8()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 DomAutomationController::DomAutomationController(RenderFrame* render_frame) | 44 DomAutomationController::DomAutomationController(RenderFrame* render_frame) |
| 45 : RenderFrameObserver(render_frame), automation_id_(MSG_ROUTING_NONE) {} | 45 : RenderFrameObserver(render_frame), automation_id_(MSG_ROUTING_NONE) {} |
| 46 | 46 |
| 47 DomAutomationController::~DomAutomationController() {} | 47 DomAutomationController::~DomAutomationController() {} |
| 48 | 48 |
| 49 gin::ObjectTemplateBuilder DomAutomationController::GetObjectTemplateBuilder( | 49 gin::ObjectTemplateBuilder DomAutomationController::GetObjectTemplateBuilder( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return Send( | 114 return Send( |
| 115 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id)); | 115 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool DomAutomationController::SetAutomationId(int automation_id) { | 118 bool DomAutomationController::SetAutomationId(int automation_id) { |
| 119 automation_id_ = automation_id; | 119 automation_id_ = automation_id; |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace content | 123 } // namespace content |
| OLD | NEW |