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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 | 1577 |
1578 if (url->SchemeIs(kAboutScheme)) { | 1578 if (url->SchemeIs(kAboutScheme)) { |
1579 // The renderer treats all URLs in the about: scheme as being about:blank. | 1579 // The renderer treats all URLs in the about: scheme as being about:blank. |
1580 // Canonicalize about: URLs to about:blank. | 1580 // Canonicalize about: URLs to about:blank. |
1581 *url = GURL(kAboutBlankURL); | 1581 *url = GURL(kAboutBlankURL); |
1582 RecordAction(base::UserMetricsAction("FilterURLTermiate_About")); | 1582 RecordAction(base::UserMetricsAction("FilterURLTermiate_About")); |
1583 } | 1583 } |
1584 | 1584 |
1585 // Do not allow browser plugin guests to navigate to non-web URLs, since they | 1585 // Do not allow browser plugin guests to navigate to non-web URLs, since they |
1586 // cannot swap processes or grant bindings. | 1586 // cannot swap processes or grant bindings. |
1587 bool non_web_url_in_guest = rph->IsGuest() && | 1587 bool non_web_url_in_guest = rph->IsIsolatedGuest() && |
1588 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); | 1588 !(url->is_valid() && policy->IsWebSafeScheme(url->scheme())); |
1589 | 1589 |
1590 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { | 1590 if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) { |
1591 // If this renderer is not permitted to request this URL, we invalidate the | 1591 // If this renderer is not permitted to request this URL, we invalidate the |
1592 // URL. This prevents us from storing the blocked URL and becoming confused | 1592 // URL. This prevents us from storing the blocked URL and becoming confused |
1593 // later. | 1593 // later. |
1594 VLOG(1) << "Blocked URL " << url->spec(); | 1594 VLOG(1) << "Blocked URL " << url->spec(); |
1595 *url = GURL(kAboutBlankURL); | 1595 *url = GURL(kAboutBlankURL); |
1596 RecordAction(base::UserMetricsAction("FilterURLTermiate_Blocked")); | 1596 RecordAction(base::UserMetricsAction("FilterURLTermiate_Blocked")); |
1597 } | 1597 } |
1598 } | 1598 } |
1599 | 1599 |
1600 // static | 1600 // static |
1601 bool RenderProcessHostImpl::IsSuitableHost( | 1601 bool RenderProcessHostImpl::IsSuitableHost( |
1602 RenderProcessHost* host, | 1602 RenderProcessHost* host, |
1603 BrowserContext* browser_context, | 1603 BrowserContext* browser_context, |
1604 const GURL& site_url) { | 1604 const GURL& site_url) { |
1605 if (run_renderer_in_process()) | 1605 if (run_renderer_in_process()) |
1606 return true; | 1606 return true; |
1607 | 1607 |
1608 if (host->GetBrowserContext() != browser_context) | 1608 if (host->GetBrowserContext() != browser_context) |
1609 return false; | 1609 return false; |
1610 | 1610 |
1611 // Do not allow sharing of guest hosts. This is to prevent bugs where guest | 1611 // Do not allow sharing of guest hosts. This is to prevent bugs where guest |
1612 // and non-guest storage gets mixed. In the future, we might consider enabling | 1612 // and non-guest storage gets mixed. In the future, we might consider enabling |
1613 // the sharing of guests, in this case this check should be removed and | 1613 // the sharing of guests, in this case this check should be removed and |
1614 // InSameStoragePartition should handle the possible sharing. | 1614 // InSameStoragePartition should handle the possible sharing. |
1615 if (host->IsGuest()) | 1615 if (host->IsIsolatedGuest()) |
1616 return false; | 1616 return false; |
1617 | 1617 |
1618 // Check whether the given host and the intended site_url will be using the | 1618 // Check whether the given host and the intended site_url will be using the |
1619 // same StoragePartition, since a RenderProcessHost can only support a single | 1619 // same StoragePartition, since a RenderProcessHost can only support a single |
1620 // StoragePartition. This is relevant for packaged apps and isolated sites. | 1620 // StoragePartition. This is relevant for packaged apps and isolated sites. |
1621 StoragePartition* dest_partition = | 1621 StoragePartition* dest_partition = |
1622 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); | 1622 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); |
1623 if (!host->InSameStoragePartition(dest_partition)) | 1623 if (!host->InSameStoragePartition(dest_partition)) |
1624 return false; | 1624 return false; |
1625 | 1625 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 mojo::ScopedMessagePipeHandle handle) { | 2073 mojo::ScopedMessagePipeHandle handle) { |
2074 mojo_activation_required_ = true; | 2074 mojo_activation_required_ = true; |
2075 MaybeActivateMojo(); | 2075 MaybeActivateMojo(); |
2076 | 2076 |
2077 mojo::AllocationScope scope; | 2077 mojo::AllocationScope scope; |
2078 mojo_application_host_->shell_client()->AcceptConnection(service_name, | 2078 mojo_application_host_->shell_client()->AcceptConnection(service_name, |
2079 handle.Pass()); | 2079 handle.Pass()); |
2080 } | 2080 } |
2081 | 2081 |
2082 } // namespace content | 2082 } // namespace content |
OLD | NEW |