Chromium Code Reviews| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 | 237 |
| 238 void NavigationHandleImpl::CancelDeferredNavigation( | 238 void NavigationHandleImpl::CancelDeferredNavigation( |
| 239 NavigationThrottle::ThrottleCheckResult result) { | 239 NavigationThrottle::ThrottleCheckResult result) { |
| 240 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 240 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); |
| 241 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 241 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| 242 result == NavigationThrottle::CANCEL); | 242 result == NavigationThrottle::CANCEL); |
| 243 state_ = CANCELING; | 243 state_ = CANCELING; |
| 244 RunCompleteCallback(result); | 244 RunCompleteCallback(result); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void NavigationHandleImpl::QueueConsoleMessage(ConsoleMessageLevel level, | |
| 248 const std::string& message) { | |
| 249 console_queue_.emplace(level, message); | |
| 250 | |
| 251 if (state_ >= WILL_PROCESS_RESPONSE) | |
| 252 DumpMessagesToConsole(); | |
| 253 } | |
| 254 | |
| 247 void NavigationHandleImpl::RegisterThrottleForTesting( | 255 void NavigationHandleImpl::RegisterThrottleForTesting( |
| 248 std::unique_ptr<NavigationThrottle> navigation_throttle) { | 256 std::unique_ptr<NavigationThrottle> navigation_throttle) { |
| 249 throttles_.push_back(std::move(navigation_throttle)); | 257 throttles_.push_back(std::move(navigation_throttle)); |
| 250 } | 258 } |
| 251 | 259 |
| 252 NavigationThrottle::ThrottleCheckResult | 260 NavigationThrottle::ThrottleCheckResult |
| 253 NavigationHandleImpl::CallWillStartRequestForTesting( | 261 NavigationHandleImpl::CallWillStartRequestForTesting( |
| 254 bool is_post, | 262 bool is_post, |
| 255 const Referrer& sanitized_referrer, | 263 const Referrer& sanitized_referrer, |
| 256 bool has_user_gesture, | 264 bool has_user_gesture, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 void NavigationHandleImpl::WillProcessResponse( | 391 void NavigationHandleImpl::WillProcessResponse( |
| 384 RenderFrameHostImpl* render_frame_host, | 392 RenderFrameHostImpl* render_frame_host, |
| 385 scoped_refptr<net::HttpResponseHeaders> response_headers, | 393 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 386 const ThrottleChecksFinishedCallback& callback) { | 394 const ThrottleChecksFinishedCallback& callback) { |
| 387 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 395 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 388 render_frame_host_ = render_frame_host; | 396 render_frame_host_ = render_frame_host; |
| 389 response_headers_ = response_headers; | 397 response_headers_ = response_headers; |
| 390 state_ = WILL_PROCESS_RESPONSE; | 398 state_ = WILL_PROCESS_RESPONSE; |
| 391 complete_callback_ = callback; | 399 complete_callback_ = callback; |
| 392 | 400 |
| 401 // Clear out the pending console message queue now that we have a | |
| 402 // render_frame_host. | |
| 403 // | |
| 404 // TODO(mkwst): Move this to 'ReadyToCommitNavigation' as part of the work | |
| 405 // in https://crbug.com/621856. | |
| 406 DumpMessagesToConsole(); | |
|
clamy
2016/06/28 11:30:38
This is problematic right now for transfer navigat
Mike West
2016/06/28 12:22:33
It's no more problematic than getting the RenderFr
| |
| 407 | |
| 393 // Notify each throttle of the response. | 408 // Notify each throttle of the response. |
| 394 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 409 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 395 | 410 |
| 396 // If the navigation is about to proceed, then it's ready to commit. | 411 // If the navigation is about to proceed, then it's ready to commit. |
| 397 if (result == NavigationThrottle::PROCEED) | 412 if (result == NavigationThrottle::PROCEED) |
| 398 ReadyToCommitNavigation(render_frame_host); | 413 ReadyToCommitNavigation(render_frame_host); |
| 399 | 414 |
| 400 // If the navigation is not deferred, run the callback. | 415 // If the navigation is not deferred, run the callback. |
| 401 if (result != NavigationThrottle::DEFER) | 416 if (result != NavigationThrottle::DEFER) |
| 402 RunCompleteCallback(result); | 417 RunCompleteCallback(result); |
| (...skipping 131 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 |