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

Side by Side Diff: headless/lib/renderer/headless_content_renderer_client.cc

Issue 2907523003: Fix TabSocket.onmessage whoch should be able to retrieve all messages (Closed)
Patch Set: Created 3 years, 7 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 | « headless/lib/headless_web_contents_browsertest.cc ('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 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
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
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
OLDNEW
« no previous file with comments | « headless/lib/headless_web_contents_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698