Index: content/browser/tab_contents/navigation_controller_impl.cc |
diff --git a/content/browser/tab_contents/navigation_controller_impl.cc b/content/browser/tab_contents/navigation_controller_impl.cc |
index 05dbda2beb22a0fe5a5901ab0c4294a86b838874..aa5bd8e89338dd16e0c0a8b6896a860c668e7354 100644 |
--- a/content/browser/tab_contents/navigation_controller_impl.cc |
+++ b/content/browser/tab_contents/navigation_controller_impl.cc |
@@ -266,9 +266,31 @@ void NavigationControllerImpl::ReloadInternal(bool check_for_repost, |
} else { |
DiscardNonCommittedEntriesInternal(); |
- pending_entry_index_ = current_index; |
- entries_[pending_entry_index_]->SetTransitionType( |
- content::PAGE_TRANSITION_RELOAD); |
+ NavigationEntryImpl* entry = entries_[current_index].get(); |
+ SiteInstanceImpl* site_instance = entry->site_instance(); |
+ DCHECK(site_instance); |
+ |
+ // If we are reloading an entry that no longer belongs to the current |
+ // site instance (for example, refreshing a page for just installed app), |
+ // the reload must happen in a new process. |
+ // The new entry must have a new page_id and site instance, so it behaves |
+ // as new navigation (which happens to clear forward history). |
+ if (site_instance->HasWrongProcessForURL(entry->GetURL())) { |
+ // Create a navigation entry that resembles the current one, but do not |
+ // copy page id, site instance, and content state. |
+ NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry( |
+ CreateNavigationEntry( |
+ entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(), |
+ false, entry->extra_headers(), browser_context_)); |
+ |
+ nav_entry->set_is_cross_site_reload(true); |
+ pending_entry_ = nav_entry; |
+ } else { |
+ pending_entry_index_ = current_index; |
+ entries_[pending_entry_index_]->SetTransitionType( |
+ content::PAGE_TRANSITION_RELOAD); |
+ } |
+ |
NavigateToPendingEntry(reload_type); |
} |
} |
@@ -583,6 +605,13 @@ bool NavigationControllerImpl::RendererDidNavigate( |
// assigned one in NavigateToPendingEntry. |
DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); |
+ // If we are doing a cross-site reload, we need to replace the existing |
+ // navigation entry, not add another entry to the history. This has the side |
+ // effect of removing forward browsing history, if such existed. |
+ if (pending_entry_ != NULL) { |
+ details->did_replace_entry = pending_entry_->is_cross_site_reload(); |
+ } |
+ |
// is_in_page must be computed before the entry gets committed. |
details->is_in_page = IsURLInPageNavigation(params.url); |