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

Side by Side 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: Rebase + change to unit test Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "content/browser/frame_host/frame_tree.h" 7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/frame_host/frame_tree_node.h" 8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "content/browser/frame_host/navigation_request_info.h" 9 #include "content/browser/frame_host/navigation_request_info.h"
10 #include "content/browser/frame_host/navigator.h" 10 #include "content/browser/frame_host/navigator.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 case FrameMsg_Navigate_Type::NORMAL: 43 case FrameMsg_Navigate_Type::NORMAL:
44 default: 44 default:
45 break; 45 break;
46 } 46 }
47 return load_flags; 47 return load_flags;
48 } 48 }
49 49
50 } // namespace 50 } // namespace
51 51
52 // static 52 // static
53 bool NavigationRequest::ShouldMakeNetworkRequest(const GURL& url) {
54 // Data urls should not make network requests.
55 // TODO(clamy): same document navigations should not make network requests.
56 return !url.SchemeIs(url::kDataScheme);
57 }
58
59 // static
53 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( 60 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
54 FrameTreeNode* frame_tree_node, 61 FrameTreeNode* frame_tree_node,
55 const NavigationEntryImpl& entry, 62 const NavigationEntryImpl& entry,
56 FrameMsg_Navigate_Type::Value navigation_type, 63 FrameMsg_Navigate_Type::Value navigation_type,
57 base::TimeTicks navigation_start) { 64 base::TimeTicks navigation_start) {
58 std::string method = entry.GetHasPostData() ? "POST" : "GET"; 65 std::string method = entry.GetHasPostData() ? "POST" : "GET";
59 66
60 // Copy existing headers and add necessary headers that may not be present 67 // Copy existing headers and add necessary headers that may not be present
61 // in the RequestNavigationParams. 68 // in the RequestNavigationParams.
62 net::HttpRequestHeaders headers; 69 net::HttpRequestHeaders headers;
(...skipping 20 matching lines...) Expand all
83 if (!entry.intent_received_timestamp().is_null()) 90 if (!entry.intent_received_timestamp().is_null())
84 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; 91 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT;
85 ui_timestamp = entry.intent_received_timestamp(); 92 ui_timestamp = entry.intent_received_timestamp();
86 #endif 93 #endif
87 94
88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( 95 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest(
89 frame_tree_node, 96 frame_tree_node,
90 CommonNavigationParams(entry.GetURL(), entry.GetReferrer(), 97 CommonNavigationParams(entry.GetURL(), entry.GetReferrer(),
91 entry.GetTransitionType(), navigation_type, 98 entry.GetTransitionType(), navigation_type,
92 !entry.IsViewSourceMode(),ui_timestamp, 99 !entry.IsViewSourceMode(),ui_timestamp,
93 report_type), 100 report_type, entry.GetBaseURLForDataURL(),
101 entry.GetHistoryURLForDataURL()),
94 BeginNavigationParams(method, headers.ToString(), 102 BeginNavigationParams(method, headers.ToString(),
95 LoadFlagFromNavigationType(navigation_type), 103 LoadFlagFromNavigationType(navigation_type),
96 false), 104 false),
97 CommitNavigationParams(entry.GetPageState(), 105 CommitNavigationParams(entry.GetPageState(),
98 entry.GetIsOverridingUserAgent(), 106 entry.GetIsOverridingUserAgent(),
99 navigation_start), 107 navigation_start),
100 request_body, true, &entry)); 108 request_body, true, &entry));
101 return navigation_request.Pass(); 109 return navigation_request.Pass();
102 } 110 }
103 111
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bool parent_is_main_frame = !frame_tree_node->parent() ? 159 bool parent_is_main_frame = !frame_tree_node->parent() ?
152 false : frame_tree_node->parent()->IsMainFrame(); 160 false : frame_tree_node->parent()->IsMainFrame();
153 info_.reset(new NavigationRequestInfo( 161 info_.reset(new NavigationRequestInfo(
154 common_params, begin_params, first_party_for_cookies, 162 common_params, begin_params, first_party_for_cookies,
155 frame_tree_node->IsMainFrame(), parent_is_main_frame, body)); 163 frame_tree_node->IsMainFrame(), parent_is_main_frame, body));
156 } 164 }
157 165
158 NavigationRequest::~NavigationRequest() { 166 NavigationRequest::~NavigationRequest() {
159 } 167 }
160 168
161 void NavigationRequest::BeginNavigation() { 169 bool NavigationRequest::BeginNavigation() {
162 DCHECK(!loader_); 170 DCHECK(!loader_);
163 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 171 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
164 state_ = STARTED; 172 state_ = STARTED;
165 loader_ = NavigationURLLoader::Create( 173
166 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 174 if (ShouldMakeNetworkRequest(common_params_.url)) {
167 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); 175 loader_ = NavigationURLLoader::Create(
176 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
177 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this);
178 return true;
179 }
180
181 // There is no need to make a network request for this navigation, so commit
182 // it immediately.
183 state_ = RESPONSE_STARTED;
184 frame_tree_node_->navigator()->CommitNavigation(
185 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>());
186 return false;
168 187
169 // TODO(davidben): Fire (and add as necessary) observer methods such as 188 // TODO(davidben): Fire (and add as necessary) observer methods such as
170 // DidStartProvisionalLoadForFrame for the navigation. 189 // DidStartProvisionalLoadForFrame for the navigation.
171 } 190 }
172 191
173 void NavigationRequest::OnRequestRedirected( 192 void NavigationRequest::OnRequestRedirected(
174 const net::RedirectInfo& redirect_info, 193 const net::RedirectInfo& redirect_info,
175 const scoped_refptr<ResourceResponse>& response) { 194 const scoped_refptr<ResourceResponse>& response) {
176 // TODO(davidben): Track other changes from redirects. These are important 195 // TODO(davidben): Track other changes from redirects. These are important
177 // for, e.g., reloads. 196 // for, e.g., reloads.
(...skipping 19 matching lines...) Expand all
197 // TODO(davidben): Network failures should display a network error page. 216 // TODO(davidben): Network failures should display a network error page.
198 NOTIMPLEMENTED() << " where net_error=" << net_error; 217 NOTIMPLEMENTED() << " where net_error=" << net_error;
199 } 218 }
200 219
201 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 220 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
202 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 221 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
203 common_params_.url); 222 common_params_.url);
204 } 223 }
205 224
206 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698