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/common/child_process_messages.h" | 9 #include "content/common/child_process_messages.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
(...skipping 15 matching lines...) Expand all Loading... |
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::Handle<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()) |
| 37 return; |
| 38 |
36 v8::Handle<v8::Object> global = context->Global(); | 39 v8::Handle<v8::Object> global = context->Global(); |
37 global->Set(gin::StringToV8(isolate, "domAutomationController"), | 40 global->Set(gin::StringToV8(isolate, "domAutomationController"), |
38 controller.ToV8()); | 41 controller.ToV8()); |
39 } | 42 } |
40 | 43 |
41 DomAutomationController::DomAutomationController(RenderFrame* render_frame) | 44 DomAutomationController::DomAutomationController(RenderFrame* render_frame) |
42 : RenderFrameObserver(render_frame), automation_id_(MSG_ROUTING_NONE) {} | 45 : RenderFrameObserver(render_frame), automation_id_(MSG_ROUTING_NONE) {} |
43 | 46 |
44 DomAutomationController::~DomAutomationController() {} | 47 DomAutomationController::~DomAutomationController() {} |
45 | 48 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return Send( | 114 return Send( |
112 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id)); | 115 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id)); |
113 } | 116 } |
114 | 117 |
115 bool DomAutomationController::SetAutomationId(int automation_id) { | 118 bool DomAutomationController::SetAutomationId(int automation_id) { |
116 automation_id_ = automation_id; | 119 automation_id_ = automation_id; |
117 return true; | 120 return true; |
118 } | 121 } |
119 | 122 |
120 } // namespace content | 123 } // namespace content |
OLD | NEW |