blob: 8e754b5824749e8941b302c9084ae8ef6de40fb5 [file] [log] [blame]
[email protected]fd911dd2012-01-27 01:57:101// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]d353541f2012-05-03 22:45:415#include "content/renderer/render_process_impl.h"
6
[email protected]037fce02009-01-22 01:42:157#include "build/build_config.h"
8
9#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2910#include <windows.h>
11#include <objidl.h>
12#include <mlang.h>
[email protected]037fce02009-01-22 01:42:1513#endif
initial.commit09911bf2008-07-26 23:55:2914
initial.commit09911bf2008-07-26 23:55:2915#include "base/basictypes.h"
16#include "base/command_line.h"
[email protected]037fce02009-01-22 01:42:1517#include "base/compiler_specific.h"
[email protected]aaf68892013-07-18 00:11:3018#include "base/message_loop/message_loop.h"
[email protected]74ebfb12013-06-07 20:48:0019#include "base/strings/utf_string_conversions.h"
[email protected]037fce02009-01-22 01:42:1520#include "base/sys_info.h"
[email protected]10208ea2013-06-06 20:08:0321#include "content/child/child_thread.h"
[email protected]29e2fb42013-07-19 01:13:4722#include "content/child/npapi/plugin_instance.h"
23#include "content/child/npapi/plugin_lib.h"
[email protected]55dd9332013-09-04 17:17:5024#include "content/child/site_isolation_policy.h"
[email protected]0aed2f52011-03-23 18:06:3625#include "content/common/view_messages.h"
[email protected]c08950d22011-10-13 22:20:2926#include "content/public/common/content_switches.h"
[email protected]d344114c2011-10-01 01:24:3427#include "content/public/renderer/content_renderer_client.h"
[email protected]946d1b22009-07-22 23:57:2128#include "ipc/ipc_channel.h"
29#include "ipc/ipc_message_utils.h"
[email protected]46f36a492010-07-28 19:36:4130#include "skia/ext/platform_canvas.h"
[email protected]6bd867b2013-07-24 22:10:2031#include "third_party/WebKit/public/web/WebFrame.h"
[email protected]d353541f2012-05-03 22:45:4132#include "ui/surface/transport_dib.h"
[email protected]067f5192014-01-29 05:22:0933#include "v8/include/v8.h"
initial.commit09911bf2008-07-26 23:55:2934
[email protected]0c3a16b2009-10-08 23:17:1435#if defined(OS_MACOSX)
[email protected]0378bf42011-01-01 18:20:1436#include "base/mac/mac_util.h"
[email protected]0c3a16b2009-10-08 23:17:1437#endif
38
[email protected]987422f2013-10-01 10:33:3139#if defined(OS_ANDROID)
40#include "base/android/sys_utils.h"
41#endif
42
[email protected]eb398192012-10-22 20:16:1943namespace content {
44
[email protected]396c3a462010-03-03 05:03:2245RenderProcessImpl::RenderProcessImpl()
[email protected]1cf03f7f2014-04-24 03:09:4946 : enabled_bindings_(0) {
[email protected]396c3a462010-03-03 05:03:2247#if defined(OS_WIN)
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"));
57 DCHECK(gdi_init_lpk);
[email protected]00c39612010-03-06 02:53:2858 if (gdi_init_lpk) {
[email protected]396c3a462010-03-03 05:03:2259 gdi_init_lpk(0);
[email protected]00c39612010-03-06 02:53:2860 }
[email protected]396c3a462010-03-03 05:03:2261 }
[email protected]e68e62fa2009-02-20 02:00:0462#endif
63
[email protected]987422f2013-10-01 10:33:3164#if defined(OS_ANDROID)
[email protected]067f5192014-01-29 05:22:0965 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()));
69 }
[email protected]987422f2013-10-01 10:33:3170#endif
71
[email protected]396c3a462010-03-03 05:03:2272 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
73 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
[email protected]067f5192014-01-29 05:22:0974 std::string flags(
[email protected]95edc392010-07-30 22:00:3875 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
[email protected]067f5192014-01-29 05:22:0976 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
[email protected]396c3a462010-03-03 05:03:2277 }
[email protected]55dd9332013-09-04 17:17:5078
79 // Turn on cross-site document blocking for renderer processes.
80 SiteIsolationPolicy::SetPolicyEnabled(
81 GetContentClient()->renderer()->ShouldEnableSiteIsolationPolicy());
[email protected]e68e62fa2009-02-20 02:00:0482}
83
[email protected]396c3a462010-03-03 05:03:2284RenderProcessImpl::~RenderProcessImpl() {
[email protected]396c3a462010-03-03 05:03:2285#ifndef NDEBUG
[email protected]180ef242013-11-07 06:50:4686 int count = blink::WebFrame::instanceCount();
[email protected]6bd867b2013-07-24 22:10:2087 if (count)
88 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
[email protected]396c3a462010-03-03 05:03:2289#endif
[email protected]e68e62fa2009-02-20 02:00:0490
[email protected]396c3a462010-03-03 05:03:2291 GetShutDownEvent()->Signal();
[email protected]396c3a462010-03-03 05:03:2292}
[email protected]e68e62fa2009-02-20 02:00:0493
[email protected]744c2a22012-03-15 18:42:0494void RenderProcessImpl::AddBindings(int bindings) {
95 enabled_bindings_ |= bindings;
96}
97
98int RenderProcessImpl::GetEnabledBindings() const {
99 return enabled_bindings_;
100}
101
[email protected]eb398192012-10-22 20:16:19102} // namespace content