OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 // we compare against the last successful commit when deciding whether to swap | 1602 // we compare against the last successful commit when deciding whether to swap |
1603 // this time. | 1603 // this time. |
1604 if (SiteInstance::IsSameWebSite(browser_context, | 1604 if (SiteInstance::IsSameWebSite(browser_context, |
1605 candidate->last_successful_url(), dest_url)) { | 1605 candidate->last_successful_url(), dest_url)) { |
1606 return true; | 1606 return true; |
1607 } | 1607 } |
1608 | 1608 |
1609 // It is possible that last_successful_url() was a nonstandard scheme (for | 1609 // It is possible that last_successful_url() was a nonstandard scheme (for |
1610 // example, "about:blank"). If so, examine the replicated origin to determine | 1610 // example, "about:blank"). If so, examine the replicated origin to determine |
1611 // the site. | 1611 // the site. |
1612 if (!candidate->GetLastCommittedOrigin().unique() && | 1612 if (!candidate->GetLastCommittedOrigin().opaque() && |
1613 SiteInstance::IsSameWebSite( | 1613 SiteInstance::IsSameWebSite( |
1614 browser_context, | 1614 browser_context, |
1615 GURL(candidate->GetLastCommittedOrigin().Serialize()), dest_url)) { | 1615 GURL(candidate->GetLastCommittedOrigin().Serialize()), dest_url)) { |
1616 return true; | 1616 return true; |
1617 } | 1617 } |
1618 | 1618 |
1619 // Not same-site. | 1619 // Not same-site. |
1620 return false; | 1620 return false; |
1621 } | 1621 } |
1622 | 1622 |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2753 // and the frame being navigated differ, |source_instance| is set to the | 2753 // and the frame being navigated differ, |source_instance| is set to the |
2754 // SiteInstance of the initiating frame. |dest_instance| is present on session | 2754 // SiteInstance of the initiating frame. |dest_instance| is present on session |
2755 // history navigations. The two cannot be set simultaneously. | 2755 // history navigations. The two cannot be set simultaneously. |
2756 DCHECK(!source_instance || !dest_instance); | 2756 DCHECK(!source_instance || !dest_instance); |
2757 | 2757 |
2758 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can | 2758 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can |
2759 // get here in tests for subframes (e.g., NavigateFrameToURL). | 2759 // get here in tests for subframes (e.g., NavigateFrameToURL). |
2760 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 2760 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
2761 return false; | 2761 return false; |
2762 | 2762 |
2763 // If dest_url is a unique origin like about:blank, then the need for a swap | 2763 // If dest_url is an opaque origin like about:blank, then the need for a swap |
2764 // is determined by the source_instance or dest_instance. | 2764 // is determined by the source_instance or dest_instance. |
2765 GURL resolved_url = dest_url; | 2765 GURL resolved_url = dest_url; |
2766 if (url::Origin(resolved_url).unique()) { | 2766 if (url::Origin(resolved_url).opaque()) { |
2767 if (source_instance) { | 2767 if (source_instance) { |
2768 resolved_url = source_instance->GetSiteURL(); | 2768 resolved_url = source_instance->GetSiteURL(); |
2769 } else if (dest_instance) { | 2769 } else if (dest_instance) { |
2770 resolved_url = dest_instance->GetSiteURL(); | 2770 resolved_url = dest_instance->GetSiteURL(); |
2771 } else { | 2771 } else { |
2772 // If there is no SiteInstance this unique origin can be associated with, | 2772 // If there is no SiteInstance this opaque origin can be associated with, |
2773 // then we should avoid a process swap. | 2773 // then we should avoid a process swap. |
2774 return false; | 2774 return false; |
2775 } | 2775 } |
2776 } | 2776 } |
2777 | 2777 |
2778 // If we are in an OOPIF mode that only applies to some sites, only swap if | 2778 // If we are in an OOPIF mode that only applies to some sites, only swap if |
2779 // the policy determines that a transfer would have been needed. We can get | 2779 // the policy determines that a transfer would have been needed. We can get |
2780 // here for session restore. | 2780 // here for session restore. |
2781 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), | 2781 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), |
2782 resolved_url)) { | 2782 resolved_url)) { |
2783 DCHECK(!dest_instance || | 2783 DCHECK(!dest_instance || |
2784 dest_instance == render_frame_host_->GetSiteInstance()); | 2784 dest_instance == render_frame_host_->GetSiteInstance()); |
2785 return false; | 2785 return false; |
2786 } | 2786 } |
2787 | 2787 |
2788 return true; | 2788 return true; |
2789 } | 2789 } |
2790 | 2790 |
2791 } // namespace content | 2791 } // namespace content |
OLD | NEW |