Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 177863002: Refactor configuration of sandboxes - first steps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments from jam@ Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DCHECK(context); 277 DCHECK(context);
278 SiteProcessMap* map = static_cast<SiteProcessMap*>( 278 SiteProcessMap* map = static_cast<SiteProcessMap*>(
279 context->GetUserData(kSiteProcessMapKeyName)); 279 context->GetUserData(kSiteProcessMapKeyName));
280 if (!map) { 280 if (!map) {
281 map = new SiteProcessMap(); 281 map = new SiteProcessMap();
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)
288 // NOTE: changes to this class need to be reviewed by the security team. 287 // NOTE: changes to this class need to be reviewed by the security team.
289 class RendererSandboxedProcessLauncherDelegate 288 class RendererSandboxedProcessLauncherDelegate
290 : public content::SandboxedProcessLauncherDelegate { 289 : public content::SandboxedProcessLauncherDelegate {
291 public: 290 public:
292 RendererSandboxedProcessLauncherDelegate() {} 291 RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel)
292 #if defined(OS_POSIX)
293 : ipc_fd_(channel->TakeClientFileDescriptor())
294 #endif // OS_POSIX
295 {}
296
293 virtual ~RendererSandboxedProcessLauncherDelegate() {} 297 virtual ~RendererSandboxedProcessLauncherDelegate() {}
294 298
299 #if defined(OS_WIN)
295 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, 300 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy,
296 bool* success) { 301 bool* success) {
297 AddBaseHandleClosePolicy(policy); 302 AddBaseHandleClosePolicy(policy);
298 GetContentClient()->browser()->PreSpawnRenderer(policy, success); 303 GetContentClient()->browser()->PreSpawnRenderer(policy, success);
299 } 304 }
305
306 #elif defined(OS_POSIX)
307 virtual bool ShouldUseZygote() OVERRIDE {
308 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
309 CommandLine::StringType renderer_prefix =
310 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
311 return renderer_prefix.empty();
312 }
313 virtual int GetIpcFd() OVERRIDE {
314 return ipc_fd_;
315 }
316
317 #endif // OS_WIN
jam 2014/02/28 18:07:43 nit: blank line before private
aberent 2014/02/28 21:17:28 Done.
318 private:
319 #if defined(OS_POSIX)
320 int ipc_fd_;
321 #endif // OS_POSIX
300 }; 322 };
301 #endif // OS_WIN
302 323
303 } // namespace 324 } // namespace
304 325
305 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 326 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
306 327
307 void RenderProcessHost::RegisterRendererMainThreadFactory( 328 void RenderProcessHost::RegisterRendererMainThreadFactory(
308 RendererMainThreadFactoryFunction create) { 329 RendererMainThreadFactoryFunction create) {
309 g_renderer_main_thread_factory = create; 330 g_renderer_main_thread_factory = create;
310 } 331 }
311 332
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 CommandLine* cmd_line = new CommandLine(renderer_path); 578 CommandLine* cmd_line = new CommandLine(renderer_path);
558 if (!renderer_prefix.empty()) 579 if (!renderer_prefix.empty())
559 cmd_line->PrependWrapper(renderer_prefix); 580 cmd_line->PrependWrapper(renderer_prefix);
560 AppendRendererCommandLine(cmd_line); 581 AppendRendererCommandLine(cmd_line);
561 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 582 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
562 583
563 // Spawn the child process asynchronously to avoid blocking the UI thread. 584 // 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 585 // As long as there's no renderer prefix, we can use the zygote process
565 // at this stage. 586 // at this stage.
566 child_process_launcher_.reset(new ChildProcessLauncher( 587 child_process_launcher_.reset(new ChildProcessLauncher(
567 #if defined(OS_WIN) 588 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, 589 cmd_line,
576 GetID(), 590 GetID(),
577 this)); 591 this));
578 592
579 fast_shutdown_started_ = false; 593 fast_shutdown_started_ = false;
580 } 594 }
581 595
582 if (!gpu_observer_registered_) { 596 if (!gpu_observer_registered_) {
583 gpu_observer_registered_ = true; 597 gpu_observer_registered_ = true;
584 GpuDataManagerImpl::GetInstance()->AddObserver(this); 598 GpuDataManagerImpl::GetInstance()->AddObserver(this);
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 return; 2085 return;
2072 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); 2086 Send(new MediaStreamMsg_EnableAecDump(file_for_transit));
2073 } 2087 }
2074 2088
2075 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2089 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2076 Send(new MediaStreamMsg_DisableAecDump()); 2090 Send(new MediaStreamMsg_DisableAecDump());
2077 } 2091 }
2078 #endif 2092 #endif
2079 2093
2080 } // namespace content 2094 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698