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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2161073002: Adds RequestContextType information to the NavigationHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 is_renderer_initiated_(is_renderer_initiated), 65 is_renderer_initiated_(is_renderer_initiated),
66 is_same_page_(false), 66 is_same_page_(false),
67 is_synchronous_(is_synchronous), 67 is_synchronous_(is_synchronous),
68 is_srcdoc_(is_srcdoc), 68 is_srcdoc_(is_srcdoc),
69 was_redirected_(false), 69 was_redirected_(false),
70 state_(INITIAL), 70 state_(INITIAL),
71 is_transferring_(false), 71 is_transferring_(false),
72 frame_tree_node_(frame_tree_node), 72 frame_tree_node_(frame_tree_node),
73 next_index_(0), 73 next_index_(0),
74 navigation_start_(navigation_start), 74 navigation_start_(navigation_start),
75 pending_nav_entry_id_(pending_nav_entry_id) { 75 pending_nav_entry_id_(pending_nav_entry_id) {
Mike West 2016/07/20 09:52:46 Can you please initialize `fetch_request_context_t
carlosk 2016/07/20 10:12:01 Done. I missed that.
76 DCHECK(!navigation_start.is_null()); 76 DCHECK(!navigation_start.is_null());
77 GetDelegate()->DidStartNavigation(this); 77 GetDelegate()->DidStartNavigation(this);
78 78
79 if (IsInMainFrame()) { 79 if (IsInMainFrame()) {
80 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( 80 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1(
81 "navigation", "Navigation StartToCommit", this, 81 "navigation", "Navigation StartToCommit", this,
82 navigation_start.ToInternalValue(), "Initial URL", url_.spec()); 82 navigation_start.ToInternalValue(), "Initial URL", url_.spec());
83 } 83 }
84 } 84 }
85 85
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (is_post) { 263 if (is_post) {
264 method = "POST"; 264 method = "POST";
265 265
266 std::string body = "test=body"; 266 std::string body = "test=body";
267 resource_request_body = new ResourceRequestBodyImpl(); 267 resource_request_body = new ResourceRequestBodyImpl();
268 resource_request_body->AppendBytes(body.data(), body.size()); 268 resource_request_body->AppendBytes(body.data(), body.size());
269 } 269 }
270 270
271 WillStartRequest(method, resource_request_body, sanitized_referrer, 271 WillStartRequest(method, resource_request_body, sanitized_referrer,
272 has_user_gesture, transition, is_external_protocol, 272 has_user_gesture, transition, is_external_protocol,
273 REQUEST_CONTEXT_TYPE_LOCATION,
273 base::Bind(&UpdateThrottleCheckResult, &result)); 274 base::Bind(&UpdateThrottleCheckResult, &result));
274 275
275 // Reset the callback to ensure it will not be called later. 276 // Reset the callback to ensure it will not be called later.
276 complete_callback_.Reset(); 277 complete_callback_.Reset();
277 return result; 278 return result;
278 } 279 }
279 280
280 NavigationThrottle::ThrottleCheckResult 281 NavigationThrottle::ThrottleCheckResult
281 NavigationHandleImpl::CallWillRedirectRequestForTesting( 282 NavigationHandleImpl::CallWillRedirectRequestForTesting(
282 const GURL& new_url, 283 const GURL& new_url,
(...skipping 15 matching lines...) Expand all
298 return navigation_data_.get(); 299 return navigation_data_.get();
299 } 300 }
300 301
301 void NavigationHandleImpl::WillStartRequest( 302 void NavigationHandleImpl::WillStartRequest(
302 const std::string& method, 303 const std::string& method,
303 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, 304 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body,
304 const Referrer& sanitized_referrer, 305 const Referrer& sanitized_referrer,
305 bool has_user_gesture, 306 bool has_user_gesture,
306 ui::PageTransition transition, 307 ui::PageTransition transition,
307 bool is_external_protocol, 308 bool is_external_protocol,
309 RequestContextType fetch_request_context_type,
308 const ThrottleChecksFinishedCallback& callback) { 310 const ThrottleChecksFinishedCallback& callback) {
309 // |method != "POST"| should imply absence of |resource_request_body|. 311 // |method != "POST"| should imply absence of |resource_request_body|.
310 if (method != "POST" && resource_request_body) { 312 if (method != "POST" && resource_request_body) {
311 NOTREACHED(); 313 NOTREACHED();
312 resource_request_body = nullptr; 314 resource_request_body = nullptr;
313 } 315 }
314 316
315 // Update the navigation parameters. 317 // Update the navigation parameters.
316 method_ = method; 318 method_ = method;
317 if (method_ == "POST") 319 if (method_ == "POST")
318 resource_request_body_ = resource_request_body; 320 resource_request_body_ = resource_request_body;
319 sanitized_referrer_ = sanitized_referrer; 321 sanitized_referrer_ = sanitized_referrer;
320 has_user_gesture_ = has_user_gesture; 322 has_user_gesture_ = has_user_gesture;
321 transition_ = transition; 323 transition_ = transition;
322 is_external_protocol_ = is_external_protocol; 324 is_external_protocol_ = is_external_protocol;
323 325 fetch_request_context_type_ = fetch_request_context_type;
324 state_ = WILL_SEND_REQUEST; 326 state_ = WILL_SEND_REQUEST;
325 complete_callback_ = callback; 327 complete_callback_ = callback;
326 328
327 RegisterNavigationThrottles(); 329 RegisterNavigationThrottles();
328 330
329 // Notify each throttle of the request. 331 // Notify each throttle of the request.
330 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); 332 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest();
331 333
332 // If the navigation is not deferred, run the callback. 334 // If the navigation is not deferred, run the callback.
333 if (result != NavigationThrottle::DEFER) 335 if (result != NavigationThrottle::DEFER)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 throttles_to_register.end()); 538 throttles_to_register.end());
537 throttles_to_register.weak_clear(); 539 throttles_to_register.weak_clear();
538 } 540 }
539 std::unique_ptr<NavigationThrottle> devtools_throttle = 541 std::unique_ptr<NavigationThrottle> devtools_throttle =
540 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); 542 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this);
541 if (devtools_throttle) 543 if (devtools_throttle)
542 throttles_.push_back(devtools_throttle.release()); 544 throttles_.push_back(devtools_throttle.release());
543 } 545 }
544 546
545 } // namespace content 547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698