OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 VisitedLinkCommon::Fingerprints pending_; | 231 VisitedLinkCommon::Fingerprints pending_; |
232 }; | 232 }; |
233 | 233 |
234 namespace { | 234 namespace { |
235 | 235 |
236 // Helper class that we pass to ResourceMessageFilter so that it can find the | 236 // Helper class that we pass to ResourceMessageFilter so that it can find the |
237 // right net::URLRequestContext for a request. | 237 // right net::URLRequestContext for a request. |
238 class RendererURLRequestContextOverride | 238 class RendererURLRequestContextOverride |
239 : public ResourceMessageFilter::URLRequestContextOverride { | 239 : public ResourceMessageFilter::URLRequestContextOverride { |
240 public: | 240 public: |
241 explicit RendererURLRequestContextOverride(Profile* profile) | 241 RendererURLRequestContextOverride(Profile* profile, |
242 : request_context_(profile->GetRequestContext()), | 242 const Extension* installed_app) |
| 243 : request_context_(profile->GetRequestContextForPossibleApp( |
| 244 installed_app)), |
243 media_request_context_(profile->GetRequestContextForMedia()) { | 245 media_request_context_(profile->GetRequestContextForMedia()) { |
244 } | 246 } |
245 | 247 |
246 virtual net::URLRequestContext* GetRequestContext( | 248 virtual net::URLRequestContext* GetRequestContext( |
247 const ViewHostMsg_Resource_Request& resource_request) { | 249 const ViewHostMsg_Resource_Request& resource_request) { |
248 URLRequestContextGetter* request_context = request_context_; | 250 URLRequestContextGetter* request_context = request_context_; |
249 // If the request has resource type of ResourceType::MEDIA, we use a request | 251 // If the request has resource type of ResourceType::MEDIA, we use a request |
250 // context specific to media for handling it because these resources have | 252 // context specific to media for handling it because these resources have |
251 // specific needs for caching. | 253 // specific needs for caching. |
252 if (resource_request.resource_type == ResourceType::MEDIA) | 254 if (resource_request.resource_type == ResourceType::MEDIA) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 channel_.reset(); | 330 channel_.reset(); |
329 while (!queued_messages_.empty()) { | 331 while (!queued_messages_.empty()) { |
330 delete queued_messages_.front(); | 332 delete queued_messages_.front(); |
331 queued_messages_.pop(); | 333 queued_messages_.pop(); |
332 } | 334 } |
333 | 335 |
334 ClearTransportDIBCache(); | 336 ClearTransportDIBCache(); |
335 } | 337 } |
336 | 338 |
337 bool BrowserRenderProcessHost::Init( | 339 bool BrowserRenderProcessHost::Init( |
338 bool is_accessibility_enabled, bool is_extensions_process) { | 340 bool is_accessibility_enabled, bool is_extensions_process, |
| 341 const Extension* installed_app) { |
339 // calling Init() more than once does nothing, this makes it more convenient | 342 // calling Init() more than once does nothing, this makes it more convenient |
340 // for the view host which may not be sure in some cases | 343 // for the view host which may not be sure in some cases |
341 if (channel_.get()) | 344 if (channel_.get()) |
342 return true; | 345 return true; |
343 | 346 |
344 accessibility_enabled_ = is_accessibility_enabled; | 347 accessibility_enabled_ = is_accessibility_enabled; |
345 | 348 |
346 // It is possible for an extension process to be reused for non-extension | 349 // It is possible for an extension process to be reused for non-extension |
347 // content, e.g. if an extension calls window.open. | 350 // content, e.g. if an extension calls window.open. |
348 extension_process_ = extension_process_ || is_extensions_process; | 351 extension_process_ = extension_process_ || is_extensions_process; |
349 | 352 |
| 353 // Keep track of the installed app for this process, if any. |
| 354 installed_app_ = installed_app; |
| 355 |
350 // run the IPC channel on the shared IO thread. | 356 // run the IPC channel on the shared IO thread. |
351 base::Thread* io_thread = g_browser_process->io_thread(); | 357 base::Thread* io_thread = g_browser_process->io_thread(); |
352 | 358 |
353 CommandLine::StringType renderer_prefix; | 359 CommandLine::StringType renderer_prefix; |
354 #if defined(OS_POSIX) | 360 #if defined(OS_POSIX) |
355 // A command prefix is something prepended to the command line of the spawned | 361 // A command prefix is something prepended to the command line of the spawned |
356 // process. It is supported only on POSIX systems. | 362 // process. It is supported only on POSIX systems. |
357 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 363 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
358 renderer_prefix = | 364 renderer_prefix = |
359 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 365 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 434 } |
429 | 435 |
430 return true; | 436 return true; |
431 } | 437 } |
432 | 438 |
433 void BrowserRenderProcessHost::CreateMessageFilters() { | 439 void BrowserRenderProcessHost::CreateMessageFilters() { |
434 scoped_refptr<RenderMessageFilter> render_message_filter( | 440 scoped_refptr<RenderMessageFilter> render_message_filter( |
435 new RenderMessageFilter(id(), | 441 new RenderMessageFilter(id(), |
436 PluginService::GetInstance(), | 442 PluginService::GetInstance(), |
437 profile(), | 443 profile(), |
438 widget_helper_)); | 444 widget_helper_, |
| 445 installed_app_)); |
439 channel_->AddFilter(render_message_filter); | 446 channel_->AddFilter(render_message_filter); |
440 | 447 |
441 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( | 448 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( |
442 new RendererURLRequestContextOverride(profile())); | 449 new RendererURLRequestContextOverride(profile(), installed_app_)); |
443 | 450 |
444 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 451 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
445 id(), ChildProcessInfo::RENDER_PROCESS, | 452 id(), ChildProcessInfo::RENDER_PROCESS, |
446 g_browser_process->resource_dispatcher_host()); | 453 g_browser_process->resource_dispatcher_host()); |
447 resource_message_filter->set_url_request_context_override( | 454 resource_message_filter->set_url_request_context_override( |
448 url_request_context_override); | 455 url_request_context_override); |
449 channel_->AddFilter(resource_message_filter); | 456 channel_->AddFilter(resource_message_filter); |
450 | 457 |
451 channel_->AddFilter(new AudioRendererHost()); | 458 channel_->AddFilter(new AudioRendererHost()); |
452 channel_->AddFilter( | 459 channel_->AddFilter( |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 IPC::PlatformFileForTransit file; | 1289 IPC::PlatformFileForTransit file; |
1283 #if defined(OS_POSIX) | 1290 #if defined(OS_POSIX) |
1284 file = base::FileDescriptor(model_file, false); | 1291 file = base::FileDescriptor(model_file, false); |
1285 #elif defined(OS_WIN) | 1292 #elif defined(OS_WIN) |
1286 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1293 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
1287 false, DUPLICATE_SAME_ACCESS); | 1294 false, DUPLICATE_SAME_ACCESS); |
1288 #endif | 1295 #endif |
1289 Send(new ViewMsg_SetPhishingModel(file)); | 1296 Send(new ViewMsg_SetPhishingModel(file)); |
1290 } | 1297 } |
1291 } | 1298 } |
OLD | NEW |