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 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2607 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 2607 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
2608 Activate(); | 2608 Activate(); |
2609 if (delegate_) | 2609 if (delegate_) |
2610 delegate_->ShowRepostFormWarningDialog(this); | 2610 delegate_->ShowRepostFormWarningDialog(this); |
2611 } | 2611 } |
2612 | 2612 |
2613 // Notifies the RenderWidgetHost instance about the fact that the page is | 2613 // Notifies the RenderWidgetHost instance about the fact that the page is |
2614 // loading, or done loading. | 2614 // loading, or done loading. |
2615 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, | 2615 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, |
2616 bool is_loading, | 2616 bool is_loading, |
| 2617 bool to_different_document, |
2617 LoadNotificationDetails* details) { | 2618 LoadNotificationDetails* details) { |
2618 if (is_loading == is_loading_) | 2619 if (is_loading == is_loading_) |
2619 return; | 2620 return; |
2620 | 2621 |
2621 if (!is_loading) { | 2622 if (!is_loading) { |
2622 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, | 2623 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, |
2623 base::string16()); | 2624 base::string16()); |
2624 load_state_host_.clear(); | 2625 load_state_host_.clear(); |
2625 upload_size_ = 0; | 2626 upload_size_ = 0; |
2626 upload_position_ = 0; | 2627 upload_position_ = 0; |
2627 } | 2628 } |
2628 | 2629 |
2629 GetRenderManager()->SetIsLoading(is_loading); | 2630 GetRenderManager()->SetIsLoading(is_loading); |
2630 | 2631 |
2631 is_loading_ = is_loading; | 2632 is_loading_ = is_loading; |
2632 waiting_for_response_ = is_loading; | 2633 waiting_for_response_ = is_loading; |
2633 | 2634 |
2634 if (delegate_) | 2635 if (delegate_) |
2635 delegate_->LoadingStateChanged(this); | 2636 delegate_->LoadingStateChanged(this, to_different_document); |
2636 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 2637 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
2637 | 2638 |
2638 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); | 2639 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); |
2639 if (is_loading) { | 2640 if (is_loading) { |
2640 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, | 2641 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, |
2641 "URL", url); | 2642 "URL", url); |
2642 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2643 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2643 DidStartLoading(render_view_host)); | 2644 DidStartLoading(render_view_host)); |
2644 } else { | 2645 } else { |
2645 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, | 2646 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 2896 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
2896 // renderer may not have made a clean exit. | 2897 // renderer may not have made a clean exit. |
2897 if (IsFullscreenForCurrentTab()) | 2898 if (IsFullscreenForCurrentTab()) |
2898 ToggleFullscreenMode(false); | 2899 ToggleFullscreenMode(false); |
2899 | 2900 |
2900 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 2901 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
2901 if (dialog_manager_) | 2902 if (dialog_manager_) |
2902 dialog_manager_->CancelActiveAndPendingDialogs(this); | 2903 dialog_manager_->CancelActiveAndPendingDialogs(this); |
2903 | 2904 |
2904 ClearPowerSaveBlockers(rvh); | 2905 ClearPowerSaveBlockers(rvh); |
2905 SetIsLoading(rvh, false, NULL); | 2906 SetIsLoading(rvh, false, true, NULL); |
2906 NotifyDisconnected(); | 2907 NotifyDisconnected(); |
2907 SetIsCrashed(status, error_code); | 2908 SetIsCrashed(status, error_code); |
2908 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); | 2909 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
2909 | 2910 |
2910 FOR_EACH_OBSERVER(WebContentsObserver, | 2911 FOR_EACH_OBSERVER(WebContentsObserver, |
2911 observers_, | 2912 observers_, |
2912 RenderProcessGone(GetCrashedStatus())); | 2913 RenderProcessGone(GetCrashedStatus())); |
2913 } | 2914 } |
2914 | 2915 |
2915 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2916 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 | 3025 |
3025 // Allow the navigation to proceed. | 3026 // Allow the navigation to proceed. |
3026 GetRenderManager()->SwappedOut(rvh); | 3027 GetRenderManager()->SwappedOut(rvh); |
3027 } | 3028 } |
3028 | 3029 |
3029 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3030 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
3030 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3031 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
3031 delegate_->MoveContents(this, new_bounds); | 3032 delegate_->MoveContents(this, new_bounds); |
3032 } | 3033 } |
3033 | 3034 |
3034 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host) { | 3035 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, |
3035 SetIsLoading(render_frame_host->GetRenderViewHost(), true, NULL); | 3036 bool to_different_document) { |
| 3037 SetIsLoading(render_frame_host->GetRenderViewHost(), true, |
| 3038 to_different_document, NULL); |
3036 } | 3039 } |
3037 | 3040 |
3038 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { | 3041 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { |
3039 scoped_ptr<LoadNotificationDetails> details; | 3042 scoped_ptr<LoadNotificationDetails> details; |
3040 | 3043 |
3041 // Use the last committed entry rather than the active one, in case a | 3044 // Use the last committed entry rather than the active one, in case a |
3042 // pending entry has been created. | 3045 // pending entry has been created. |
3043 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 3046 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
3044 Navigator* navigator = frame_tree_.root()->navigator(); | 3047 Navigator* navigator = frame_tree_.root()->navigator(); |
3045 | 3048 |
3046 // An entry may not exist for a stop when loading an initial blank page or | 3049 // An entry may not exist for a stop when loading an initial blank page or |
3047 // if an iframe injected by script into a blank page finishes loading. | 3050 // if an iframe injected by script into a blank page finishes loading. |
3048 if (entry) { | 3051 if (entry) { |
3049 base::TimeDelta elapsed = | 3052 base::TimeDelta elapsed = |
3050 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); | 3053 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); |
3051 | 3054 |
3052 details.reset(new LoadNotificationDetails( | 3055 details.reset(new LoadNotificationDetails( |
3053 entry->GetVirtualURL(), | 3056 entry->GetVirtualURL(), |
3054 entry->GetTransitionType(), | 3057 entry->GetTransitionType(), |
3055 elapsed, | 3058 elapsed, |
3056 &controller_, | 3059 &controller_, |
3057 controller_.GetCurrentEntryIndex())); | 3060 controller_.GetCurrentEntryIndex())); |
3058 } | 3061 } |
3059 | 3062 |
3060 SetIsLoading(render_frame_host->GetRenderViewHost(), false, details.get()); | 3063 SetIsLoading(render_frame_host->GetRenderViewHost(), false, true, |
| 3064 details.get()); |
3061 } | 3065 } |
3062 | 3066 |
3063 void WebContentsImpl::DidCancelLoading() { | 3067 void WebContentsImpl::DidCancelLoading() { |
3064 controller_.DiscardNonCommittedEntries(); | 3068 controller_.DiscardNonCommittedEntries(); |
3065 | 3069 |
3066 // Update the URL display. | 3070 // Update the URL display. |
3067 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 3071 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
3068 } | 3072 } |
3069 | 3073 |
3070 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 3074 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3630 | 3634 |
3631 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3635 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
3632 if (!delegate_) | 3636 if (!delegate_) |
3633 return; | 3637 return; |
3634 const gfx::Size new_size = GetPreferredSize(); | 3638 const gfx::Size new_size = GetPreferredSize(); |
3635 if (new_size != old_size) | 3639 if (new_size != old_size) |
3636 delegate_->UpdatePreferredSize(this, new_size); | 3640 delegate_->UpdatePreferredSize(this, new_size); |
3637 } | 3641 } |
3638 | 3642 |
3639 } // namespace content | 3643 } // namespace content |
OLD | NEW |