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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tab_contents/navigation_controller_impl.h" 5 #include "content/browser/tab_contents/navigation_controller_impl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" // Temporary 9 #include "base/string_number_conversions.h" // Temporary
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 content::NOTIFICATION_REPOST_WARNING_SHOWN, 258 content::NOTIFICATION_REPOST_WARNING_SHOWN,
259 content::Source<NavigationController>(this), 259 content::Source<NavigationController>(this),
260 content::NotificationService::NoDetails()); 260 content::NotificationService::NoDetails());
261 261
262 pending_reload_ = reload_type; 262 pending_reload_ = reload_type;
263 tab_contents_->Activate(); 263 tab_contents_->Activate();
264 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); 264 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_);
265 } else { 265 } else {
266 DiscardNonCommittedEntriesInternal(); 266 DiscardNonCommittedEntriesInternal();
267 267
268 pending_entry_index_ = current_index; 268 NavigationEntryImpl* entry = entries_[current_index].get();
269 entries_[pending_entry_index_]->SetTransitionType( 269 SiteInstance* site_instance = entry->site_instance();
270 content::PAGE_TRANSITION_RELOAD); 270 DCHECK(site_instance);
271
272 // 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
273 // site instance (for example, refreshing a page for just installed app),
274 // the reload must happen in a new process.
275 // The new entry must have a new page_id and site instance, so it behaves
276 // as new navigation (which happens to clear forward history).
277 if (site_instance->HasWrongProcessForURL(entry->GetURL())) {
278 // Create a navigation entry that resembles the current one, but do not
279 // copy page id, site instance, and content state.
280 NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry(
281 CreateNavigationEntry(
282 entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(),
283 false, entry->extra_headers(), browser_context_));
284
285 nav_entry->set_is_cross_site_reload(true);
286 pending_entry_ = nav_entry;
287 } else {
288 pending_entry_index_ = current_index;
289 entries_[pending_entry_index_]->SetTransitionType(
290 content::PAGE_TRANSITION_RELOAD);
291 }
292
271 NavigateToPendingEntry(reload_type); 293 NavigateToPendingEntry(reload_type);
272 } 294 }
273 } 295 }
274 296
275 void NavigationControllerImpl::CancelPendingReload() { 297 void NavigationControllerImpl::CancelPendingReload() {
276 DCHECK(pending_reload_ != NO_RELOAD); 298 DCHECK(pending_reload_ != NO_RELOAD);
277 pending_reload_ = NO_RELOAD; 299 pending_reload_ = NO_RELOAD;
278 } 300 }
279 301
280 void NavigationControllerImpl::ContinuePendingReload() { 302 void NavigationControllerImpl::ContinuePendingReload() {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } else { 597 } else {
576 details->previous_url = GURL(); 598 details->previous_url = GURL();
577 details->previous_entry_index = -1; 599 details->previous_entry_index = -1;
578 } 600 }
579 601
580 // If we have a pending entry at this point, it should have a SiteInstance. 602 // If we have a pending entry at this point, it should have a SiteInstance.
581 // Restored entries start out with a null SiteInstance, but we should have 603 // Restored entries start out with a null SiteInstance, but we should have
582 // assigned one in NavigateToPendingEntry. 604 // assigned one in NavigateToPendingEntry.
583 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); 605 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance());
584 606
607 // If we are doing a cross-site reload, we need to replace the existing
608 // navigation entry, not add another entry to the history. This has the side
609 // effect of removing forward browsing history, if such existed.
610 if (pending_entry_ != NULL) {
Charlie Reis 2012/01/26 21:49:45 Nit: no braces on a one line if.
611 details->did_replace_entry = pending_entry_->is_cross_site_reload();
612 }
613
585 // is_in_page must be computed before the entry gets committed. 614 // is_in_page must be computed before the entry gets committed.
586 details->is_in_page = IsURLInPageNavigation(params.url); 615 details->is_in_page = IsURLInPageNavigation(params.url);
587 616
588 // Do navigation-type specific actions. These will make and commit an entry. 617 // Do navigation-type specific actions. These will make and commit an entry.
589 details->type = ClassifyNavigation(params); 618 details->type = ClassifyNavigation(params);
590 619
591 switch (details->type) { 620 switch (details->type) {
592 case content::NAVIGATION_TYPE_NEW_PAGE: 621 case content::NAVIGATION_TYPE_NEW_PAGE:
593 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); 622 RendererDidNavigateToNewPage(params, &(details->did_replace_entry));
594 break; 623 break;
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 for (int i = 0; i < max_index; i++) { 1390 for (int i = 0; i < max_index; i++) {
1362 // When cloning a tab, copy all entries except interstitial pages 1391 // When cloning a tab, copy all entries except interstitial pages
1363 if (source.entries_[i].get()->GetPageType() != 1392 if (source.entries_[i].get()->GetPageType() !=
1364 content::PAGE_TYPE_INTERSTITIAL) { 1393 content::PAGE_TYPE_INTERSTITIAL) {
1365 entries_.insert(entries_.begin() + insert_index++, 1394 entries_.insert(entries_.begin() + insert_index++,
1366 linked_ptr<NavigationEntryImpl>( 1395 linked_ptr<NavigationEntryImpl>(
1367 new NavigationEntryImpl(*source.entries_[i]))); 1396 new NavigationEntryImpl(*source.entries_[i])));
1368 } 1397 }
1369 } 1398 }
1370 } 1399 }
OLDNEW
« 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