blob: 8e754b5824749e8941b302c9084ae8ef6de40fb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/render_process_impl.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#include <objidl.h>
#include <mlang.h>
#endif
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "content/child/child_thread.h"
#include "content/child/npapi/plugin_instance.h"
#include "content/child/npapi/plugin_lib.h"
#include "content/child/site_isolation_policy.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/content_renderer_client.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message_utils.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "ui/surface/transport_dib.h"
#include "v8/include/v8.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#endif
#if defined(OS_ANDROID)
#include "base/android/sys_utils.h"
#endif
namespace content {
RenderProcessImpl::RenderProcessImpl()
: enabled_bindings_(0) {
#if defined(OS_WIN)
// HACK: See http://b/issue?id=1024307 for rationale.
if (GetModuleHandle(L"LPK.DLL") == NULL) {
// Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works
// when buffering into a EMF buffer for printing.
typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs);
GdiInitializeLanguagePack gdi_init_lpk =
reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress(
GetModuleHandle(L"GDI32.DLL"),
"GdiInitializeLanguagePack"));
DCHECK(gdi_init_lpk);
if (gdi_init_lpk) {
gdi_init_lpk(0);
}
}
#endif
#if defined(OS_ANDROID)
if (base::android::SysUtils::IsLowEndDevice()) {
std::string optimize_flag("--optimize-for-size");
v8::V8::SetFlagsFromString(optimize_flag.c_str(),
static_cast<int>(optimize_flag.size()));
}
#endif
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
std::string flags(
command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
}
// Turn on cross-site document blocking for renderer processes.
SiteIsolationPolicy::SetPolicyEnabled(
GetContentClient()->renderer()->ShouldEnableSiteIsolationPolicy());
}
RenderProcessImpl::~RenderProcessImpl() {
#ifndef NDEBUG
int count = blink::WebFrame::instanceCount();
if (count)
DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
#endif
GetShutDownEvent()->Signal();
}
void RenderProcessImpl::AddBindings(int bindings) {
enabled_bindings_ |= bindings;
}
int RenderProcessImpl::GetEnabledBindings() const {
return enabled_bindings_;
}
} // namespace content
|