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..f504d04df09cfacae0a56e3a5e9dd26c2170747f 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 nto make netwrok requests. |
Charlie Reis
2015/02/20 22:11:50
nit: not
nit: network
clamy
2015/02/26 15:28:36
Done.
|
+ return !url.SchemeIs(url::kDataScheme); |
+} |
+ |
+// static |
scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
FrameTreeNode* frame_tree_node, |
const NavigationEntryImpl& entry, |
@@ -85,12 +92,16 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
ui_timestamp = entry.intent_received_timestamp(); |
#endif |
+ const GURL history_url_for_data_url = |
+ entry.GetBaseURLForDataURL().is_empty() ? GURL() : entry.GetVirtualURL(); |
+ |
scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
frame_tree_node, |
CommonNavigationParams(entry.GetURL(), entry.GetReferrer(), |
entry.GetTransitionType(), navigation_type, |
!entry.IsViewSourceMode(),ui_timestamp, |
- report_type), |
+ report_type, entry.GetBaseURLForDataURL(), |
+ history_url_for_data_url), |
BeginNavigationParams(method, headers.ToString(), |
LoadFlagFromNavigationType(navigation_type), |
false), |
@@ -158,13 +169,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; |
+ // 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. |