Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: content/renderer/dom_automation_controller.cc

Issue 1336433002: Revert of Expose distiller functions to JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-content
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/dom_automation_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return gin::Wrappable<DomAutomationController>::GetObjectTemplateBuilder( 51 return gin::Wrappable<DomAutomationController>::GetObjectTemplateBuilder(
52 isolate) 52 isolate)
53 .SetMethod("send", &DomAutomationController::SendMsg) 53 .SetMethod("send", &DomAutomationController::SendMsg)
54 .SetMethod("setAutomationId", &DomAutomationController::SetAutomationId) 54 .SetMethod("setAutomationId", &DomAutomationController::SetAutomationId)
55 .SetMethod("sendJSON", &DomAutomationController::SendJSON) 55 .SetMethod("sendJSON", &DomAutomationController::SendJSON)
56 .SetMethod("sendWithId", &DomAutomationController::SendWithId); 56 .SetMethod("sendWithId", &DomAutomationController::SendWithId);
57 } 57 }
58 58
59 void DomAutomationController::OnDestruct() {} 59 void DomAutomationController::OnDestruct() {}
60 60
61 void DomAutomationController::DidCreateScriptContext(
62 v8::Local<v8::Context> context,
63 int extension_group,
64 int world_id) {
65 // Add the domAutomationController to isolated worlds as well.
66 v8::Isolate* isolate = blink::mainThreadIsolate();
67 v8::HandleScope handle_scope(isolate);
68 if (context.IsEmpty())
69 return;
70
71 v8::Context::Scope context_scope(context);
72
73 // Resuse this object instead of creating others.
74 gin::Handle<DomAutomationController> controller =
75 gin::CreateHandle(isolate, this);
76 if (controller.IsEmpty())
77 return;
78
79 v8::Local<v8::Object> global = context->Global();
80 global->Set(gin::StringToV8(isolate, "domAutomationController"),
81 controller.ToV8());
82 }
83
84 bool DomAutomationController::SendMsg(const gin::Arguments& args) { 61 bool DomAutomationController::SendMsg(const gin::Arguments& args) {
85 if (!render_frame()) 62 if (!render_frame())
86 return false; 63 return false;
87 64
88 if (automation_id_ == MSG_ROUTING_NONE) 65 if (automation_id_ == MSG_ROUTING_NONE)
89 return false; 66 return false;
90 67
91 std::string json; 68 std::string json;
92 JSONStringValueSerializer serializer(&json); 69 JSONStringValueSerializer serializer(&json);
93 scoped_ptr<base::Value> value; 70 scoped_ptr<base::Value> value;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return Send( 115 return Send(
139 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id)); 116 new FrameHostMsg_DomOperationResponse(routing_id(), str, automation_id));
140 } 117 }
141 118
142 bool DomAutomationController::SetAutomationId(int automation_id) { 119 bool DomAutomationController::SetAutomationId(int automation_id) {
143 automation_id_ = automation_id; 120 automation_id_ = automation_id;
144 return true; 121 return true;
145 } 122 }
146 123
147 } // namespace content 124 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_automation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698