| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 bool g_run_renderer_in_process_ = false; | 384 bool g_run_renderer_in_process_ = false; |
| 385 | 385 |
| 386 // static | 386 // static |
| 387 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 387 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
| 388 g_max_renderer_count_override = count; | 388 g_max_renderer_count_override = count; |
| 389 } | 389 } |
| 390 | 390 |
| 391 RenderProcessHostImpl::RenderProcessHostImpl( | 391 RenderProcessHostImpl::RenderProcessHostImpl( |
| 392 BrowserContext* browser_context, | 392 BrowserContext* browser_context, |
| 393 StoragePartitionImpl* storage_partition_impl, | 393 StoragePartitionImpl* storage_partition_impl, |
| 394 bool is_guest) | 394 bool is_isolated_guest) |
| 395 : fast_shutdown_started_(false), | 395 : fast_shutdown_started_(false), |
| 396 deleting_soon_(false), | 396 deleting_soon_(false), |
| 397 #ifndef NDEBUG | 397 #ifndef NDEBUG |
| 398 is_self_deleted_(false), | 398 is_self_deleted_(false), |
| 399 #endif | 399 #endif |
| 400 pending_views_(0), | 400 pending_views_(0), |
| 401 mojo_activation_required_(false), | 401 mojo_activation_required_(false), |
| 402 visible_widgets_(0), | 402 visible_widgets_(0), |
| 403 backgrounded_(true), | 403 backgrounded_(true), |
| 404 is_initialized_(false), | 404 is_initialized_(false), |
| 405 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 405 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 406 browser_context_(browser_context), | 406 browser_context_(browser_context), |
| 407 storage_partition_impl_(storage_partition_impl), | 407 storage_partition_impl_(storage_partition_impl), |
| 408 sudden_termination_allowed_(true), | 408 sudden_termination_allowed_(true), |
| 409 ignore_input_events_(false), | 409 ignore_input_events_(false), |
| 410 is_guest_(is_guest), | 410 is_isolated_guest_(is_isolated_guest), |
| 411 gpu_observer_registered_(false), | 411 gpu_observer_registered_(false), |
| 412 delayed_cleanup_needed_(false), | 412 delayed_cleanup_needed_(false), |
| 413 within_process_died_observer_(false), | 413 within_process_died_observer_(false), |
| 414 power_monitor_broadcaster_(this), | 414 power_monitor_broadcaster_(this), |
| 415 screen_orientation_dispatcher_host_(NULL), | 415 screen_orientation_dispatcher_host_(NULL), |
| 416 worker_ref_count_(0), | 416 worker_ref_count_(0), |
| 417 weak_factory_(this) { | 417 weak_factory_(this) { |
| 418 widget_helper_ = new RenderWidgetHelper(); | 418 widget_helper_ = new RenderWidgetHelper(); |
| 419 | 419 |
| 420 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 420 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 if (visible_widgets_ == 0) { | 933 if (visible_widgets_ == 0) { |
| 934 DCHECK(!backgrounded_); | 934 DCHECK(!backgrounded_); |
| 935 SetBackgrounded(true); | 935 SetBackgrounded(true); |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 int RenderProcessHostImpl::VisibleWidgetCount() const { | 939 int RenderProcessHostImpl::VisibleWidgetCount() const { |
| 940 return visible_widgets_; | 940 return visible_widgets_; |
| 941 } | 941 } |
| 942 | 942 |
| 943 bool RenderProcessHostImpl::IsGuest() const { | 943 bool RenderProcessHostImpl::IsIsolatedGuest() const { |
| 944 return is_guest_; | 944 return is_isolated_guest_; |
| 945 } | 945 } |
| 946 | 946 |
| 947 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { | 947 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { |
| 948 return storage_partition_impl_; | 948 return storage_partition_impl_; |
| 949 } | 949 } |
| 950 | 950 |
| 951 static void AppendCompositorCommandLineFlags(CommandLine* command_line) { | 951 static void AppendCompositorCommandLineFlags(CommandLine* command_line) { |
| 952 if (IsPinchVirtualViewportEnabled()) | 952 if (IsPinchVirtualViewportEnabled()) |
| 953 command_line->AppendSwitch(cc::switches::kEnablePinchVirtualViewport); | 953 command_line->AppendSwitch(cc::switches::kEnablePinchVirtualViewport); |
| 954 | 954 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 | 1576 |
| 1577 if (url->SchemeIs(kAboutScheme)) { | 1577 if (url->SchemeIs(kAboutScheme)) { |
| 1578 // The renderer treats all URLs in the about: scheme as being about:blank. | 1578 // The renderer treats all URLs in the about: scheme as being about:blank. |
| 1579 // Canonicalize about: URLs to about:blank. | 1579 // Canonicalize about: URLs to about:blank. |
| 1580 *url = GURL(kAboutBlankURL); | 1580 *url = GURL(kAboutBlankURL); |
| 1581 RecordAction(base::UserMetricsAction("FilterURLTermiate_About")); | 1581 RecordAction(base::UserMetricsAction("FilterURLTermiate_About")); |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 // Do not allow browser plugin guests to navigate to non-web URLs, since they | 1584 // Do not allow browser plugin guests to navigate to non-web URLs, since they |
| 1585 // cannot swap processes or grant bindings. | 1585 // cannot swap processes or grant bindings. |
| 1586 bool non_web_url_in_guest = rph->IsGuest() && | 1586 bool non_web_url_in_guest = rph->IsIsolatedGuest() && |
| 1587 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); | 1587 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); |
| 1588 | 1588 |
| 1589 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { | 1589 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { |
| 1590 // If this renderer is not permitted to request this URL, we invalidate the | 1590 // If this renderer is not permitted to request this URL, we invalidate the |
| 1591 // URL. This prevents us from storing the blocked URL and becoming confused | 1591 // URL. This prevents us from storing the blocked URL and becoming confused |
| 1592 // later. | 1592 // later. |
| 1593 VLOG(1) << "Blocked URL " << url->spec(); | 1593 VLOG(1) << "Blocked URL " << url->spec(); |
| 1594 *url = GURL(kAboutBlankURL); | 1594 *url = GURL(kAboutBlankURL); |
| 1595 RecordAction(base::UserMetricsAction("FilterURLTermiate_Blocked")); | 1595 RecordAction(base::UserMetricsAction("FilterURLTermiate_Blocked")); |
| 1596 } | 1596 } |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 // static | 1599 // static |
| 1600 bool RenderProcessHostImpl::IsSuitableHost( | 1600 bool RenderProcessHostImpl::IsSuitableHost( |
| 1601 RenderProcessHost* host, | 1601 RenderProcessHost* host, |
| 1602 BrowserContext* browser_context, | 1602 BrowserContext* browser_context, |
| 1603 const GURL& site_url) { | 1603 const GURL& site_url) { |
| 1604 if (run_renderer_in_process()) | 1604 if (run_renderer_in_process()) |
| 1605 return true; | 1605 return true; |
| 1606 | 1606 |
| 1607 if (host->GetBrowserContext() != browser_context) | 1607 if (host->GetBrowserContext() != browser_context) |
| 1608 return false; | 1608 return false; |
| 1609 | 1609 |
| 1610 // Do not allow sharing of guest hosts. This is to prevent bugs where guest | 1610 // Do not allow sharing of guest hosts. This is to prevent bugs where guest |
| 1611 // and non-guest storage gets mixed. In the future, we might consider enabling | 1611 // and non-guest storage gets mixed. In the future, we might consider enabling |
| 1612 // the sharing of guests, in this case this check should be removed and | 1612 // the sharing of guests, in this case this check should be removed and |
| 1613 // InSameStoragePartition should handle the possible sharing. | 1613 // InSameStoragePartition should handle the possible sharing. |
| 1614 if (host->IsGuest()) | 1614 if (host->IsIsolatedGuest()) |
| 1615 return false; | 1615 return false; |
| 1616 | 1616 |
| 1617 // Check whether the given host and the intended site_url will be using the | 1617 // Check whether the given host and the intended site_url will be using the |
| 1618 // same StoragePartition, since a RenderProcessHost can only support a single | 1618 // same StoragePartition, since a RenderProcessHost can only support a single |
| 1619 // StoragePartition. This is relevant for packaged apps and isolated sites. | 1619 // StoragePartition. This is relevant for packaged apps and isolated sites. |
| 1620 StoragePartition* dest_partition = | 1620 StoragePartition* dest_partition = |
| 1621 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); | 1621 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); |
| 1622 if (!host->InSameStoragePartition(dest_partition)) | 1622 if (!host->InSameStoragePartition(dest_partition)) |
| 1623 return false; | 1623 return false; |
| 1624 | 1624 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 mojo::ScopedMessagePipeHandle handle) { | 2072 mojo::ScopedMessagePipeHandle handle) { |
| 2073 mojo_activation_required_ = true; | 2073 mojo_activation_required_ = true; |
| 2074 MaybeActivateMojo(); | 2074 MaybeActivateMojo(); |
| 2075 | 2075 |
| 2076 mojo::AllocationScope scope; | 2076 mojo::AllocationScope scope; |
| 2077 mojo_application_host_->shell_client()->AcceptConnection(service_name, | 2077 mojo_application_host_->shell_client()->AcceptConnection(service_name, |
| 2078 handle.Pass()); | 2078 handle.Pass()); |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 } // namespace content | 2081 } // namespace content |
| OLD | NEW |