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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 906283003: PlzNavigate: Support data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Charlie's comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 8a599b199427ffc84e9990ea1897e95279082bc7..1c3867d37026927b8feeb650513c9e778103a720 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -50,6 +50,13 @@ int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) {
} // namespace
// static
+bool NavigationRequest::ShouldMakeNetworkRequest(const GURL& url) {
+ // Data urls should not make network requests.
+ // TODO(clamy): same document navigations should not make network requests.
+ return !url.SchemeIs(url::kDataScheme);
+}
+
+// static
scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
FrameTreeNode* frame_tree_node,
const NavigationEntryImpl& entry,
@@ -90,7 +97,8 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
CommonNavigationParams(entry.GetURL(), entry.GetReferrer(),
entry.GetTransitionType(), navigation_type,
!entry.IsViewSourceMode(),ui_timestamp,
- report_type),
+ report_type, entry.GetBaseURLForDataURL(),
+ entry.GetHistoryURLForDataURL()),
BeginNavigationParams(method, headers.ToString(),
LoadFlagFromNavigationType(navigation_type),
false),
@@ -158,13 +166,24 @@ NavigationRequest::NavigationRequest(
NavigationRequest::~NavigationRequest() {
}
-void NavigationRequest::BeginNavigation() {
+bool NavigationRequest::BeginNavigation() {
DCHECK(!loader_);
DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
state_ = STARTED;
- loader_ = NavigationURLLoader::Create(
- frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
- frame_tree_node_->frame_tree_node_id(), info_.Pass(), this);
+
+ if (ShouldMakeNetworkRequest(common_params_.url)) {
+ loader_ = NavigationURLLoader::Create(
+ frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
+ frame_tree_node_->frame_tree_node_id(), info_.Pass(), this);
+ return true;
+ }
+
+ state_ = RESPONSE_STARTED;
nasko 2015/02/26 17:35:24 nit: I'd move this state assignment after the comm
clamy 2015/02/27 12:53:59 Done.
+ // There is no need to make a network request for this navigation, so commit
+ // it immediately.
+ frame_tree_node_->navigator()->CommitNavigation(
+ frame_tree_node_, nullptr, scoped_ptr<StreamHandle>());
+ return false;
// TODO(davidben): Fire (and add as necessary) observer methods such as
// DidStartProvisionalLoadForFrame for the navigation.

Powered by Google App Engine
This is Rietveld 408576698