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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 #include "ui/native_theme/native_theme_switches.h" | 168 #include "ui/native_theme/native_theme_switches.h" |
169 | 169 |
170 #if defined(OS_ANDROID) | 170 #if defined(OS_ANDROID) |
171 #include "content/browser/android/child_process_launcher_android.h" | 171 #include "content/browser/android/child_process_launcher_android.h" |
172 #include "content/browser/media/android/browser_demuxer_android.h" | 172 #include "content/browser/media/android/browser_demuxer_android.h" |
173 #include "content/browser/mojo/service_registrar_android.h" | 173 #include "content/browser/mojo/service_registrar_android.h" |
174 #include "content/browser/screen_orientation/screen_orientation_message_filter_a ndroid.h" | 174 #include "content/browser/screen_orientation/screen_orientation_message_filter_a ndroid.h" |
175 #endif | 175 #endif |
176 | 176 |
177 #if defined(OS_WIN) | 177 #if defined(OS_WIN) |
178 #include "base/memory/shared_memory.h" | |
178 #include "base/win/scoped_com_initializer.h" | 179 #include "base/win/scoped_com_initializer.h" |
179 #include "base/win/windows_version.h" | 180 #include "base/win/windows_version.h" |
180 #include "content/common/font_cache_dispatcher_win.h" | 181 #include "content/common/font_cache_dispatcher_win.h" |
181 #include "content/common/sandbox_win.h" | 182 #include "content/common/sandbox_win.h" |
183 #include "content/public/common/dwrite_font_platform_win.h" | |
182 #include "sandbox/win/src/sandbox_policy.h" | 184 #include "sandbox/win/src/sandbox_policy.h" |
185 #include "ui/gfx/win/direct_write.h" | |
183 #include "ui/gfx/win/dpi.h" | 186 #include "ui/gfx/win/dpi.h" |
184 #endif | 187 #endif |
185 | 188 |
186 #if defined(ENABLE_BROWSER_CDMS) | 189 #if defined(ENABLE_BROWSER_CDMS) |
187 #include "content/browser/media/cdm/browser_cdm_manager.h" | 190 #include "content/browser/media/cdm/browser_cdm_manager.h" |
188 #endif | 191 #endif |
189 | 192 |
190 #if defined(ENABLE_PLUGINS) | 193 #if defined(ENABLE_PLUGINS) |
191 #include "content/browser/plugin_service_impl.h" | 194 #include "content/browser/plugin_service_impl.h" |
192 #endif | 195 #endif |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 return map; | 325 return map; |
323 } | 326 } |
324 | 327 |
325 // NOTE: changes to this class need to be reviewed by the security team. | 328 // NOTE: changes to this class need to be reviewed by the security team. |
326 class RendererSandboxedProcessLauncherDelegate | 329 class RendererSandboxedProcessLauncherDelegate |
327 : public SandboxedProcessLauncherDelegate { | 330 : public SandboxedProcessLauncherDelegate { |
328 public: | 331 public: |
329 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) | 332 explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) |
330 #if defined(OS_POSIX) | 333 #if defined(OS_POSIX) |
331 : ipc_fd_(channel->TakeClientFileDescriptor()) | 334 : ipc_fd_(channel->TakeClientFileDescriptor()) |
332 #endif // OS_POSIX | 335 #elif defined(OS_WIN) |
336 : direct_write_font_cache_section_(NULL) | |
337 #endif // OS_WIN | |
333 {} | 338 {} |
334 | 339 |
335 ~RendererSandboxedProcessLauncherDelegate() override {} | 340 ~RendererSandboxedProcessLauncherDelegate() override {} |
336 | 341 |
337 #if defined(OS_WIN) | 342 #if defined(OS_WIN) |
338 void PreSpawnTarget(sandbox::TargetPolicy* policy, bool* success) override { | 343 void PreSpawnTarget(sandbox::TargetPolicy* policy, bool* success) override { |
339 AddBaseHandleClosePolicy(policy); | 344 AddBaseHandleClosePolicy(policy); |
340 | 345 |
341 if (base::win::GetVersion() == base::win::VERSION_WIN8 || | 346 if (base::win::GetVersion() == base::win::VERSION_WIN8 || |
342 base::win::GetVersion() == base::win::VERSION_WIN8_1) { | 347 base::win::GetVersion() == base::win::VERSION_WIN8_1) { |
343 const base::CommandLine& command_line = | 348 const base::CommandLine& command_line = |
344 *base::CommandLine::ForCurrentProcess(); | 349 *base::CommandLine::ForCurrentProcess(); |
345 if (!command_line.HasSwitch(switches::kDisableAppContainer)) { | 350 if (!command_line.HasSwitch(switches::kDisableAppContainer)) { |
346 // TODO(shrikant): Check if these constants should be different across | 351 // TODO(shrikant): Check if these constants should be different across |
347 // various versions of Chromium code base or could be same. | 352 // various versions of Chromium code base or could be same. |
348 // If there should be different SID per channel then move this code | 353 // If there should be different SID per channel then move this code |
349 // in chrome rather than content and assign SID based on | 354 // in chrome rather than content and assign SID based on |
350 // VersionInfo::GetChannel(). | 355 // VersionInfo::GetChannel(). |
351 const wchar_t kAppContainerSid[] = | 356 const wchar_t kAppContainerSid[] = |
352 L"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-" | 357 L"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-" |
353 L"924012148-129201922"; | 358 L"924012148-129201922"; |
354 | 359 |
355 policy->SetLowBox(kAppContainerSid); | 360 policy->SetLowBox(kAppContainerSid); |
356 } | 361 } |
357 } | 362 } |
358 | 363 |
364 // If we have a valid DirectWrite font cache section then add its handle to | |
365 // the list of handles being shared with the renderer process. | |
366 if (direct_write_font_cache_section_) | |
367 policy->AddHandleToShare(direct_write_font_cache_section_); | |
368 | |
359 GetContentClient()->browser()->PreSpawnRenderer(policy, success); | 369 GetContentClient()->browser()->PreSpawnRenderer(policy, success); |
360 } | 370 } |
361 | 371 |
372 void set_direct_write_font_cache_handle( | |
373 base::SharedMemoryHandle direct_write_font_cache_section) { | |
374 direct_write_font_cache_section_ = direct_write_font_cache_section; | |
Shrikant Kelkar
2015/05/05 20:43:16
Scope/DuplicateHandle?
ananta
2015/05/07 22:00:47
This code is no longer needed. Based on a discussi
| |
375 } | |
362 #elif defined(OS_POSIX) | 376 #elif defined(OS_POSIX) |
363 bool ShouldUseZygote() override { | 377 bool ShouldUseZygote() override { |
364 const base::CommandLine& browser_command_line = | 378 const base::CommandLine& browser_command_line = |
365 *base::CommandLine::ForCurrentProcess(); | 379 *base::CommandLine::ForCurrentProcess(); |
366 base::CommandLine::StringType renderer_prefix = | 380 base::CommandLine::StringType renderer_prefix = |
367 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 381 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
368 return renderer_prefix.empty(); | 382 return renderer_prefix.empty(); |
369 } | 383 } |
370 base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } | 384 base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } |
371 #endif // OS_WIN | 385 #endif // OS_WIN |
372 | 386 |
373 private: | 387 private: |
374 #if defined(OS_POSIX) | 388 #if defined(OS_POSIX) |
375 base::ScopedFD ipc_fd_; | 389 base::ScopedFD ipc_fd_; |
376 #endif // OS_POSIX | 390 #endif // OS_POSIX |
391 | |
392 #if defined(OS_WIN) | |
393 base::SharedMemoryHandle direct_write_font_cache_section_; | |
Shrikant Kelkar
2015/05/05 20:43:15
Scope? Who is the owner?
ananta
2015/05/07 22:00:48
Reworked the patch to move the handle sharing and
| |
394 #endif | |
377 }; | 395 }; |
378 | 396 |
379 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; | 397 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; |
380 | 398 |
381 class SessionStorageHolder : public base::SupportsUserData::Data { | 399 class SessionStorageHolder : public base::SupportsUserData::Data { |
382 public: | 400 public: |
383 SessionStorageHolder() {} | 401 SessionStorageHolder() {} |
384 ~SessionStorageHolder() override {} | 402 ~SessionStorageHolder() override {} |
385 | 403 |
386 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) { | 404 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 // on starting in-process-render-thread. | 676 // on starting in-process-render-thread. |
659 // So put it here to trigger ChannelMojo initialization earlier to enable | 677 // So put it here to trigger ChannelMojo initialization earlier to enable |
660 // in-process-render-thread using ChannelMojo there. | 678 // in-process-render-thread using ChannelMojo there. |
661 OnProcessLaunched(); // Fake a callback that the process is ready. | 679 OnProcessLaunched(); // Fake a callback that the process is ready. |
662 | 680 |
663 in_process_renderer_->StartWithOptions(options); | 681 in_process_renderer_->StartWithOptions(options); |
664 | 682 |
665 g_in_process_thread = in_process_renderer_->message_loop(); | 683 g_in_process_thread = in_process_renderer_->message_loop(); |
666 | 684 |
667 } else { | 685 } else { |
686 RendererSandboxedProcessLauncherDelegate* sandbox_delegate = | |
687 new RendererSandboxedProcessLauncherDelegate(channel_.get()); | |
688 #if defined(OS_WIN) | |
689 // If DirectWrite is enabled for font rendering then open the font cache | |
690 // section and pass the handle to the renderer process. This is needed | |
691 // because renderer processes on Windows 8+ may be running in an | |
692 // AppContainer sandbox and hence their kernel object namespace may be | |
693 // partitioned. | |
694 if (!run_renderer_in_process() && gfx::win::ShouldUseDirectWrite()) { | |
695 std::string name(content::kFontCacheSharedSectionName); | |
696 name.append(base::UintToString(base::GetCurrentProcId())); | |
697 direct_write_font_cache_section_.set_inheritable(true); | |
698 if (direct_write_font_cache_section_.Open(name, true)) { | |
699 sandbox_delegate->set_direct_write_font_cache_handle( | |
700 direct_write_font_cache_section_.handle()); | |
701 } | |
702 } | |
703 #endif | |
668 // Build command line for renderer. We call AppendRendererCommandLine() | 704 // Build command line for renderer. We call AppendRendererCommandLine() |
669 // first so the process type argument will appear first. | 705 // first so the process type argument will appear first. |
670 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); | 706 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); |
671 if (!renderer_prefix.empty()) | 707 if (!renderer_prefix.empty()) |
672 cmd_line->PrependWrapper(renderer_prefix); | 708 cmd_line->PrependWrapper(renderer_prefix); |
673 AppendRendererCommandLine(cmd_line); | 709 AppendRendererCommandLine(cmd_line); |
674 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 710 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
675 | 711 |
676 // Spawn the child process asynchronously to avoid blocking the UI thread. | 712 // Spawn the child process asynchronously to avoid blocking the UI thread. |
677 // As long as there's no renderer prefix, we can use the zygote process | 713 // As long as there's no renderer prefix, we can use the zygote process |
678 // at this stage. | 714 // at this stage. |
679 child_process_launcher_.reset(new ChildProcessLauncher( | 715 child_process_launcher_.reset(new ChildProcessLauncher( |
680 new RendererSandboxedProcessLauncherDelegate(channel_.get()), | 716 sandbox_delegate, |
681 cmd_line, | 717 cmd_line, |
682 GetID(), | 718 GetID(), |
683 this)); | 719 this)); |
684 | 720 |
685 fast_shutdown_started_ = false; | 721 fast_shutdown_started_ = false; |
686 } | 722 } |
687 | 723 |
688 if (!gpu_observer_registered_) { | 724 if (!gpu_observer_registered_) { |
689 gpu_observer_registered_ = true; | 725 gpu_observer_registered_ = true; |
690 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); | 726 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 | 1227 |
1192 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 1228 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
1193 command_line, GetID()); | 1229 command_line, GetID()); |
1194 | 1230 |
1195 if (IsPinchToZoomEnabled()) | 1231 if (IsPinchToZoomEnabled()) |
1196 command_line->AppendSwitch(switches::kEnablePinch); | 1232 command_line->AppendSwitch(switches::kEnablePinch); |
1197 | 1233 |
1198 #if defined(OS_WIN) | 1234 #if defined(OS_WIN) |
1199 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, | 1235 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, |
1200 base::DoubleToString(gfx::GetDPIScale())); | 1236 base::DoubleToString(gfx::GetDPIScale())); |
1201 command_line->AppendSwitchASCII( | 1237 if (direct_write_font_cache_section_.handle()) { |
1202 switches::kFontCacheSharedMemSuffix, | 1238 command_line->AppendSwitchASCII( |
1203 base::UintToString(base::GetCurrentProcId())); | 1239 switches::kFontCacheSharedHandle, |
1240 base::UintToString(reinterpret_cast<unsigned int>( | |
1241 direct_write_font_cache_section_.handle()))); | |
1242 } | |
1204 #endif | 1243 #endif |
1205 | 1244 |
1206 AppendCompositorCommandLineFlags(command_line); | 1245 AppendCompositorCommandLineFlags(command_line); |
1207 } | 1246 } |
1208 | 1247 |
1209 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1248 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
1210 const base::CommandLine& browser_cmd, | 1249 const base::CommandLine& browser_cmd, |
1211 base::CommandLine* renderer_cmd) const { | 1250 base::CommandLine* renderer_cmd) const { |
1212 // Propagate the following switches to the renderer command line (along | 1251 // Propagate the following switches to the renderer command line (along |
1213 // with any associated values) if present in the browser command line. | 1252 // with any associated values) if present in the browser command line. |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2490 if (worker_ref_count_ == 0) | 2529 if (worker_ref_count_ == 0) |
2491 Cleanup(); | 2530 Cleanup(); |
2492 } | 2531 } |
2493 | 2532 |
2494 void RenderProcessHostImpl::GetAudioOutputControllers( | 2533 void RenderProcessHostImpl::GetAudioOutputControllers( |
2495 const GetAudioOutputControllersCallback& callback) const { | 2534 const GetAudioOutputControllersCallback& callback) const { |
2496 audio_renderer_host()->GetOutputControllers(callback); | 2535 audio_renderer_host()->GetOutputControllers(callback); |
2497 } | 2536 } |
2498 | 2537 |
2499 } // namespace content | 2538 } // namespace content |
OLD | NEW |