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 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2572 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 2572 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
| 2573 Activate(); | 2573 Activate(); |
| 2574 if (delegate_) | 2574 if (delegate_) |
| 2575 delegate_->ShowRepostFormWarningDialog(this); | 2575 delegate_->ShowRepostFormWarningDialog(this); |
| 2576 } | 2576 } |
| 2577 | 2577 |
| 2578 // Notifies the RenderWidgetHost instance about the fact that the page is | 2578 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 2579 // loading, or done loading. | 2579 // loading, or done loading. |
| 2580 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, | 2580 void WebContentsImpl::SetIsLoading(RenderViewHost* render_view_host, |
| 2581 bool is_loading, | 2581 bool is_loading, |
| 2582 bool to_different_document, | |
| 2582 LoadNotificationDetails* details) { | 2583 LoadNotificationDetails* details) { |
| 2583 if (is_loading == is_loading_) | 2584 if (is_loading == is_loading_) |
| 2584 return; | 2585 return; |
| 2585 | 2586 |
| 2586 if (!is_loading) { | 2587 if (!is_loading) { |
| 2587 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, | 2588 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, |
| 2588 base::string16()); | 2589 base::string16()); |
| 2589 load_state_host_.clear(); | 2590 load_state_host_.clear(); |
| 2590 upload_size_ = 0; | 2591 upload_size_ = 0; |
| 2591 upload_position_ = 0; | 2592 upload_position_ = 0; |
| 2592 } | 2593 } |
| 2593 | 2594 |
| 2594 GetRenderManager()->SetIsLoading(is_loading); | 2595 GetRenderManager()->SetIsLoading(is_loading); |
| 2595 | 2596 |
| 2596 is_loading_ = is_loading; | 2597 is_loading_ = is_loading; |
| 2597 waiting_for_response_ = is_loading; | 2598 waiting_for_response_ = is_loading; |
| 2598 | 2599 |
| 2599 if (delegate_) | 2600 if (delegate_) |
| 2600 delegate_->LoadingStateChanged(this); | 2601 delegate_->LoadingStateChanged(this, to_different_document); |
| 2601 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 2602 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
| 2602 | 2603 |
| 2603 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); | 2604 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); |
| 2604 if (is_loading) { | 2605 if (is_loading) { |
| 2605 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, | 2606 TRACE_EVENT_ASYNC_BEGIN1("browser", "WebContentsImpl Loading", this, |
| 2606 "URL", url); | 2607 "URL", url); |
| 2607 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2608 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2608 DidStartLoading(render_view_host)); | 2609 DidStartLoading(render_view_host)); |
| 2609 } else { | 2610 } else { |
| 2610 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, | 2611 TRACE_EVENT_ASYNC_END1("browser", "WebContentsImpl Loading", this, |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2865 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 2866 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
| 2866 // renderer may not have made a clean exit. | 2867 // renderer may not have made a clean exit. |
| 2867 if (IsFullscreenForCurrentTab()) | 2868 if (IsFullscreenForCurrentTab()) |
| 2868 ToggleFullscreenMode(false); | 2869 ToggleFullscreenMode(false); |
| 2869 | 2870 |
| 2870 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 2871 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
| 2871 if (dialog_manager_) | 2872 if (dialog_manager_) |
| 2872 dialog_manager_->CancelActiveAndPendingDialogs(this); | 2873 dialog_manager_->CancelActiveAndPendingDialogs(this); |
| 2873 | 2874 |
| 2874 ClearPowerSaveBlockers(rvh); | 2875 ClearPowerSaveBlockers(rvh); |
| 2875 SetIsLoading(rvh, false, NULL); | 2876 SetIsLoading(rvh, false, true, NULL); |
| 2876 NotifyDisconnected(); | 2877 NotifyDisconnected(); |
| 2877 SetIsCrashed(status, error_code); | 2878 SetIsCrashed(status, error_code); |
| 2878 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); | 2879 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
| 2879 | 2880 |
| 2880 FOR_EACH_OBSERVER(WebContentsObserver, | 2881 FOR_EACH_OBSERVER(WebContentsObserver, |
| 2881 observers_, | 2882 observers_, |
| 2882 RenderProcessGone(GetCrashedStatus())); | 2883 RenderProcessGone(GetCrashedStatus())); |
| 2883 } | 2884 } |
| 2884 | 2885 |
| 2885 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2886 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2994 | 2995 |
| 2995 // Allow the navigation to proceed. | 2996 // Allow the navigation to proceed. |
| 2996 GetRenderManager()->SwappedOut(rvh); | 2997 GetRenderManager()->SwappedOut(rvh); |
| 2997 } | 2998 } |
| 2998 | 2999 |
| 2999 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3000 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 3000 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3001 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 3001 delegate_->MoveContents(this, new_bounds); | 3002 delegate_->MoveContents(this, new_bounds); |
| 3002 } | 3003 } |
| 3003 | 3004 |
| 3004 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host) { | 3005 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, |
| 3005 SetIsLoading(render_frame_host->GetRenderViewHost(), true, NULL); | 3006 bool to_different_document) { |
| 3007 SetIsLoading(render_frame_host->GetRenderViewHost(), true, | |
| 3008 to_different_document, NULL); | |
|
Charlie Reis
2014/03/10 20:07:46
nit: Align with first argument.
| |
| 3006 } | 3009 } |
| 3007 | 3010 |
| 3008 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { | 3011 void WebContentsImpl::DidStopLoading(RenderFrameHost* render_frame_host) { |
| 3009 scoped_ptr<LoadNotificationDetails> details; | 3012 scoped_ptr<LoadNotificationDetails> details; |
| 3010 | 3013 |
| 3011 // Use the last committed entry rather than the active one, in case a | 3014 // Use the last committed entry rather than the active one, in case a |
| 3012 // pending entry has been created. | 3015 // pending entry has been created. |
| 3013 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 3016 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
| 3014 Navigator* navigator = frame_tree_.root()->navigator(); | 3017 Navigator* navigator = frame_tree_.root()->navigator(); |
| 3015 | 3018 |
| 3016 // An entry may not exist for a stop when loading an initial blank page or | 3019 // An entry may not exist for a stop when loading an initial blank page or |
| 3017 // if an iframe injected by script into a blank page finishes loading. | 3020 // if an iframe injected by script into a blank page finishes loading. |
| 3018 if (entry) { | 3021 if (entry) { |
| 3019 base::TimeDelta elapsed = | 3022 base::TimeDelta elapsed = |
| 3020 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); | 3023 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); |
| 3021 | 3024 |
| 3022 details.reset(new LoadNotificationDetails( | 3025 details.reset(new LoadNotificationDetails( |
| 3023 entry->GetVirtualURL(), | 3026 entry->GetVirtualURL(), |
| 3024 entry->GetTransitionType(), | 3027 entry->GetTransitionType(), |
| 3025 elapsed, | 3028 elapsed, |
| 3026 &controller_, | 3029 &controller_, |
| 3027 controller_.GetCurrentEntryIndex())); | 3030 controller_.GetCurrentEntryIndex())); |
| 3028 } | 3031 } |
| 3029 | 3032 |
| 3030 SetIsLoading(render_frame_host->GetRenderViewHost(), false, details.get()); | 3033 SetIsLoading(render_frame_host->GetRenderViewHost(), false, true, |
| 3034 details.get()); | |
|
Charlie Reis
2014/03/10 20:07:46
nit: align with first argument.
| |
| 3031 } | 3035 } |
| 3032 | 3036 |
| 3033 void WebContentsImpl::DidCancelLoading() { | 3037 void WebContentsImpl::DidCancelLoading() { |
| 3034 controller_.DiscardNonCommittedEntries(); | 3038 controller_.DiscardNonCommittedEntries(); |
| 3035 | 3039 |
| 3036 // Update the URL display. | 3040 // Update the URL display. |
| 3037 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 3041 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 3038 } | 3042 } |
| 3039 | 3043 |
| 3040 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 3044 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3600 | 3604 |
| 3601 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3605 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 3602 if (!delegate_) | 3606 if (!delegate_) |
| 3603 return; | 3607 return; |
| 3604 const gfx::Size new_size = GetPreferredSize(); | 3608 const gfx::Size new_size = GetPreferredSize(); |
| 3605 if (new_size != old_size) | 3609 if (new_size != old_size) |
| 3606 delegate_->UpdatePreferredSize(this, new_size); | 3610 delegate_->UpdatePreferredSize(this, new_size); |
| 3607 } | 3611 } |
| 3608 | 3612 |
| 3609 } // namespace content | 3613 } // namespace content |
| OLD | NEW |