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/web_contents/navigation_controller_impl.h" | 5 #include "content/browser/web_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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 entry->set_transferred_global_request_id(transferred_global_request_id); | 567 entry->set_transferred_global_request_id(transferred_global_request_id); |
568 | 568 |
569 LoadEntry(entry); | 569 LoadEntry(entry); |
570 } | 570 } |
571 | 571 |
572 void NavigationControllerImpl::LoadURL( | 572 void NavigationControllerImpl::LoadURL( |
573 const GURL& url, | 573 const GURL& url, |
574 const content::Referrer& referrer, | 574 const content::Referrer& referrer, |
575 content::PageTransition transition, | 575 content::PageTransition transition, |
576 const std::string& extra_headers) { | 576 const std::string& extra_headers) { |
577 bool override = false; | |
578 | |
579 // Carry over the user agent override if we're doing a regular navigation. | |
580 bool carry_over = transition == content::PAGE_TRANSITION_TYPED || | |
581 transition == content::PAGE_TRANSITION_AUTO_BOOKMARK || | |
582 transition == content::PAGE_TRANSITION_GENERATED; | |
gone
2012/05/24 18:26:21
These conditions were the only ones we encountered
jochen (gone - plz use gerrit)
2012/05/31 14:09:16
What is the intention? When should the UA override
gone
2012/05/31 21:43:25
We intend to carry the override around until a cal
Charlie Reis
2012/06/01 00:36:08
As noted before, I don't understand why it's per-R
| |
583 if (GetLastCommittedEntry() && carry_over) | |
584 override = GetLastCommittedEntry()->GetIsOverridingUserAgent(); | |
585 | |
586 LoadURLWithUserAgentOverride(url, referrer, transition, extra_headers, | |
587 override); | |
588 } | |
589 | |
590 void NavigationControllerImpl::LoadURLWithUserAgentOverride( | |
591 const GURL& url, | |
592 const content::Referrer& referrer, | |
593 content::PageTransition transition, | |
594 const std::string& extra_headers, | |
595 bool is_overriding_user_agent) { | |
577 if (content::HandleDebugURL(url, transition)) | 596 if (content::HandleDebugURL(url, transition)) |
578 return; | 597 return; |
579 | 598 |
580 // The user initiated a load, we don't need to reload anymore. | 599 // The user initiated a load, we don't need to reload anymore. |
581 needs_reload_ = false; | 600 needs_reload_ = false; |
582 | 601 |
583 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 602 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
584 CreateNavigationEntry( | 603 CreateNavigationEntry( |
585 url, referrer, transition, false, extra_headers, browser_context_)); | 604 url, referrer, transition, false, extra_headers, browser_context_)); |
605 entry->SetIsOverridingUserAgent(is_overriding_user_agent); | |
586 | 606 |
587 LoadEntry(entry); | 607 LoadEntry(entry); |
588 } | 608 } |
589 | 609 |
590 void NavigationControllerImpl::LoadURLFromRenderer( | 610 void NavigationControllerImpl::LoadURLFromRenderer( |
Charlie Reis
2012/06/01 00:36:08
What about this case? Do we only care about user
gone
2012/06/01 01:04:06
We catch renderer-initiated navigations when it se
Charlie Reis
2012/06/01 18:04:09
UpdateURL is called after the navigation commits i
gone
2012/06/14 00:46:39
I've added this case in.
| |
591 const GURL& url, | 611 const GURL& url, |
592 const content::Referrer& referrer, | 612 const content::Referrer& referrer, |
593 content::PageTransition transition, | 613 content::PageTransition transition, |
594 const std::string& extra_headers) { | 614 const std::string& extra_headers) { |
595 // The user initiated a load, we don't need to reload anymore. | 615 // The user initiated a load, we don't need to reload anymore. |
596 needs_reload_ = false; | 616 needs_reload_ = false; |
597 | 617 |
598 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 618 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
599 CreateNavigationEntry( | 619 CreateNavigationEntry( |
600 url, referrer, transition, true, extra_headers, browser_context_)); | 620 url, referrer, transition, true, extra_headers, browser_context_)); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 new_entry->SetURL(params.url); | 881 new_entry->SetURL(params.url); |
862 if (update_virtual_url) | 882 if (update_virtual_url) |
863 UpdateVirtualURLToURL(new_entry, params.url); | 883 UpdateVirtualURLToURL(new_entry, params.url); |
864 new_entry->SetReferrer(params.referrer); | 884 new_entry->SetReferrer(params.referrer); |
865 new_entry->SetPageID(params.page_id); | 885 new_entry->SetPageID(params.page_id); |
866 new_entry->SetTransitionType(params.transition); | 886 new_entry->SetTransitionType(params.transition); |
867 new_entry->set_site_instance( | 887 new_entry->set_site_instance( |
868 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); | 888 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); |
869 new_entry->SetHasPostData(params.is_post); | 889 new_entry->SetHasPostData(params.is_post); |
870 new_entry->SetPostID(params.post_id); | 890 new_entry->SetPostID(params.post_id); |
871 | 891 new_entry->SetOriginalRequestURL(params.original_request_url); |
tony
2012/05/31 17:25:00
How are original_request_url and url/redirects[0]
gone
2012/05/31 21:43:25
It's intentional; the redirect chain doesn't alway
tony
2012/05/31 21:59:02
I don't fully understand the issue, but is this bu
gone
2012/06/01 01:04:06
Will do.
| |
872 if (params.redirects.size() > 0) | 892 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); |
873 new_entry->SetOriginalRequestURL(params.redirects[0]); | |
874 else | |
875 new_entry->SetOriginalRequestURL(params.url); | |
876 | 893 |
877 InsertOrReplaceEntry(new_entry, *did_replace_entry); | 894 InsertOrReplaceEntry(new_entry, *did_replace_entry); |
878 } | 895 } |
879 | 896 |
880 void NavigationControllerImpl::RendererDidNavigateToExistingPage( | 897 void NavigationControllerImpl::RendererDidNavigateToExistingPage( |
881 const ViewHostMsg_FrameNavigate_Params& params) { | 898 const ViewHostMsg_FrameNavigate_Params& params) { |
882 // We should only get here for main frame navigations. | 899 // We should only get here for main frame navigations. |
883 DCHECK(content::PageTransitionIsMainFrame(params.transition)); | 900 DCHECK(content::PageTransitionIsMainFrame(params.transition)); |
884 | 901 |
885 // This is a back/forward navigation. The existing page for the ID is | 902 // This is a back/forward navigation. The existing page for the ID is |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 for (int i = 0; i < max_index; i++) { | 1449 for (int i = 0; i < max_index; i++) { |
1433 // When cloning a tab, copy all entries except interstitial pages | 1450 // When cloning a tab, copy all entries except interstitial pages |
1434 if (source.entries_[i].get()->GetPageType() != | 1451 if (source.entries_[i].get()->GetPageType() != |
1435 content::PAGE_TYPE_INTERSTITIAL) { | 1452 content::PAGE_TYPE_INTERSTITIAL) { |
1436 entries_.insert(entries_.begin() + insert_index++, | 1453 entries_.insert(entries_.begin() + insert_index++, |
1437 linked_ptr<NavigationEntryImpl>( | 1454 linked_ptr<NavigationEntryImpl>( |
1438 new NavigationEntryImpl(*source.entries_[i]))); | 1455 new NavigationEntryImpl(*source.entries_[i]))); |
1439 } | 1456 } |
1440 } | 1457 } |
1441 } | 1458 } |
OLD | NEW |