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" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "content/browser/browser_url_handler.h" | 13 #include "content/browser/browser_url_handler.h" |
14 #include "content/browser/child_process_security_policy.h" | 14 #include "content/browser/child_process_security_policy.h" |
| 15 #include "content/browser/content_frame.h" |
15 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 16 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
16 #include "content/browser/renderer_host/render_view_host.h" // Temporary | 17 #include "content/browser/renderer_host/render_view_host.h" // Temporary |
17 #include "content/browser/site_instance.h" | 18 #include "content/browser/site_instance.h" |
18 #include "content/browser/tab_contents/interstitial_page.h" | 19 #include "content/browser/tab_contents/interstitial_page.h" |
19 #include "content/browser/tab_contents/navigation_details.h" | 20 #include "content/browser/tab_contents/navigation_details.h" |
20 #include "content/browser/tab_contents/navigation_entry.h" | 21 #include "content/browser/tab_contents/navigation_entry.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "content/browser/tab_contents/tab_contents_delegate.h" | 23 #include "content/browser/tab_contents/tab_contents_delegate.h" |
23 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
24 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 bool NavigationController::IsInitialNavigation() { | 225 bool NavigationController::IsInitialNavigation() { |
225 return last_document_loaded_.is_null(); | 226 return last_document_loaded_.is_null(); |
226 } | 227 } |
227 | 228 |
228 // static | 229 // static |
229 NavigationEntry* NavigationController::CreateNavigationEntry( | 230 NavigationEntry* NavigationController::CreateNavigationEntry( |
230 const GURL& url, const content::Referrer& referrer, | 231 const GURL& url, const content::Referrer& referrer, |
231 content::PageTransition transition, | 232 content::PageTransition transition, |
232 bool is_renderer_initiated, const std::string& extra_headers, | 233 bool is_renderer_initiated, const std::string& extra_headers, |
233 content::BrowserContext* browser_context) { | 234 content::BrowserContext* browser_context, |
| 235 content::ContentFrame* opener) { |
234 // Allow the browser URL handler to rewrite the URL. This will, for example, | 236 // Allow the browser URL handler to rewrite the URL. This will, for example, |
235 // remove "view-source:" from the beginning of the URL to get the URL that | 237 // remove "view-source:" from the beginning of the URL to get the URL that |
236 // will actually be loaded. This real URL won't be shown to the user, just | 238 // will actually be loaded. This real URL won't be shown to the user, just |
237 // used internally. | 239 // used internally. |
238 GURL loaded_url(url); | 240 GURL loaded_url(url); |
239 bool reverse_on_redirect = false; | 241 bool reverse_on_redirect = false; |
240 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 242 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
241 &loaded_url, browser_context, &reverse_on_redirect); | 243 &loaded_url, browser_context, &reverse_on_redirect); |
242 | 244 |
243 NavigationEntry* entry = new NavigationEntry( | 245 NavigationEntry* entry = new NavigationEntry( |
244 NULL, // The site instance for tabs is sent on navigation | 246 NULL, // The site instance for tabs is sent on navigation |
245 // (TabContents::GetSiteInstance). | 247 // (TabContents::GetSiteInstance). |
246 -1, | 248 -1, |
247 loaded_url, | 249 loaded_url, |
248 referrer, | 250 referrer, |
249 string16(), | 251 string16(), |
250 transition, | 252 transition, |
251 is_renderer_initiated); | 253 is_renderer_initiated); |
252 entry->set_virtual_url(url); | 254 entry->set_virtual_url(url); |
253 entry->set_user_typed_url(url); | 255 entry->set_user_typed_url(url); |
254 entry->set_update_virtual_url_with_url(reverse_on_redirect); | 256 entry->set_update_virtual_url_with_url(reverse_on_redirect); |
255 entry->set_extra_headers(extra_headers); | 257 entry->set_extra_headers(extra_headers); |
| 258 |
| 259 if (opener) |
| 260 entry->set_opener_content_frame_id(opener->id()); |
| 261 |
256 return entry; | 262 return entry; |
257 } | 263 } |
258 | 264 |
259 NavigationEntry* NavigationController::GetEntryWithPageID( | 265 NavigationEntry* NavigationController::GetEntryWithPageID( |
260 SiteInstance* instance, int32 page_id) const { | 266 SiteInstance* instance, int32 page_id) const { |
261 int index = GetEntryIndexWithPageID(instance, page_id); | 267 int index = GetEntryIndexWithPageID(instance, page_id); |
262 return (index != -1) ? entries_[index].get() : NULL; | 268 return (index != -1) ? entries_[index].get() : NULL; |
263 } | 269 } |
264 | 270 |
265 void NavigationController::LoadEntry(NavigationEntry* entry) { | 271 void NavigationController::LoadEntry(NavigationEntry* entry) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); | 507 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); |
502 transient_entry_index_ = index; | 508 transient_entry_index_ = index; |
503 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 509 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
504 } | 510 } |
505 | 511 |
506 void NavigationController::TransferURL( | 512 void NavigationController::TransferURL( |
507 const GURL& url, | 513 const GURL& url, |
508 const content::Referrer& referrer, | 514 const content::Referrer& referrer, |
509 content::PageTransition transition, | 515 content::PageTransition transition, |
510 const std::string& extra_headers, | 516 const std::string& extra_headers, |
| 517 content::ContentFrame* opener, |
511 const GlobalRequestID& transferred_global_request_id, | 518 const GlobalRequestID& transferred_global_request_id, |
512 bool is_renderer_initiated) { | 519 bool is_renderer_initiated) { |
513 // The user initiated a load, we don't need to reload anymore. | 520 // The user initiated a load, we don't need to reload anymore. |
514 needs_reload_ = false; | 521 needs_reload_ = false; |
515 | 522 |
516 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 523 NavigationEntry* entry = CreateNavigationEntry( |
517 is_renderer_initiated, | 524 url, referrer, transition, is_renderer_initiated, extra_headers, |
518 extra_headers, | 525 browser_context_, opener); |
519 browser_context_); | |
520 entry->set_transferred_global_request_id(transferred_global_request_id); | 526 entry->set_transferred_global_request_id(transferred_global_request_id); |
521 | 527 |
522 LoadEntry(entry); | 528 LoadEntry(entry); |
523 } | 529 } |
524 | 530 |
525 void NavigationController::LoadURL( | 531 void NavigationController::LoadURL( |
526 const GURL& url, | 532 const GURL& url, |
527 const content::Referrer& referrer, | 533 const content::Referrer& referrer, |
528 content::PageTransition transition, | 534 content::PageTransition transition, |
529 const std::string& extra_headers) { | 535 const std::string& extra_headers) { |
530 // The user initiated a load, we don't need to reload anymore. | 536 // The user initiated a load, we don't need to reload anymore. |
531 needs_reload_ = false; | 537 needs_reload_ = false; |
532 | 538 |
533 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 539 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, |
534 false, | 540 false, |
535 extra_headers, | 541 extra_headers, |
536 browser_context_); | 542 browser_context_); |
537 | 543 |
538 LoadEntry(entry); | 544 LoadEntry(entry); |
539 } | 545 } |
540 | 546 |
541 void NavigationController::LoadURLFromRenderer( | 547 void NavigationController::LoadURLFromRenderer( |
542 const GURL& url, | 548 const GURL& url, |
543 const content::Referrer& referrer, | 549 const content::Referrer& referrer, |
544 content::PageTransition transition, | 550 content::PageTransition transition, |
545 const std::string& extra_headers) { | 551 const std::string& extra_headers, |
| 552 content::ContentFrame* opener) { |
546 // The user initiated a load, we don't need to reload anymore. | 553 // The user initiated a load, we don't need to reload anymore. |
547 needs_reload_ = false; | 554 needs_reload_ = false; |
548 | 555 |
549 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, | 556 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, |
550 true, | 557 true, |
551 extra_headers, | 558 extra_headers, |
552 browser_context_); | 559 browser_context_, |
| 560 opener); |
553 | 561 |
554 LoadEntry(entry); | 562 LoadEntry(entry); |
555 } | 563 } |
556 | 564 |
557 void NavigationController::DocumentLoadedInFrame() { | 565 void NavigationController::DocumentLoadedInFrame() { |
558 last_document_loaded_ = base::TimeTicks::Now(); | 566 last_document_loaded_ = base::TimeTicks::Now(); |
559 } | 567 } |
560 | 568 |
561 bool NavigationController::RendererDidNavigate( | 569 bool NavigationController::RendererDidNavigate( |
562 const ViewHostMsg_FrameNavigate_Params& params, | 570 const ViewHostMsg_FrameNavigate_Params& params, |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 for (int i = 0; i < max_index; i++) { | 1302 for (int i = 0; i < max_index; i++) { |
1295 // When cloning a tab, copy all entries except interstitial pages | 1303 // When cloning a tab, copy all entries except interstitial pages |
1296 if (source.entries_[i].get()->page_type() != | 1304 if (source.entries_[i].get()->page_type() != |
1297 content::PAGE_TYPE_INTERSTITIAL) { | 1305 content::PAGE_TYPE_INTERSTITIAL) { |
1298 entries_.insert(entries_.begin() + insert_index++, | 1306 entries_.insert(entries_.begin() + insert_index++, |
1299 linked_ptr<NavigationEntry>( | 1307 linked_ptr<NavigationEntry>( |
1300 new NavigationEntry(*source.entries_[i]))); | 1308 new NavigationEntry(*source.entries_[i]))); |
1301 } | 1309 } |
1302 } | 1310 } |
1303 } | 1311 } |
OLD | NEW |