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..9c0ca52aa0bcf1230f90a2c66966bd617bc673fe 100644 |
--- a/content/browser/tab_contents/navigation_controller_impl.cc |
+++ b/content/browser/tab_contents/navigation_controller_impl.cc |
@@ -265,9 +265,29 @@ 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(); |
Charlie Reis
2012/01/26 01:20:23
GetEntryAtIndex
nasko
2012/01/26 20:25:57
I've used direct access to the collection, since I
Charlie Reis
2012/01/26 21:49:45
Ah. Yes, that's fine then. I've emailed John abo
|
+ SiteInstance* site_instance = entry->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 and behave as new navigation |
Charlie Reis
2012/01/26 01:20:23
Nit: let's split out the "behave as new navigation
nasko
2012/01/26 20:25:57
Done.
|
+ // when it comes to history. |
+ if (site_instance != NULL && |
Charlie Reis
2012/01/26 01:20:23
More common to drop the != NULL. And actually, sh
nasko
2012/01/26 20:25:57
Done.
|
+ site_instance->HasWrongProcessForURL(entry->GetURL())) { |
+ // Create a navigation entry that resembles the current one |
Charlie Reis
2012/01/26 01:20:23
Nit: perhaps mention which things must not be copi
nasko
2012/01/26 20:25:57
Done.
|
+ 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 +602,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(); |
Charlie Reis
2012/01/26 01:20:23
Nit: extra space.
|
+ } |
+ |
// is_in_page must be computed before the entry gets committed. |
details->is_in_page = IsURLInPageNavigation(params.url); |