| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/renderer/render_process_impl.h" | 5 #include "content/renderer/render_process_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <objidl.h> | 11 #include <objidl.h> |
| 12 #include <mlang.h> | 12 #include <mlang.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/sys_utils.h" |
| 18 #include "content/child/site_isolation_policy.h" | 19 #include "content/child/site_isolation_policy.h" |
| 19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/renderer/content_renderer_client.h" | 21 #include "content/public/renderer/content_renderer_client.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| 22 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
| 23 | 24 |
| 24 #if defined(OS_ANDROID) | |
| 25 #include "base/android/sys_utils.h" | |
| 26 #endif | |
| 27 | |
| 28 namespace content { | 25 namespace content { |
| 29 | 26 |
| 30 RenderProcessImpl::RenderProcessImpl() | 27 RenderProcessImpl::RenderProcessImpl() |
| 31 : enabled_bindings_(0) { | 28 : enabled_bindings_(0) { |
| 32 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 33 // HACK: See http://b/issue?id=1024307 for rationale. | 30 // HACK: See http://b/issue?id=1024307 for rationale. |
| 34 if (GetModuleHandle(L"LPK.DLL") == NULL) { | 31 if (GetModuleHandle(L"LPK.DLL") == NULL) { |
| 35 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works | 32 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works |
| 36 // when buffering into a EMF buffer for printing. | 33 // when buffering into a EMF buffer for printing. |
| 37 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); | 34 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); |
| 38 GdiInitializeLanguagePack gdi_init_lpk = | 35 GdiInitializeLanguagePack gdi_init_lpk = |
| 39 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress( | 36 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress( |
| 40 GetModuleHandle(L"GDI32.DLL"), | 37 GetModuleHandle(L"GDI32.DLL"), |
| 41 "GdiInitializeLanguagePack")); | 38 "GdiInitializeLanguagePack")); |
| 42 DCHECK(gdi_init_lpk); | 39 DCHECK(gdi_init_lpk); |
| 43 if (gdi_init_lpk) { | 40 if (gdi_init_lpk) { |
| 44 gdi_init_lpk(0); | 41 gdi_init_lpk(0); |
| 45 } | 42 } |
| 46 } | 43 } |
| 47 #endif | 44 #endif |
| 48 | 45 |
| 49 #if defined(OS_ANDROID) | 46 if (base::SysUtils::IsLowEndDevice()) { |
| 50 if (base::android::SysUtils::IsLowEndDevice()) { | |
| 51 std::string optimize_flag("--optimize-for-size"); | 47 std::string optimize_flag("--optimize-for-size"); |
| 52 v8::V8::SetFlagsFromString(optimize_flag.c_str(), | 48 v8::V8::SetFlagsFromString(optimize_flag.c_str(), |
| 53 static_cast<int>(optimize_flag.size())); | 49 static_cast<int>(optimize_flag.size())); |
| 54 } | 50 } |
| 55 #endif | |
| 56 | 51 |
| 57 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 52 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 58 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { | 53 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { |
| 59 std::string flags( | 54 std::string flags( |
| 60 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); | 55 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); |
| 61 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 56 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 62 } | 57 } |
| 63 | 58 |
| 64 // Turn on cross-site document blocking for renderer processes. | 59 // Turn on cross-site document blocking for renderer processes. |
| 65 SiteIsolationPolicy::SetPolicyEnabled( | 60 SiteIsolationPolicy::SetPolicyEnabled( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 | 73 |
| 79 void RenderProcessImpl::AddBindings(int bindings) { | 74 void RenderProcessImpl::AddBindings(int bindings) { |
| 80 enabled_bindings_ |= bindings; | 75 enabled_bindings_ |= bindings; |
| 81 } | 76 } |
| 82 | 77 |
| 83 int RenderProcessImpl::GetEnabledBindings() const { | 78 int RenderProcessImpl::GetEnabledBindings() const { |
| 84 return enabled_bindings_; | 79 return enabled_bindings_; |
| 85 } | 80 } |
| 86 | 81 |
| 87 } // namespace content | 82 } // namespace content |
| OLD | NEW |