OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/tab_contents/navigation_controller.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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 pending_reload_ = NO_RELOAD; | 216 pending_reload_ = NO_RELOAD; |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 bool NavigationController::IsInitialNavigation() { | 220 bool NavigationController::IsInitialNavigation() { |
221 return last_document_loaded_.is_null(); | 221 return last_document_loaded_.is_null(); |
222 } | 222 } |
223 | 223 |
224 // static | 224 // static |
225 NavigationEntry* NavigationController::CreateNavigationEntry( | 225 NavigationEntry* NavigationController::CreateNavigationEntry( |
226 const GURL& url, const GURL& referrer, content::PageTransition transition, | 226 const GURL& url, const content::Referrer& referrer, |
| 227 content::PageTransition transition, |
227 bool is_renderer_initiated, const std::string& extra_headers, | 228 bool is_renderer_initiated, const std::string& extra_headers, |
228 content::BrowserContext* browser_context) { | 229 content::BrowserContext* browser_context) { |
229 // Allow the browser URL handler to rewrite the URL. This will, for example, | 230 // Allow the browser URL handler to rewrite the URL. This will, for example, |
230 // remove "view-source:" from the beginning of the URL to get the URL that | 231 // remove "view-source:" from the beginning of the URL to get the URL that |
231 // will actually be loaded. This real URL won't be shown to the user, just | 232 // will actually be loaded. This real URL won't be shown to the user, just |
232 // used internally. | 233 // used internally. |
233 GURL loaded_url(url); | 234 GURL loaded_url(url); |
234 bool reverse_on_redirect = false; | 235 bool reverse_on_redirect = false; |
235 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 236 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
236 &loaded_url, browser_context, &reverse_on_redirect); | 237 &loaded_url, browser_context, &reverse_on_redirect); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 bool is_current = index == last_committed_entry_index_; | 466 bool is_current = index == last_committed_entry_index_; |
466 RemoveEntryAtIndexInternal(index); | 467 RemoveEntryAtIndexInternal(index); |
467 if (is_current) { | 468 if (is_current) { |
468 // We removed the currently shown entry, so we have to load something else. | 469 // We removed the currently shown entry, so we have to load something else. |
469 if (last_committed_entry_index_ != -1) { | 470 if (last_committed_entry_index_ != -1) { |
470 pending_entry_index_ = last_committed_entry_index_; | 471 pending_entry_index_ = last_committed_entry_index_; |
471 NavigateToPendingEntry(NO_RELOAD); | 472 NavigateToPendingEntry(NO_RELOAD); |
472 } else { | 473 } else { |
473 // If there is nothing to show, show a default page. | 474 // If there is nothing to show, show a default page. |
474 LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, | 475 LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, |
475 GURL(), content::PAGE_TRANSITION_START_PAGE, std::string()); | 476 content::Referrer(), content::PAGE_TRANSITION_START_PAGE, |
| 477 std::string()); |
476 } | 478 } |
477 } | 479 } |
478 } | 480 } |
479 | 481 |
480 void NavigationController::UpdateVirtualURLToURL( | 482 void NavigationController::UpdateVirtualURLToURL( |
481 NavigationEntry* entry, const GURL& new_url) { | 483 NavigationEntry* entry, const GURL& new_url) { |
482 GURL new_virtual_url(new_url); | 484 GURL new_virtual_url(new_url); |
483 if (BrowserURLHandler::GetInstance()->ReverseURLRewrite( | 485 if (BrowserURLHandler::GetInstance()->ReverseURLRewrite( |
484 &new_virtual_url, entry->virtual_url(), browser_context_)) { | 486 &new_virtual_url, entry->virtual_url(), browser_context_)) { |
485 entry->set_virtual_url(new_virtual_url); | 487 entry->set_virtual_url(new_virtual_url); |
486 } | 488 } |
487 } | 489 } |
488 | 490 |
489 void NavigationController::AddTransientEntry(NavigationEntry* entry) { | 491 void NavigationController::AddTransientEntry(NavigationEntry* entry) { |
490 // Discard any current transient entry, we can only have one at a time. | 492 // Discard any current transient entry, we can only have one at a time. |
491 int index = 0; | 493 int index = 0; |
492 if (last_committed_entry_index_ != -1) | 494 if (last_committed_entry_index_ != -1) |
493 index = last_committed_entry_index_ + 1; | 495 index = last_committed_entry_index_ + 1; |
494 DiscardTransientEntry(); | 496 DiscardTransientEntry(); |
495 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); | 497 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); |
496 transient_entry_index_ = index; | 498 transient_entry_index_ = index; |
497 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 499 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
498 } | 500 } |
499 | 501 |
500 void NavigationController::LoadURL( | 502 void NavigationController::LoadURL( |
501 const GURL& url, | 503 const GURL& url, |
502 const GURL& referrer, | 504 const content::Referrer& referrer, |
503 content::PageTransition transition, | 505 content::PageTransition transition, |
504 const std::string& extra_headers) { | 506 const std::string& extra_headers) { |
505 // The user initiated a load, we don't need to reload anymore. | 507 // The user initiated a load, we don't need to reload anymore. |
506 needs_reload_ = false; | 508 needs_reload_ = false; |
507 | 509 |
508 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 510 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, |
509 false, | 511 false, |
510 extra_headers, | 512 extra_headers, |
511 browser_context_); | 513 browser_context_); |
512 | 514 |
513 LoadEntry(entry); | 515 LoadEntry(entry); |
514 } | 516 } |
515 | 517 |
516 void NavigationController::LoadURLFromRenderer( | 518 void NavigationController::LoadURLFromRenderer( |
517 const GURL& url, | 519 const GURL& url, |
518 const GURL& referrer, | 520 const content::Referrer& referrer, |
519 content::PageTransition transition, | 521 content::PageTransition transition, |
520 const std::string& extra_headers) { | 522 const std::string& extra_headers) { |
521 // The user initiated a load, we don't need to reload anymore. | 523 // The user initiated a load, we don't need to reload anymore. |
522 needs_reload_ = false; | 524 needs_reload_ = false; |
523 | 525 |
524 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 526 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, |
525 true, | 527 true, |
526 extra_headers, | 528 extra_headers, |
527 browser_context_); | 529 browser_context_); |
528 | 530 |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 for (int i = 0; i < max_index; i++) { | 1264 for (int i = 0; i < max_index; i++) { |
1263 // When cloning a tab, copy all entries except interstitial pages | 1265 // When cloning a tab, copy all entries except interstitial pages |
1264 if (source.entries_[i].get()->page_type() != | 1266 if (source.entries_[i].get()->page_type() != |
1265 content::PAGE_TYPE_INTERSTITIAL) { | 1267 content::PAGE_TYPE_INTERSTITIAL) { |
1266 entries_.insert(entries_.begin() + insert_index++, | 1268 entries_.insert(entries_.begin() + insert_index++, |
1267 linked_ptr<NavigationEntry>( | 1269 linked_ptr<NavigationEntry>( |
1268 new NavigationEntry(*source.entries_[i]))); | 1270 new NavigationEntry(*source.entries_[i]))); |
1269 } | 1271 } |
1270 } | 1272 } |
1271 } | 1273 } |
OLD | NEW |