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 3c5ddeee33263d3ea536685549e4fd44ff255eb6..c798bc1f34d80291ffd9b5211c252b13f1d78a65 100644 |
--- a/content/browser/tab_contents/navigation_controller_impl.cc |
+++ b/content/browser/tab_contents/navigation_controller_impl.cc |
@@ -265,9 +265,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(); |
+ SiteInstance* site_instance = entry->site_instance(); |
+ DCHECK(site_instance); |
+ |
+ // If we are reloading an entry that no longer belongs to the current |
Charlie Reis
2012/01/26 21:49:45
Nit: belongs to -> belongs in
|
+ // 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); |
} |
} |
@@ -582,6 +604,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) { |
Charlie Reis
2012/01/26 21:49:45
Nit: no braces on a one line if.
|
+ 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); |