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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 #include "content/public/browser/render_process_host_factory.h" | 119 #include "content/public/browser/render_process_host_factory.h" |
120 #include "content/public/browser/render_process_host_observer.h" | 120 #include "content/public/browser/render_process_host_observer.h" |
121 #include "content/public/browser/render_widget_host.h" | 121 #include "content/public/browser/render_widget_host.h" |
122 #include "content/public/browser/render_widget_host_iterator.h" | 122 #include "content/public/browser/render_widget_host_iterator.h" |
123 #include "content/public/browser/resource_context.h" | 123 #include "content/public/browser/resource_context.h" |
124 #include "content/public/browser/user_metrics.h" | 124 #include "content/public/browser/user_metrics.h" |
125 #include "content/public/common/content_constants.h" | 125 #include "content/public/common/content_constants.h" |
126 #include "content/public/common/content_switches.h" | 126 #include "content/public/common/content_switches.h" |
127 #include "content/public/common/process_type.h" | 127 #include "content/public/common/process_type.h" |
128 #include "content/public/common/result_codes.h" | 128 #include "content/public/common/result_codes.h" |
129 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
129 #include "content/public/common/url_constants.h" | 130 #include "content/public/common/url_constants.h" |
130 #include "gpu/command_buffer/service/gpu_switches.h" | 131 #include "gpu/command_buffer/service/gpu_switches.h" |
131 #include "ipc/ipc_channel.h" | 132 #include "ipc/ipc_channel.h" |
132 #include "ipc/ipc_logging.h" | 133 #include "ipc/ipc_logging.h" |
133 #include "ipc/ipc_switches.h" | 134 #include "ipc/ipc_switches.h" |
134 #include "media/base/media_switches.h" | 135 #include "media/base/media_switches.h" |
135 #include "net/url_request/url_request_context_getter.h" | 136 #include "net/url_request/url_request_context_getter.h" |
136 #include "ppapi/shared_impl/ppapi_switches.h" | 137 #include "ppapi/shared_impl/ppapi_switches.h" |
137 #include "ui/base/ui_base_switches.h" | 138 #include "ui/base/ui_base_switches.h" |
138 #include "ui/events/event_switches.h" | 139 #include "ui/events/event_switches.h" |
139 #include "ui/gfx/switches.h" | 140 #include "ui/gfx/switches.h" |
140 #include "ui/gl/gl_switches.h" | 141 #include "ui/gl/gl_switches.h" |
141 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 142 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
142 #include "webkit/common/resource_type.h" | 143 #include "webkit/common/resource_type.h" |
143 | 144 |
144 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
145 #include "base/win/scoped_com_initializer.h" | 146 #include "base/win/scoped_com_initializer.h" |
146 #include "content/common/font_cache_dispatcher_win.h" | 147 #include "content/common/font_cache_dispatcher_win.h" |
147 #include "content/common/sandbox_win.h" | 148 #include "content/common/sandbox_win.h" |
148 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
149 #endif | 149 #endif |
150 | 150 |
151 #if defined(ENABLE_WEBRTC) | 151 #if defined(ENABLE_WEBRTC) |
152 #include "content/browser/media/webrtc_internals.h" | 152 #include "content/browser/media/webrtc_internals.h" |
153 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 153 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
154 #include "content/common/media/media_stream_messages.h" | 154 #include "content/common/media/media_stream_messages.h" |
155 #endif | 155 #endif |
156 | 156 |
157 #include "third_party/skia/include/core/SkBitmap.h" | 157 #include "third_party/skia/include/core/SkBitmap.h" |
158 | 158 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 context->SetUserData(kSiteProcessMapKeyName, map); | 282 context->SetUserData(kSiteProcessMapKeyName, map); |
283 } | 283 } |
284 return map; | 284 return map; |
285 } | 285 } |
286 | 286 |
287 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
288 // NOTE: changes to this class need to be reviewed by the security team. | 288 // NOTE: changes to this class need to be reviewed by the security team. |
289 class RendererSandboxedProcessLauncherDelegate | 289 class RendererSandboxedProcessLauncherDelegate |
290 : public content::SandboxedProcessLauncherDelegate { | 290 : public content::SandboxedProcessLauncherDelegate { |
291 public: | 291 public: |
292 RendererSandboxedProcessLauncherDelegate() {} | 292 RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* /*channel*/) {} |
293 virtual ~RendererSandboxedProcessLauncherDelegate() {} | 293 virtual ~RendererSandboxedProcessLauncherDelegate() {} |
294 | 294 |
295 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, | 295 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, |
296 bool* success) { | 296 bool* success) { |
297 AddBaseHandleClosePolicy(policy); | 297 AddBaseHandleClosePolicy(policy); |
298 GetContentClient()->browser()->PreSpawnRenderer(policy, success); | 298 GetContentClient()->browser()->PreSpawnRenderer(policy, success); |
299 } | 299 } |
300 private: | |
301 int ipc_fd_; | |
302 }; | |
303 | |
304 #elif defined(OS_POSIX) | |
305 | |
306 // NOTE: changes to this class need to be reviewed by the security team. | |
jam
2014/02/26 19:47:52
ditto
aberent
2014/02/28 08:51:07
Done.
| |
307 class RendererSandboxedProcessLauncherDelegate | |
308 : public content::SandboxedProcessLauncherDelegate { | |
309 public: | |
310 RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel) | |
311 : ipc_fd_(channel->TakeClientFileDescriptor()) {} | |
312 virtual ~RendererSandboxedProcessLauncherDelegate() {} | |
313 | |
314 virtual bool UseZygote() OVERRIDE { | |
315 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | |
316 CommandLine::StringType renderer_prefix = | |
317 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | |
318 return renderer_prefix.empty(); | |
319 } | |
320 virtual int IpcFd() OVERRIDE { | |
321 return ipc_fd_; | |
322 } | |
323 private: | |
324 int ipc_fd_; | |
300 }; | 325 }; |
301 #endif // OS_WIN | 326 #endif // OS_WIN |
302 | 327 |
303 } // namespace | 328 } // namespace |
304 | 329 |
305 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 330 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
306 | 331 |
307 void RenderProcessHost::RegisterRendererMainThreadFactory( | 332 void RenderProcessHost::RegisterRendererMainThreadFactory( |
308 RendererMainThreadFactoryFunction create) { | 333 RendererMainThreadFactoryFunction create) { |
309 g_renderer_main_thread_factory = create; | 334 g_renderer_main_thread_factory = create; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 CommandLine* cmd_line = new CommandLine(renderer_path); | 582 CommandLine* cmd_line = new CommandLine(renderer_path); |
558 if (!renderer_prefix.empty()) | 583 if (!renderer_prefix.empty()) |
559 cmd_line->PrependWrapper(renderer_prefix); | 584 cmd_line->PrependWrapper(renderer_prefix); |
560 AppendRendererCommandLine(cmd_line); | 585 AppendRendererCommandLine(cmd_line); |
561 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 586 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
562 | 587 |
563 // Spawn the child process asynchronously to avoid blocking the UI thread. | 588 // Spawn the child process asynchronously to avoid blocking the UI thread. |
564 // As long as there's no renderer prefix, we can use the zygote process | 589 // As long as there's no renderer prefix, we can use the zygote process |
565 // at this stage. | 590 // at this stage. |
566 child_process_launcher_.reset(new ChildProcessLauncher( | 591 child_process_launcher_.reset(new ChildProcessLauncher( |
567 #if defined(OS_WIN) | 592 new RendererSandboxedProcessLauncherDelegate(channel_.get()), |
568 new RendererSandboxedProcessLauncherDelegate, | |
569 false, | |
570 #elif defined(OS_POSIX) | |
571 renderer_prefix.empty(), | |
572 base::EnvironmentMap(), | |
573 channel_->TakeClientFileDescriptor(), | |
574 #endif | |
575 cmd_line, | 593 cmd_line, |
576 GetID(), | 594 GetID(), |
577 this)); | 595 this)); |
578 | 596 |
579 fast_shutdown_started_ = false; | 597 fast_shutdown_started_ = false; |
580 } | 598 } |
581 | 599 |
582 if (!gpu_observer_registered_) { | 600 if (!gpu_observer_registered_) { |
583 gpu_observer_registered_ = true; | 601 gpu_observer_registered_ = true; |
584 GpuDataManagerImpl::GetInstance()->AddObserver(this); | 602 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2071 return; | 2089 return; |
2072 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); | 2090 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); |
2073 } | 2091 } |
2074 | 2092 |
2075 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2093 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
2076 Send(new MediaStreamMsg_DisableAecDump()); | 2094 Send(new MediaStreamMsg_DisableAecDump()); |
2077 } | 2095 } |
2078 #endif | 2096 #endif |
2079 | 2097 |
2080 } // namespace content | 2098 } // namespace content |
OLD | NEW |