OLD | NEW |
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/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void NavigationHandleImpl::WillProcessResponse( | 383 void NavigationHandleImpl::WillProcessResponse( |
384 RenderFrameHostImpl* render_frame_host, | 384 RenderFrameHostImpl* render_frame_host, |
385 scoped_refptr<net::HttpResponseHeaders> response_headers, | 385 scoped_refptr<net::HttpResponseHeaders> response_headers, |
386 const ThrottleChecksFinishedCallback& callback) { | 386 const ThrottleChecksFinishedCallback& callback) { |
387 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 387 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
388 render_frame_host_ = render_frame_host; | 388 render_frame_host_ = render_frame_host; |
389 response_headers_ = response_headers; | 389 response_headers_ = response_headers; |
390 state_ = WILL_PROCESS_RESPONSE; | 390 state_ = WILL_PROCESS_RESPONSE; |
391 complete_callback_ = callback; | 391 complete_callback_ = callback; |
392 | 392 |
| 393 // Clear out the pending console message queue now that we have a |
| 394 // render_frame_host. |
| 395 // |
| 396 // TODO(mkwst): Move this to 'ReadyToCommitNavigation' as part of the work |
| 397 // in https://crbug.com/621856. |
| 398 DumpMessagesToConsole(); |
| 399 |
393 // Notify each throttle of the response. | 400 // Notify each throttle of the response. |
394 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 401 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
395 | 402 |
396 // If the navigation is about to proceed, then it's ready to commit. | 403 // If the navigation is about to proceed, then it's ready to commit. |
397 if (result == NavigationThrottle::PROCEED) | 404 if (result == NavigationThrottle::PROCEED) |
398 ReadyToCommitNavigation(render_frame_host); | 405 ReadyToCommitNavigation(render_frame_host); |
399 | 406 |
400 // If the navigation is not deferred, run the callback. | 407 // If the navigation is not deferred, run the callback. |
401 if (result != NavigationThrottle::DEFER) | 408 if (result != NavigationThrottle::DEFER) |
402 RunCompleteCallback(result); | 409 RunCompleteCallback(result); |
(...skipping 21 matching lines...) Expand all Loading... |
424 | 431 |
425 method_ = params.method; | 432 method_ = params.method; |
426 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 433 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
427 transition_ = params.transition; | 434 transition_ = params.transition; |
428 render_frame_host_ = render_frame_host; | 435 render_frame_host_ = render_frame_host; |
429 is_same_page_ = same_page; | 436 is_same_page_ = same_page; |
430 | 437 |
431 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; | 438 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; |
432 } | 439 } |
433 | 440 |
| 441 void NavigationHandleImpl::QueueConsoleMessage(ConsoleMessageLevel level, |
| 442 const std::string& message) { |
| 443 console_queue_.emplace(level, message); |
| 444 |
| 445 if (state_ >= WILL_PROCESS_RESPONSE) |
| 446 DumpMessagesToConsole(); |
| 447 } |
| 448 |
434 NavigationThrottle::ThrottleCheckResult | 449 NavigationThrottle::ThrottleCheckResult |
435 NavigationHandleImpl::CheckWillStartRequest() { | 450 NavigationHandleImpl::CheckWillStartRequest() { |
436 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 451 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
437 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 452 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
438 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 453 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
439 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 454 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
440 NavigationThrottle::ThrottleCheckResult result = | 455 NavigationThrottle::ThrottleCheckResult result = |
441 throttles_[i]->WillStartRequest(); | 456 throttles_[i]->WillStartRequest(); |
442 switch (result) { | 457 switch (result) { |
443 case NavigationThrottle::PROCEED: | 458 case NavigationThrottle::PROCEED: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 ThrottleChecksFinishedCallback callback = complete_callback_; | 549 ThrottleChecksFinishedCallback callback = complete_callback_; |
535 complete_callback_.Reset(); | 550 complete_callback_.Reset(); |
536 | 551 |
537 if (!callback.is_null()) | 552 if (!callback.is_null()) |
538 callback.Run(result); | 553 callback.Run(result); |
539 | 554 |
540 // No code after running the callback, as it might have resulted in our | 555 // No code after running the callback, as it might have resulted in our |
541 // destruction. | 556 // destruction. |
542 } | 557 } |
543 | 558 |
| 559 void NavigationHandleImpl::DumpMessagesToConsole() { |
| 560 DCHECK_GE(state_, WILL_PROCESS_RESPONSE); |
| 561 DCHECK(GetRenderFrameHost()); |
| 562 |
| 563 while (!console_queue_.empty()) { |
| 564 GetRenderFrameHost()->AddMessageToConsole(console_queue_.front().first, |
| 565 console_queue_.front().second); |
| 566 console_queue_.pop(); |
| 567 } |
| 568 } |
| 569 |
544 } // namespace content | 570 } // namespace content |
OLD | NEW |