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
3 // found in the LICENSE file.
5 #include "content/renderer/render_process_impl.h"
7 #include "build/build_config.h"
15 #include "base/basictypes.h"
16 #include "base/command_line.h"
17 #include "base/compiler_specific.h"
18 #include "base/message_loop/message_loop.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "base/sys_info.h"
21 #include "content/child/child_thread.h"
22 #include "content/child/npapi/plugin_instance.h"
23 #include "content/child/npapi/plugin_lib.h"
24 #include "content/child/site_isolation_policy.h"
25 #include "content/common/view_messages.h"
26 #include "content/public/common/content_switches.h"
27 #include "content/public/renderer/content_renderer_client.h"
28 #include "ipc/ipc_channel.h"
29 #include "ipc/ipc_message_utils.h"
30 #include "skia/ext/platform_canvas.h"
31 #include "third_party/WebKit/public/web/WebFrame.h"
32 #include "ui/surface/transport_dib.h"
33 #include "v8/include/v8.h"
35 #if defined(OS_MACOSX)
36 #include "base/mac/mac_util.h"
39 #if defined(OS_ANDROID)
40 #include "base/android/sys_utils.h"
45 RenderProcessImpl::RenderProcessImpl()
46 : enabled_bindings_(0) {
48 // HACK: See http://b/issue?id=1024307 for rationale.
49 if (GetModuleHandle(L
"LPK.DLL") == NULL
) {
50 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works
51 // when buffering into a EMF buffer for printing.
52 typedef BOOL (__stdcall
*GdiInitializeLanguagePack
)(int LoadedShapingDLLs
);
53 GdiInitializeLanguagePack gdi_init_lpk
=
54 reinterpret_cast<GdiInitializeLanguagePack
>(GetProcAddress(
55 GetModuleHandle(L
"GDI32.DLL"),
56 "GdiInitializeLanguagePack"));
64 #if defined(OS_ANDROID)
65 if (base::android::SysUtils::IsLowEndDevice()) {
66 std::string
optimize_flag("--optimize-for-size");
67 v8::V8::SetFlagsFromString(optimize_flag
.c_str(),
68 static_cast<int>(optimize_flag
.size()));
72 const CommandLine
& command_line
= *CommandLine::ForCurrentProcess();
73 if (command_line
.HasSwitch(switches::kJavaScriptFlags
)) {
75 command_line
.GetSwitchValueASCII(switches::kJavaScriptFlags
));
76 v8::V8::SetFlagsFromString(flags
.c_str(), static_cast<int>(flags
.size()));
79 // Turn on cross-site document blocking for renderer processes.
80 SiteIsolationPolicy::SetPolicyEnabled(
81 GetContentClient()->renderer()->ShouldEnableSiteIsolationPolicy());
84 RenderProcessImpl::~RenderProcessImpl() {
86 int count
= blink::WebFrame::instanceCount();
88 DLOG(ERROR
) << "WebFrame LEAKED " << count
<< " TIMES";
91 GetShutDownEvent()->Signal();
94 void RenderProcessImpl::AddBindings(int bindings
) {
95 enabled_bindings_
|= bindings
;
98 int RenderProcessImpl::GetEnabledBindings() const {
99 return enabled_bindings_
;
102 } // namespace content