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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 content::Referrer& referrer, | 226 const GURL& url, const content::Referrer& referrer, |
227 content::PageTransition transition, | 227 content::PageTransition transition, |
228 bool is_renderer_initiated, const std::string& extra_headers, | 228 bool is_renderer_initiated, const std::string& extra_headers, |
229 content::BrowserContext* browser_context) { | 229 content::BrowserContext* browser_context, |
| 230 int64 opener_browsing_instance_frame_id) { |
230 // Allow the browser URL handler to rewrite the URL. This will, for example, | 231 // Allow the browser URL handler to rewrite the URL. This will, for example, |
231 // remove "view-source:" from the beginning of the URL to get the URL that | 232 // remove "view-source:" from the beginning of the URL to get the URL that |
232 // will actually be loaded. This real URL won't be shown to the user, just | 233 // will actually be loaded. This real URL won't be shown to the user, just |
233 // used internally. | 234 // used internally. |
234 GURL loaded_url(url); | 235 GURL loaded_url(url); |
235 bool reverse_on_redirect = false; | 236 bool reverse_on_redirect = false; |
236 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 237 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
237 &loaded_url, browser_context, &reverse_on_redirect); | 238 &loaded_url, browser_context, &reverse_on_redirect); |
238 | 239 |
239 NavigationEntry* entry = new NavigationEntry( | 240 NavigationEntry* entry = new NavigationEntry( |
240 NULL, // The site instance for tabs is sent on navigation | 241 NULL, // The site instance for tabs is sent on navigation |
241 // (TabContents::GetSiteInstance). | 242 // (TabContents::GetSiteInstance). |
242 -1, | 243 -1, |
243 loaded_url, | 244 loaded_url, |
244 referrer, | 245 referrer, |
245 string16(), | 246 string16(), |
246 transition, | 247 transition, |
247 is_renderer_initiated); | 248 is_renderer_initiated); |
248 entry->set_virtual_url(url); | 249 entry->set_virtual_url(url); |
249 entry->set_user_typed_url(url); | 250 entry->set_user_typed_url(url); |
250 entry->set_update_virtual_url_with_url(reverse_on_redirect); | 251 entry->set_update_virtual_url_with_url(reverse_on_redirect); |
251 entry->set_extra_headers(extra_headers); | 252 entry->set_extra_headers(extra_headers); |
| 253 entry->set_opener_browsing_instance_frame_id( |
| 254 opener_browsing_instance_frame_id); |
252 return entry; | 255 return entry; |
253 } | 256 } |
254 | 257 |
255 NavigationEntry* NavigationController::GetEntryWithPageID( | 258 NavigationEntry* NavigationController::GetEntryWithPageID( |
256 SiteInstance* instance, int32 page_id) const { | 259 SiteInstance* instance, int32 page_id) const { |
257 int index = GetEntryIndexWithPageID(instance, page_id); | 260 int index = GetEntryIndexWithPageID(instance, page_id); |
258 return (index != -1) ? entries_[index].get() : NULL; | 261 return (index != -1) ? entries_[index].get() : NULL; |
259 } | 262 } |
260 | 263 |
261 void NavigationController::LoadEntry(NavigationEntry* entry) { | 264 void NavigationController::LoadEntry(NavigationEntry* entry) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); | 500 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); |
498 transient_entry_index_ = index; | 501 transient_entry_index_ = index; |
499 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 502 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
500 } | 503 } |
501 | 504 |
502 void NavigationController::TransferURL( | 505 void NavigationController::TransferURL( |
503 const GURL& url, | 506 const GURL& url, |
504 const content::Referrer& referrer, | 507 const content::Referrer& referrer, |
505 content::PageTransition transition, | 508 content::PageTransition transition, |
506 const std::string& extra_headers, | 509 const std::string& extra_headers, |
| 510 const int64 opener_browsing_instance_frame_id, |
507 const GlobalRequestID& transferred_global_request_id, | 511 const GlobalRequestID& transferred_global_request_id, |
508 bool is_renderer_initiated) { | 512 bool is_renderer_initiated) { |
509 // The user initiated a load, we don't need to reload anymore. | 513 // The user initiated a load, we don't need to reload anymore. |
510 needs_reload_ = false; | 514 needs_reload_ = false; |
511 | 515 |
512 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 516 NavigationEntry* entry = CreateNavigationEntry( |
513 is_renderer_initiated, | 517 url, referrer, transition, is_renderer_initiated, extra_headers, |
514 extra_headers, | 518 browser_context_, opener_browsing_instance_frame_id); |
515 browser_context_); | |
516 entry->set_transferred_global_request_id(transferred_global_request_id); | 519 entry->set_transferred_global_request_id(transferred_global_request_id); |
517 | 520 |
518 LoadEntry(entry); | 521 LoadEntry(entry); |
519 } | 522 } |
520 | 523 |
521 void NavigationController::LoadURL( | 524 void NavigationController::LoadURL( |
522 const GURL& url, | 525 const GURL& url, |
523 const content::Referrer& referrer, | 526 const content::Referrer& referrer, |
524 content::PageTransition transition, | 527 content::PageTransition transition, |
525 const std::string& extra_headers) { | 528 const std::string& extra_headers) { |
526 // The user initiated a load, we don't need to reload anymore. | 529 // The user initiated a load, we don't need to reload anymore. |
527 needs_reload_ = false; | 530 needs_reload_ = false; |
528 | 531 |
529 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 532 NavigationEntry* entry = CreateNavigationEntry( |
530 false, | 533 url, referrer, transition, false, extra_headers, |
531 extra_headers, | 534 browser_context_); |
532 browser_context_); | |
533 | 535 |
534 LoadEntry(entry); | 536 LoadEntry(entry); |
535 } | 537 } |
536 | 538 |
537 void NavigationController::LoadURLFromRenderer( | 539 void NavigationController::LoadURLFromRenderer( |
538 const GURL& url, | 540 const GURL& url, |
539 const content::Referrer& referrer, | 541 const content::Referrer& referrer, |
540 content::PageTransition transition, | 542 content::PageTransition transition, |
541 const std::string& extra_headers) { | 543 const std::string& extra_headers, |
| 544 int64 opener_browsing_instance_frame_id) { |
542 // The user initiated a load, we don't need to reload anymore. | 545 // The user initiated a load, we don't need to reload anymore. |
543 needs_reload_ = false; | 546 needs_reload_ = false; |
544 | 547 |
545 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 548 NavigationEntry* entry = CreateNavigationEntry( |
546 true, | 549 url, referrer, transition, true, extra_headers, |
547 extra_headers, | 550 browser_context_, opener_browsing_instance_frame_id); |
548 browser_context_); | |
549 | 551 |
550 LoadEntry(entry); | 552 LoadEntry(entry); |
551 } | 553 } |
552 | 554 |
553 void NavigationController::DocumentLoadedInFrame() { | 555 void NavigationController::DocumentLoadedInFrame() { |
554 last_document_loaded_ = base::TimeTicks::Now(); | 556 last_document_loaded_ = base::TimeTicks::Now(); |
555 } | 557 } |
556 | 558 |
557 bool NavigationController::RendererDidNavigate( | 559 bool NavigationController::RendererDidNavigate( |
558 const ViewHostMsg_FrameNavigate_Params& params, | 560 const ViewHostMsg_FrameNavigate_Params& params, |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 for (int i = 0; i < max_index; i++) { | 1285 for (int i = 0; i < max_index; i++) { |
1284 // When cloning a tab, copy all entries except interstitial pages | 1286 // When cloning a tab, copy all entries except interstitial pages |
1285 if (source.entries_[i].get()->page_type() != | 1287 if (source.entries_[i].get()->page_type() != |
1286 content::PAGE_TYPE_INTERSTITIAL) { | 1288 content::PAGE_TYPE_INTERSTITIAL) { |
1287 entries_.insert(entries_.begin() + insert_index++, | 1289 entries_.insert(entries_.begin() + insert_index++, |
1288 linked_ptr<NavigationEntry>( | 1290 linked_ptr<NavigationEntry>( |
1289 new NavigationEntry(*source.entries_[i]))); | 1291 new NavigationEntry(*source.entries_[i]))); |
1290 } | 1292 } |
1291 } | 1293 } |
1292 } | 1294 } |
OLD | NEW |