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

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

Issue 10829044: Implement NavigationControllerWebView.PostURL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix nits. Use RefCountedBytes. 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 false, 646 false,
647 std::string(), 647 std::string(),
648 browser_context_)); 648 browser_context_));
649 entry->SetIsOverridingUserAgent(is_overriding_user_agent); 649 entry->SetIsOverridingUserAgent(is_overriding_user_agent);
650 entry->SetBaseURLForDataURL(base_url); 650 entry->SetBaseURLForDataURL(base_url);
651 entry->SetVirtualURL(history_url); 651 entry->SetVirtualURL(history_url);
652 652
653 LoadEntry(entry); 653 LoadEntry(entry);
654 } 654 }
655 655
656 void NavigationControllerImpl::PostURL(
657 const GURL& url,
658 const content::Referrer& referrer,
659 const scoped_refptr<base::RefCountedBytes> http_body,
660 bool is_overriding_user_agent) {
661 // Must be http scheme for a post request
Charlie Reis 2012/07/30 20:36:38 nit: End with a period.
boliu 2012/07/30 21:53:45 Done.
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
656 void NavigationControllerImpl::DocumentLoadedInFrame() { 685 void NavigationControllerImpl::DocumentLoadedInFrame() {
657 last_document_loaded_ = base::TimeTicks::Now(); 686 last_document_loaded_ = base::TimeTicks::Now();
658 } 687 }
659 688
660 bool NavigationControllerImpl::RendererDidNavigate( 689 bool NavigationControllerImpl::RendererDidNavigate(
661 const ViewHostMsg_FrameNavigate_Params& params, 690 const ViewHostMsg_FrameNavigate_Params& params,
662 content::LoadCommittedDetails* details) { 691 content::LoadCommittedDetails* details) {
663 692
664 // Save the previous state before we clobber it. 693 // Save the previous state before we clobber it.
665 if (GetLastCommittedEntry()) { 694 if (GetLastCommittedEntry()) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 default: 751 default:
723 NOTREACHED(); 752 NOTREACHED();
724 } 753 }
725 754
726 // All committed entries should have nonempty content state so WebKit doesn't 755 // All committed entries should have nonempty content state so WebKit doesn't
727 // get confused when we go back to them (see the function for details). 756 // get confused when we go back to them (see the function for details).
728 DCHECK(!params.content_state.empty()); 757 DCHECK(!params.content_state.empty());
729 NavigationEntryImpl* active_entry = 758 NavigationEntryImpl* active_entry =
730 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); 759 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry());
731 active_entry->SetContentState(params.content_state); 760 active_entry->SetContentState(params.content_state);
761 // No longer needed since content state will hold the post data if any.
762 active_entry->SetBrowserInitiatedPostData(
763 scoped_refptr<base::RefCountedBytes>(NULL));
764
732 765
733 // Once committed, we do not need to track if the entry was initiated by 766 // Once committed, we do not need to track if the entry was initiated by
734 // the renderer. 767 // the renderer.
735 active_entry->set_is_renderer_initiated(false); 768 active_entry->set_is_renderer_initiated(false);
736 769
737 // The active entry's SiteInstance should match our SiteInstance. 770 // The active entry's SiteInstance should match our SiteInstance.
738 DCHECK(active_entry->site_instance() == web_contents_->GetSiteInstance()); 771 DCHECK(active_entry->site_instance() == web_contents_->GetSiteInstance());
739 772
740 // Now prep the rest of the details for the notification and broadcast. 773 // Now prep the rest of the details for the notification and broadcast.
741 details->entry = active_entry; 774 details->entry = active_entry;
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 for (int i = 0; i < max_index; i++) { 1517 for (int i = 0; i < max_index; i++) {
1485 // When cloning a tab, copy all entries except interstitial pages 1518 // When cloning a tab, copy all entries except interstitial pages
1486 if (source.entries_[i].get()->GetPageType() != 1519 if (source.entries_[i].get()->GetPageType() !=
1487 content::PAGE_TYPE_INTERSTITIAL) { 1520 content::PAGE_TYPE_INTERSTITIAL) {
1488 entries_.insert(entries_.begin() + insert_index++, 1521 entries_.insert(entries_.begin() + insert_index++,
1489 linked_ptr<NavigationEntryImpl>( 1522 linked_ptr<NavigationEntryImpl>(
1490 new NavigationEntryImpl(*source.entries_[i]))); 1523 new NavigationEntryImpl(*source.entries_[i])));
1491 } 1524 }
1492 } 1525 }
1493 } 1526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698