OLD | NEW |
---|---|
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 content::NOTIFICATION_REPOST_WARNING_SHOWN, | 259 content::NOTIFICATION_REPOST_WARNING_SHOWN, |
260 content::Source<NavigationController>(this), | 260 content::Source<NavigationController>(this), |
261 content::NotificationService::NoDetails()); | 261 content::NotificationService::NoDetails()); |
262 | 262 |
263 pending_reload_ = reload_type; | 263 pending_reload_ = reload_type; |
264 tab_contents_->Activate(); | 264 tab_contents_->Activate(); |
265 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); | 265 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); |
266 } else { | 266 } else { |
267 DiscardNonCommittedEntriesInternal(); | 267 DiscardNonCommittedEntriesInternal(); |
268 | 268 |
269 pending_entry_index_ = current_index; | 269 NavigationEntryImpl* entry = entries_[current_index].get(); |
270 entries_[pending_entry_index_]->SetTransitionType( | 270 SiteInstanceImpl* site_instance = entry->site_instance(); |
271 content::PAGE_TRANSITION_RELOAD); | 271 DCHECK(site_instance); |
272 | |
273 // If we are reloading an entry that no longer belongs to the current | |
274 // site instance (for example, refreshing a page for just installed app), | |
275 // the reload must happen in a new process. | |
276 // The new entry must have a new page_id and site instance, so it behaves | |
277 // as new navigation (which happens to clear forward history). | |
278 if (site_instance->HasWrongProcessForURL(entry->GetURL())) { | |
279 // Create a navigation entry that resembles the current one, but do not | |
280 // copy page id, site instance, and content state. | |
darin (slow to review)
2012/01/27 19:34:11
normally when you reload a page, webkit restores t
Charlie Reis
2012/01/27 20:50:18
It's not ideal, but I think it's reasonable in the
| |
281 NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry( | |
282 CreateNavigationEntry( | |
283 entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(), | |
284 false, entry->extra_headers(), browser_context_)); | |
285 | |
286 nav_entry->set_is_cross_site_reload(true); | |
287 pending_entry_ = nav_entry; | |
darin (slow to review)
2012/01/27 19:34:11
you don't have to set the PAGE_TRANSITION_RELOAD t
nasko
2012/01/27 20:14:56
Again, due to the fact that we are transitioning p
| |
288 } else { | |
289 pending_entry_index_ = current_index; | |
290 entries_[pending_entry_index_]->SetTransitionType( | |
291 content::PAGE_TRANSITION_RELOAD); | |
292 } | |
293 | |
272 NavigateToPendingEntry(reload_type); | 294 NavigateToPendingEntry(reload_type); |
273 } | 295 } |
274 } | 296 } |
275 | 297 |
276 void NavigationControllerImpl::CancelPendingReload() { | 298 void NavigationControllerImpl::CancelPendingReload() { |
277 DCHECK(pending_reload_ != NO_RELOAD); | 299 DCHECK(pending_reload_ != NO_RELOAD); |
278 pending_reload_ = NO_RELOAD; | 300 pending_reload_ = NO_RELOAD; |
279 } | 301 } |
280 | 302 |
281 void NavigationControllerImpl::ContinuePendingReload() { | 303 void NavigationControllerImpl::ContinuePendingReload() { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 } else { | 598 } else { |
577 details->previous_url = GURL(); | 599 details->previous_url = GURL(); |
578 details->previous_entry_index = -1; | 600 details->previous_entry_index = -1; |
579 } | 601 } |
580 | 602 |
581 // If we have a pending entry at this point, it should have a SiteInstance. | 603 // If we have a pending entry at this point, it should have a SiteInstance. |
582 // Restored entries start out with a null SiteInstance, but we should have | 604 // Restored entries start out with a null SiteInstance, but we should have |
583 // assigned one in NavigateToPendingEntry. | 605 // assigned one in NavigateToPendingEntry. |
584 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); | 606 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); |
585 | 607 |
608 // If we are doing a cross-site reload, we need to replace the existing | |
609 // navigation entry, not add another entry to the history. This has the side | |
610 // effect of removing forward browsing history, if such existed. | |
darin (slow to review)
2012/01/27 19:34:11
normally hitting reload does not wipe out forward
nasko
2012/01/27 20:14:56
Navigation entries are identified uniquely by a tu
Charlie Reis
2012/01/27 20:50:18
That's right. We actually had a previous fix for
| |
611 if (pending_entry_ != NULL) { | |
612 details->did_replace_entry = pending_entry_->is_cross_site_reload(); | |
613 } | |
614 | |
586 // is_in_page must be computed before the entry gets committed. | 615 // is_in_page must be computed before the entry gets committed. |
587 details->is_in_page = IsURLInPageNavigation(params.url); | 616 details->is_in_page = IsURLInPageNavigation(params.url); |
588 | 617 |
589 // Do navigation-type specific actions. These will make and commit an entry. | 618 // Do navigation-type specific actions. These will make and commit an entry. |
590 details->type = ClassifyNavigation(params); | 619 details->type = ClassifyNavigation(params); |
591 | 620 |
592 switch (details->type) { | 621 switch (details->type) { |
593 case content::NAVIGATION_TYPE_NEW_PAGE: | 622 case content::NAVIGATION_TYPE_NEW_PAGE: |
594 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); | 623 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); |
595 break; | 624 break; |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 for (int i = 0; i < max_index; i++) { | 1394 for (int i = 0; i < max_index; i++) { |
1366 // When cloning a tab, copy all entries except interstitial pages | 1395 // When cloning a tab, copy all entries except interstitial pages |
1367 if (source.entries_[i].get()->GetPageType() != | 1396 if (source.entries_[i].get()->GetPageType() != |
1368 content::PAGE_TYPE_INTERSTITIAL) { | 1397 content::PAGE_TYPE_INTERSTITIAL) { |
1369 entries_.insert(entries_.begin() + insert_index++, | 1398 entries_.insert(entries_.begin() + insert_index++, |
1370 linked_ptr<NavigationEntryImpl>( | 1399 linked_ptr<NavigationEntryImpl>( |
1371 new NavigationEntryImpl(*source.entries_[i]))); | 1400 new NavigationEntryImpl(*source.entries_[i]))); |
1372 } | 1401 } |
1373 } | 1402 } |
1374 } | 1403 } |
OLD | NEW |