Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2546 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 2546 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
| 2547 Activate(); | 2547 Activate(); |
| 2548 if (delegate_) | 2548 if (delegate_) |
| 2549 delegate_->ShowRepostFormWarningDialog(this); | 2549 delegate_->ShowRepostFormWarningDialog(this); |
| 2550 } | 2550 } |
| 2551 | 2551 |
| 2552 // Notifies the RenderWidgetHost instance about the fact that the page is | 2552 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 2553 // loading, or done loading. | 2553 // loading, or done loading. |
| 2554 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, | 2554 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, |
| 2555 bool is_loading, | 2555 bool is_loading, |
| 2556 bool to_different_document, | |
| 2556 LoadNotificationDetails* details) { | 2557 LoadNotificationDetails* details) { |
| 2557 if (is_loading == is_loading_) | 2558 if (is_loading == is_loading_) |
| 2558 return; | 2559 return; |
| 2559 | 2560 |
| 2560 if (!is_loading) { | 2561 if (!is_loading) { |
| 2561 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, | 2562 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, |
| 2562 base::string16()); | 2563 base::string16()); |
| 2563 load_state_host_.clear(); | 2564 load_state_host_.clear(); |
| 2564 upload_size_ = 0; | 2565 upload_size_ = 0; |
| 2565 upload_position_ = 0; | 2566 upload_position_ = 0; |
| 2566 } | 2567 } |
| 2567 | 2568 |
| 2568 GetRenderManager()->SetIsLoading(is_loading); | 2569 GetRenderManager()->SetIsLoading(is_loading); |
| 2569 | 2570 |
| 2570 is_loading_ = is_loading; | 2571 is_loading_ = is_loading; |
| 2571 waiting_for_response_ = is_loading; | 2572 waiting_for_response_ = is_loading; |
| 2572 | 2573 |
| 2573 if (delegate_) | 2574 if (to_different_document) { |
|
sky
2014/02/13 22:25:26
Seems like the delegate/observers should be told t
| |
| 2574 delegate_->LoadingStateChanged(this); | 2575 if (delegate_) |
| 2575 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 2576 delegate_->LoadingStateChanged(this); |
| 2577 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | |
| 2578 } | |
| 2576 | 2579 |
| 2577 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); | 2580 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); |
| 2578 if (is_loading) { | 2581 if (is_loading) { |
| 2579 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, | 2582 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, |
| 2580 "URL", url); | 2583 "URL", url); |
| 2581 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2584 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2582 DidStartLoading(render_view_host)); | 2585 DidStartLoading(render_view_host)); |
| 2583 } else { | 2586 } else { |
| 2584 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, | 2587 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, |
| 2585 "URL", url); | 2588 "URL", url); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2830 | 2833 |
| 2831 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, | 2834 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, |
| 2832 base::TerminationStatus status, | 2835 base::TerminationStatus status, |
| 2833 int error_code) { | 2836 int error_code) { |
| 2834 if (rvh != GetRenderViewHost()) { | 2837 if (rvh != GetRenderViewHost()) { |
| 2835 // The pending page's RenderViewHost is gone. | 2838 // The pending page's RenderViewHost is gone. |
| 2836 return; | 2839 return; |
| 2837 } | 2840 } |
| 2838 | 2841 |
| 2839 ClearPowerSaveBlockers(rvh); | 2842 ClearPowerSaveBlockers(rvh); |
| 2840 SetIsLoading(rvh, false, NULL); | 2843 SetIsLoading(rvh, false, true, NULL); |
| 2841 NotifyDisconnected(); | 2844 NotifyDisconnected(); |
| 2842 SetIsCrashed(status, error_code); | 2845 SetIsCrashed(status, error_code); |
| 2843 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); | 2846 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
| 2844 | 2847 |
| 2845 FOR_EACH_OBSERVER(WebContentsObserver, | 2848 FOR_EACH_OBSERVER(WebContentsObserver, |
| 2846 observers_, | 2849 observers_, |
| 2847 RenderProcessGone(GetCrashedStatus())); | 2850 RenderProcessGone(GetCrashedStatus())); |
| 2848 } | 2851 } |
| 2849 | 2852 |
| 2850 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2853 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2948 | 2951 |
| 2949 // Allow the navigation to proceed. | 2952 // Allow the navigation to proceed. |
| 2950 GetRenderManager()->SwappedOut(rvh); | 2953 GetRenderManager()->SwappedOut(rvh); |
| 2951 } | 2954 } |
| 2952 | 2955 |
| 2953 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 2956 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 2954 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 2957 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 2955 delegate_->MoveContents(this, new_bounds); | 2958 delegate_->MoveContents(this, new_bounds); |
| 2956 } | 2959 } |
| 2957 | 2960 |
| 2958 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host) { | 2961 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, |
| 2959 SetIsLoading(render_frame_host->GetRenderViewHost(), true, NULL); | 2962 bool to_different_document) { |
| 2963 SetIsLoading(render_frame_host->GetRenderViewHost(), true, | |
| 2964 to_different_document, NULL); | |
| 2960 } | 2965 } |
| 2961 | 2966 |
| 2962 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { | 2967 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { |
| 2963 scoped_ptr<LoadNotificationDetails> details; | 2968 scoped_ptr<LoadNotificationDetails> details; |
| 2964 | 2969 |
| 2965 // Use the last committed entry rather than the active one, in case a | 2970 // Use the last committed entry rather than the active one, in case a |
| 2966 // pending entry has been created. | 2971 // pending entry has been created. |
| 2967 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 2972 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
| 2968 Navigator* navigator = frame_tree_.root()->navigator(); | 2973 Navigator* navigator = frame_tree_.root()->navigator(); |
| 2969 | 2974 |
| 2970 // An entry may not exist for a stop when loading an initial blank page or | 2975 // An entry may not exist for a stop when loading an initial blank page or |
| 2971 // if an iframe injected by script into a blank page finishes loading. | 2976 // if an iframe injected by script into a blank page finishes loading. |
| 2972 if (entry) { | 2977 if (entry) { |
| 2973 base::TimeDelta elapsed = | 2978 base::TimeDelta elapsed = |
| 2974 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); | 2979 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); |
| 2975 | 2980 |
| 2976 details.reset(new LoadNotificationDetails( | 2981 details.reset(new LoadNotificationDetails( |
| 2977 entry->GetVirtualURL(), | 2982 entry->GetVirtualURL(), |
| 2978 entry->GetTransitionType(), | 2983 entry->GetTransitionType(), |
| 2979 elapsed, | 2984 elapsed, |
| 2980 &controller_, | 2985 &controller_, |
| 2981 controller_.GetCurrentEntryIndex())); | 2986 controller_.GetCurrentEntryIndex())); |
| 2982 } | 2987 } |
| 2983 | 2988 |
| 2984 SetIsLoading(render_frame_host->GetRenderViewHost(), false, details.get()); | 2989 SetIsLoading(render_frame_host->GetRenderViewHost(), false, true, |
| 2990 details.get()); | |
| 2985 } | 2991 } |
| 2986 | 2992 |
| 2987 void WebContentsImpl::DidCancelLoading() { | 2993 void WebContentsImpl::DidCancelLoading() { |
| 2988 controller_.DiscardNonCommittedEntries(); | 2994 controller_.DiscardNonCommittedEntries(); |
| 2989 | 2995 |
| 2990 // Update the URL display. | 2996 // Update the URL display. |
| 2991 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 2997 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 2992 } | 2998 } |
| 2993 | 2999 |
| 2994 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 3000 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3643 | 3649 |
| 3644 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3650 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 3645 if (!delegate_) | 3651 if (!delegate_) |
| 3646 return; | 3652 return; |
| 3647 const gfx::Size new_size = GetPreferredSize(); | 3653 const gfx::Size new_size = GetPreferredSize(); |
| 3648 if (new_size != old_size) | 3654 if (new_size != old_size) |
| 3649 delegate_->UpdatePreferredSize(this, new_size); | 3655 delegate_->UpdatePreferredSize(this, new_size); |
| 3650 } | 3656 } |
| 3651 | 3657 |
| 3652 } // namespace content | 3658 } // namespace content |
| OLD | NEW |