Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: content/browser/tab_contents/navigation_controller_impl.cc

Issue 9169065: Reloading page after installing app should bring it into correct process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing initial code review comments. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | content/browser/tab_contents/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698