Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/browser/web_contents/navigation_controller_impl.cc

Issue 10830144: Consolidate all NavigationController::LoadURL and family functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move parameters of LoadURL into struct as well. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 int index = 0; 556 int index = 0;
557 if (last_committed_entry_index_ != -1) 557 if (last_committed_entry_index_ != -1)
558 index = last_committed_entry_index_ + 1; 558 index = last_committed_entry_index_ + 1;
559 DiscardTransientEntry(); 559 DiscardTransientEntry();
560 entries_.insert( 560 entries_.insert(
561 entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry)); 561 entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry));
562 transient_entry_index_ = index; 562 transient_entry_index_ = index;
563 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); 563 web_contents_->NotifyNavigationStateChanged(kInvalidateAll);
564 } 564 }
565 565
566 void NavigationControllerImpl::TransferURL(
567 const GURL& url,
568 const content::Referrer& referrer,
569 content::PageTransition transition,
570 const std::string& extra_headers,
571 const GlobalRequestID& transferred_global_request_id,
572 bool is_renderer_initiated) {
573 // The user initiated a load, we don't need to reload anymore.
574 needs_reload_ = false;
575
576 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
577 CreateNavigationEntry(
578 url, referrer, transition, is_renderer_initiated, extra_headers,
579 browser_context_));
580 entry->set_transferred_global_request_id(transferred_global_request_id);
581
582 LoadEntry(entry);
583 }
584
585 void NavigationControllerImpl::LoadURL( 566 void NavigationControllerImpl::LoadURL(
586 const GURL& url, 567 const GURL& url,
587 const content::Referrer& referrer, 568 const content::Referrer& referrer,
588 content::PageTransition transition, 569 content::PageTransition transition,
589 const std::string& extra_headers) { 570 const std::string& extra_headers) {
590 if (content::HandleDebugURL(url, transition)) 571 LoadURLParams params(url);
572 params.referrer = referrer;
573 params.transition_type = transition;
574 params.extra_headers = extra_headers;
575 LoadURLWithParams(params);
576 }
577
578 void NavigationControllerImpl::LoadURLWithParams(LoadURLParams& params) {
579 if (content::HandleDebugURL(params.url, params.transition_type))
591 return; 580 return;
592 581
593 bool override = ShouldKeepOverride(GetLastCommittedEntry()); 582 // DCHECKs based on params.load_type
594 LoadURLWithUserAgentOverride(url, referrer, transition, false, extra_headers, 583 switch (params.load_type) {
595 override); 584 case LOAD_TYPE_DEFAULT:
596 } 585 break;
586 case LOAD_TYPE_BROWSER_INITIATED_HTTP_POST:
587 DCHECK(params.url.SchemeIs(chrome::kHttpScheme) ||
mnaganov (inactive) 2012/08/03 09:20:04 We need to bail out for safety (as the original co
boliu 2012/08/03 15:55:43 Done.
588 params.url.SchemeIs(chrome::kHttpsScheme));
589 break;
590 case LOAD_TYPE_DATA:
591 DCHECK(params.url.SchemeIs(chrome::kDataScheme));
mnaganov (inactive) 2012/08/03 09:20:04 Same here
boliu 2012/08/03 15:55:43 Done.
592 break;
593 default:
594 NOTREACHED();
595 break;
596 };
597 597
598 void NavigationControllerImpl::LoadURLFromRenderer(
599 const GURL& url,
600 const content::Referrer& referrer,
601 content::PageTransition transition,
602 const std::string& extra_headers) {
603 bool override = ShouldKeepOverride(GetLastCommittedEntry());
604 LoadURLWithUserAgentOverride(url, referrer, transition, true, extra_headers,
605 override);
606 }
607
608 void NavigationControllerImpl::LoadURLWithUserAgentOverride(
609 const GURL& url,
610 const content::Referrer& referrer,
611 content::PageTransition transition,
612 bool is_renderer_initiated,
613 const std::string& extra_headers,
614 bool is_overriding_user_agent) {
615 // The user initiated a load, we don't need to reload anymore. 598 // The user initiated a load, we don't need to reload anymore.
616 needs_reload_ = false; 599 needs_reload_ = false;
617 600
601 bool override = params.is_overriding_user_agent;
602 if(params.should_inherit_user_agent_override) {
603 override = ShouldKeepOverride(GetLastCommittedEntry());
604 }
605
618 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 606 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
619 CreateNavigationEntry( 607 CreateNavigationEntry(
620 url, referrer, transition, is_renderer_initiated, extra_headers, 608 params.url,
609 params.referrer,
610 params.transition_type,
611 params.is_renderer_initiated,
612 params.extra_headers,
621 browser_context_)); 613 browser_context_));
622 entry->SetIsOverridingUserAgent(is_overriding_user_agent); 614 entry->SetIsOverridingUserAgent(override);
615 entry->set_transferred_global_request_id(
616 params.transferred_global_request_id);
617
618 switch (params.load_type) {
619 case LOAD_TYPE_DEFAULT:
620 break;
621 case LOAD_TYPE_BROWSER_INITIATED_HTTP_POST:
622 entry->SetHasPostData(true);
623 entry->SetBrowserInitiatedPostData(
624 params.browser_initiated_post_data);
625 break;
626 case LOAD_TYPE_DATA:
627 entry->SetBaseURLForDataURL(params.base_url_for_data_url);
628 entry->SetVirtualURL(params.virtual_url);
629 break;
630 default:
631 NOTREACHED();
632 break;
633 };
623 634
624 LoadEntry(entry); 635 LoadEntry(entry);
625 } 636 }
626
627 void NavigationControllerImpl::LoadDataWithBaseURL(
628 const GURL& data_url,
629 const content::Referrer& referrer,
630 const GURL& base_url,
631 const GURL& history_url,
632 bool is_overriding_user_agent) {
633 // Make sure we don't allow non-'data:' URLs.
634 if (!data_url.SchemeIs(chrome::kDataScheme)) {
635 NOTREACHED();
636 return;
637 }
638
639 needs_reload_ = false;
640
641 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
642 CreateNavigationEntry(
643 data_url,
644 referrer,
645 content::PAGE_TRANSITION_TYPED,
646 false,
647 std::string(),
648 browser_context_));
649 entry->SetIsOverridingUserAgent(is_overriding_user_agent);
650 entry->SetBaseURLForDataURL(base_url);
651 entry->SetVirtualURL(history_url);
652
653 LoadEntry(entry);
654 }
655
656 void NavigationControllerImpl::PostURL(
657 const GURL& url,
658 const content::Referrer& referrer,
659 const base::RefCountedMemory& http_body,
660 bool is_overriding_user_agent) {
661 // Must be http scheme for a post request.
662 if (!url.SchemeIs(chrome::kHttpScheme) &&
663 !url.SchemeIs(chrome::kHttpsScheme)) {
664 NOTREACHED();
665 return;
666 }
667
668 needs_reload_ = false;
669
670 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
671 CreateNavigationEntry(
672 url,
673 referrer,
674 content::PAGE_TRANSITION_TYPED,
675 false,
676 std::string(),
677 browser_context_));
678 entry->SetIsOverridingUserAgent(is_overriding_user_agent);
679 entry->SetHasPostData(true);
680 entry->SetBrowserInitiatedPostData(&http_body);
681
682 LoadEntry(entry);
683 }
684 637
685 void NavigationControllerImpl::DocumentLoadedInFrame() { 638 void NavigationControllerImpl::DocumentLoadedInFrame() {
686 last_document_loaded_ = base::TimeTicks::Now(); 639 last_document_loaded_ = base::TimeTicks::Now();
687 } 640 }
688 641
689 bool NavigationControllerImpl::RendererDidNavigate( 642 bool NavigationControllerImpl::RendererDidNavigate(
690 const ViewHostMsg_FrameNavigate_Params& params, 643 const ViewHostMsg_FrameNavigate_Params& params,
691 content::LoadCommittedDetails* details) { 644 content::LoadCommittedDetails* details) {
692 645
693 // Save the previous state before we clobber it. 646 // Save the previous state before we clobber it.
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 for (int i = 0; i < max_index; i++) { 1469 for (int i = 0; i < max_index; i++) {
1517 // When cloning a tab, copy all entries except interstitial pages 1470 // When cloning a tab, copy all entries except interstitial pages
1518 if (source.entries_[i].get()->GetPageType() != 1471 if (source.entries_[i].get()->GetPageType() !=
1519 content::PAGE_TYPE_INTERSTITIAL) { 1472 content::PAGE_TYPE_INTERSTITIAL) {
1520 entries_.insert(entries_.begin() + insert_index++, 1473 entries_.insert(entries_.begin() + insert_index++,
1521 linked_ptr<NavigationEntryImpl>( 1474 linked_ptr<NavigationEntryImpl>(
1522 new NavigationEntryImpl(*source.entries_[i]))); 1475 new NavigationEntryImpl(*source.entries_[i])));
1523 } 1476 }
1524 } 1477 }
1525 } 1478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698