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

Side by Side Diff: content/shell/renderer/layout_test/layout_test_content_renderer_client.cc

Issue 2823693002: Migrate RenderThreadImpl to use ConnectionFilter instead of the ChildThread's InterfaceRegistry to … (Closed)
Patch Set: . Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/shell/renderer/layout_test/layout_test_content_renderer_client .h" 5 #include "content/shell/renderer/layout_test/layout_test_content_renderer_client .h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "components/web_cache/renderer/web_cache_impl.h" 11 #include "components/web_cache/renderer/web_cache_impl.h"
12 #include "content/public/common/content_constants.h" 12 #include "content/public/common/content_constants.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/renderer/render_frame.h" 14 #include "content/public/renderer/render_frame.h"
15 #include "content/public/renderer/render_thread.h" 15 #include "content/public/renderer/render_thread.h"
16 #include "content/public/renderer/render_view.h" 16 #include "content/public/renderer/render_view.h"
17 #include "content/public/test/layouttest_support.h" 17 #include "content/public/test/layouttest_support.h"
18 #include "content/shell/common/layout_test/layout_test_switches.h" 18 #include "content/shell/common/layout_test/layout_test_switches.h"
19 #include "content/shell/common/shell_switches.h" 19 #include "content/shell/common/shell_switches.h"
20 #include "content/shell/renderer/layout_test/blink_test_helpers.h" 20 #include "content/shell/renderer/layout_test/blink_test_helpers.h"
21 #include "content/shell/renderer/layout_test/blink_test_runner.h" 21 #include "content/shell/renderer/layout_test/blink_test_runner.h"
22 #include "content/shell/renderer/layout_test/interface_registry_js_wrapper.h"
23 #include "content/shell/renderer/layout_test/layout_test_render_frame_observer.h " 22 #include "content/shell/renderer/layout_test/layout_test_render_frame_observer.h "
24 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer. h" 23 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer. h"
25 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory. h" 24 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory. h"
26 #include "content/shell/renderer/shell_render_view_observer.h" 25 #include "content/shell/renderer/shell_render_view_observer.h"
27 #include "content/shell/test_runner/mock_credential_manager_client.h" 26 #include "content/shell/test_runner/mock_credential_manager_client.h"
28 #include "content/shell/test_runner/web_frame_test_proxy.h" 27 #include "content/shell/test_runner/web_frame_test_proxy.h"
29 #include "content/shell/test_runner/web_test_interfaces.h" 28 #include "content/shell/test_runner/web_test_interfaces.h"
30 #include "content/shell/test_runner/web_test_runner.h" 29 #include "content/shell/test_runner/web_test_runner.h"
31 #include "content/shell/test_runner/web_view_test_proxy.h" 30 #include "content/shell/test_runner/web_view_test_proxy.h"
32 #include "content/test/mock_webclipboard_impl.h" 31 #include "content/test/mock_webclipboard_impl.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 #else 264 #else
266 return base::WrapUnique(new gfx::ICCProfile()); 265 return base::WrapUnique(new gfx::ICCProfile());
267 #endif 266 #endif
268 } 267 }
269 268
270 void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread( 269 void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread(
271 v8::Local<v8::Context> context) { 270 v8::Local<v8::Context> context) {
272 blink::WebTestingSupport::InjectInternalsObject(context); 271 blink::WebTestingSupport::InjectInternalsObject(context);
273 } 272 }
274 273
275 void LayoutTestContentRendererClient::RunScriptsAtDocumentEnd(
276 RenderFrame* render_frame) {
277 v8::Isolate* isolate = blink::MainThreadIsolate();
278 v8::HandleScope handle_scope(isolate);
279 blink::WebLocalFrame* frame = render_frame->GetWebFrame();
280 v8::Local<v8::Context> context = frame->MainWorldScriptContext();
281 v8::Context::Scope context_scope(context);
282
283 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(context);
284 if (registry->available_modules().count(
285 InterfaceRegistryJsWrapper::kPerFrameModuleName)) {
286 return;
287 }
288
289 registry->AddBuiltinModule(
290 isolate, InterfaceRegistryJsWrapper::kPerFrameModuleName,
291 InterfaceRegistryJsWrapper::Create(isolate, context,
292 render_frame->GetInterfaceRegistry())
293 .ToV8());
294 registry->AddBuiltinModule(
295 isolate, InterfaceRegistryJsWrapper::kPerProcessModuleName,
296 InterfaceRegistryJsWrapper::Create(
297 isolate, context, RenderThread::Get()->GetInterfaceRegistry())
298 .ToV8());
299 registry->AttemptToLoadMoreModules(isolate);
300 }
301
302 void LayoutTestContentRendererClient:: 274 void LayoutTestContentRendererClient::
303 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() { 275 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
304 // We always expose GC to layout tests. 276 // We always expose GC to layout tests.
305 std::string flags("--expose-gc"); 277 std::string flags("--expose-gc");
306 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 278 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
307 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 279 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
308 switches::kStableReleaseMode)) { 280 switches::kStableReleaseMode)) {
309 blink::WebRuntimeFeatures::EnableTestOnlyFeatures(true); 281 blink::WebRuntimeFeatures::EnableTestOnlyFeatures(true);
310 } 282 }
311 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 283 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
312 switches::kEnableFontAntialiasing)) { 284 switches::kEnableFontAntialiasing)) {
313 blink::SetFontAntialiasingEnabledForTest(true); 285 blink::SetFontAntialiasingEnabledForTest(true);
314 } 286 }
315 } 287 }
316 288
317 } // namespace content 289 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698