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 SiteInstanceImpl* site_instance = entry->site_instance(); |
| 271 DCHECK(site_instance); |
270 | 272 |
271 // The title of the page being reloaded might have been removed in the | 273 // If we are reloading an entry that no longer belongs to the current |
272 // meanwhile, so we need to revert to the default title upon reload and | 274 // site instance (for example, refreshing a page for just installed app), |
273 // invalidate the previously cached title (SetTitle will do both). | 275 // the reload must happen in a new process. |
274 // See Chromium issue 96041. | 276 // The new entry must have a new page_id and site instance, so it behaves |
275 entries_[pending_entry_index_]->SetTitle(string16()); | 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. |
| 281 NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry( |
| 282 CreateNavigationEntry( |
| 283 entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(), |
| 284 false, entry->extra_headers(), browser_context_)); |
276 | 285 |
277 entries_[pending_entry_index_]->SetTransitionType( | 286 nav_entry->set_is_cross_site_reload(true); |
278 content::PAGE_TRANSITION_RELOAD); | 287 pending_entry_ = nav_entry; |
| 288 } else { |
| 289 pending_entry_index_ = current_index; |
| 290 |
| 291 // The title of the page being reloaded might have been removed in the |
| 292 // meanwhile, so we need to revert to the default title upon reload and |
| 293 // invalidate the previously cached title (SetTitle will do both). |
| 294 // See Chromium issue 96041. |
| 295 entries_[pending_entry_index_]->SetTitle(string16()); |
| 296 |
| 297 entries_[pending_entry_index_]->SetTransitionType( |
| 298 content::PAGE_TRANSITION_RELOAD); |
| 299 } |
| 300 |
279 NavigateToPendingEntry(reload_type); | 301 NavigateToPendingEntry(reload_type); |
280 } | 302 } |
281 } | 303 } |
282 | 304 |
283 void NavigationControllerImpl::CancelPendingReload() { | 305 void NavigationControllerImpl::CancelPendingReload() { |
284 DCHECK(pending_reload_ != NO_RELOAD); | 306 DCHECK(pending_reload_ != NO_RELOAD); |
285 pending_reload_ = NO_RELOAD; | 307 pending_reload_ = NO_RELOAD; |
286 } | 308 } |
287 | 309 |
288 void NavigationControllerImpl::ContinuePendingReload() { | 310 void NavigationControllerImpl::ContinuePendingReload() { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } else { | 605 } else { |
584 details->previous_url = GURL(); | 606 details->previous_url = GURL(); |
585 details->previous_entry_index = -1; | 607 details->previous_entry_index = -1; |
586 } | 608 } |
587 | 609 |
588 // If we have a pending entry at this point, it should have a SiteInstance. | 610 // If we have a pending entry at this point, it should have a SiteInstance. |
589 // Restored entries start out with a null SiteInstance, but we should have | 611 // Restored entries start out with a null SiteInstance, but we should have |
590 // assigned one in NavigateToPendingEntry. | 612 // assigned one in NavigateToPendingEntry. |
591 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); | 613 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); |
592 | 614 |
| 615 // If we are doing a cross-site reload, we need to replace the existing |
| 616 // navigation entry, not add another entry to the history. This has the side |
| 617 // effect of removing forward browsing history, if such existed. |
| 618 if (pending_entry_ != NULL) { |
| 619 details->did_replace_entry = pending_entry_->is_cross_site_reload(); |
| 620 } |
| 621 |
593 // is_in_page must be computed before the entry gets committed. | 622 // is_in_page must be computed before the entry gets committed. |
594 details->is_in_page = IsURLInPageNavigation(params.url); | 623 details->is_in_page = IsURLInPageNavigation(params.url); |
595 | 624 |
596 // Do navigation-type specific actions. These will make and commit an entry. | 625 // Do navigation-type specific actions. These will make and commit an entry. |
597 details->type = ClassifyNavigation(params); | 626 details->type = ClassifyNavigation(params); |
598 | 627 |
599 switch (details->type) { | 628 switch (details->type) { |
600 case content::NAVIGATION_TYPE_NEW_PAGE: | 629 case content::NAVIGATION_TYPE_NEW_PAGE: |
601 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); | 630 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); |
602 break; | 631 break; |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 for (int i = 0; i < max_index; i++) { | 1401 for (int i = 0; i < max_index; i++) { |
1373 // When cloning a tab, copy all entries except interstitial pages | 1402 // When cloning a tab, copy all entries except interstitial pages |
1374 if (source.entries_[i].get()->GetPageType() != | 1403 if (source.entries_[i].get()->GetPageType() != |
1375 content::PAGE_TYPE_INTERSTITIAL) { | 1404 content::PAGE_TYPE_INTERSTITIAL) { |
1376 entries_.insert(entries_.begin() + insert_index++, | 1405 entries_.insert(entries_.begin() + insert_index++, |
1377 linked_ptr<NavigationEntryImpl>( | 1406 linked_ptr<NavigationEntryImpl>( |
1378 new NavigationEntryImpl(*source.entries_[i]))); | 1407 new NavigationEntryImpl(*source.entries_[i]))); |
1379 } | 1408 } |
1380 } | 1409 } |
1381 } | 1410 } |
OLD | NEW |