| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "headless/lib/renderer/headless_content_renderer_client.h" | 5 #include "headless/lib/renderer/headless_content_renderer_client.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/common/bindings_policy.h" | 9 #include "content/public/common/bindings_policy.h" |
| 10 #include "content/public/common/isolated_world_ids.h" | 10 #include "content/public/common/isolated_world_ids.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 v8::Isolate* isolate = blink::MainThreadIsolate(); | 109 v8::Isolate* isolate = blink::MainThreadIsolate(); |
| 110 v8::HandleScope handle_scope(isolate); | 110 v8::HandleScope handle_scope(isolate); |
| 111 v8::Local<v8::Context> context = GetContext(); | 111 v8::Local<v8::Context> context = GetContext(); |
| 112 v8::Local<v8::Value> argv[] = { | 112 v8::Local<v8::Value> argv[] = { |
| 113 gin::Converter<std::string>::ToV8(isolate, message), | 113 gin::Converter<std::string>::ToV8(isolate, message), |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 render_frame()->GetWebFrame()->RequestExecuteV8Function( | 116 render_frame()->GetWebFrame()->RequestExecuteV8Function( |
| 117 context, GetOnMessageCallback(), context->Global(), arraysize(argv), | 117 context, GetOnMessageCallback(), context->Global(), arraysize(argv), |
| 118 argv, this); | 118 argv, this); |
| 119 |
| 120 EnsureTabSocketPtr()->AwaitNextMessageFromEmbedder( |
| 121 base::Bind(&HeadlessTabSocketBindings::OnNextMessageFromEmbedder, |
| 122 weak_ptr_factory_.GetWeakPtr())); |
| 119 } | 123 } |
| 120 | 124 |
| 121 void InitializeTabSocketBindings(v8::Local<v8::Context> context) { | 125 void InitializeTabSocketBindings(v8::Local<v8::Context> context) { |
| 122 // Add TabSocket bindings to the DevTools created isolated world. | 126 // Add TabSocket bindings to the DevTools created isolated world. |
| 123 v8::Isolate* isolate = blink::MainThreadIsolate(); | 127 v8::Isolate* isolate = blink::MainThreadIsolate(); |
| 124 v8::HandleScope handle_scope(isolate); | 128 v8::HandleScope handle_scope(isolate); |
| 125 if (context.IsEmpty()) | 129 if (context.IsEmpty()) |
| 126 return; | 130 return; |
| 127 | 131 |
| 128 v8::Context::Scope context_scope(context); | 132 v8::Context::Scope context_scope(context); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void HeadlessContentRendererClient::RenderFrameCreated( | 169 void HeadlessContentRendererClient::RenderFrameCreated( |
| 166 content::RenderFrame* render_frame) { | 170 content::RenderFrame* render_frame) { |
| 167 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 171 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 168 new printing::PrintWebViewHelper( | 172 new printing::PrintWebViewHelper( |
| 169 render_frame, base::MakeUnique<HeadlessPrintWebViewHelperDelegate>()); | 173 render_frame, base::MakeUnique<HeadlessPrintWebViewHelperDelegate>()); |
| 170 #endif | 174 #endif |
| 171 new HeadlessTabSocketBindings(render_frame); | 175 new HeadlessTabSocketBindings(render_frame); |
| 172 } | 176 } |
| 173 | 177 |
| 174 } // namespace headless | 178 } // namespace headless |
| OLD | NEW |