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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 ->render_manager() | 195 ->render_manager() |
| 196 ->GetRenderWidgetHostView(); | 196 ->GetRenderWidgetHostView(); |
| 197 set->insert(rwhv); | 197 set->insert(rwhv); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void SetAccessibilityModeOnFrame(AccessibilityMode mode, | 200 void SetAccessibilityModeOnFrame(AccessibilityMode mode, |
| 201 RenderFrameHost* frame_host) { | 201 RenderFrameHost* frame_host) { |
| 202 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); | 202 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); |
| 203 } | 203 } |
| 204 | 204 |
| 205 | |
| 206 } // namespace | 205 } // namespace |
| 207 | 206 |
| 208 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 207 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| 209 return WebContentsImpl::CreateWithOpener( | 208 return WebContentsImpl::CreateWithOpener( |
| 210 params, static_cast<WebContentsImpl*>(params.opener)); | 209 params, static_cast<WebContentsImpl*>(params.opener)); |
| 211 } | 210 } |
| 212 | 211 |
| 213 WebContents* WebContents::CreateWithSessionStorage( | 212 WebContents* WebContents::CreateWithSessionStorage( |
| 214 const WebContents::CreateParams& params, | 213 const WebContents::CreateParams& params, |
| 215 const SessionStorageNamespaceMap& session_storage_namespace_map) { | 214 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 this, | 303 this, |
| 305 this, | 304 this, |
| 306 this, | 305 this, |
| 307 this), | 306 this), |
| 308 is_loading_(false), | 307 is_loading_(false), |
| 309 is_load_to_different_document_(false), | 308 is_load_to_different_document_(false), |
| 310 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 309 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 311 crashed_error_code_(0), | 310 crashed_error_code_(0), |
| 312 waiting_for_response_(false), | 311 waiting_for_response_(false), |
| 313 load_state_(net::LOAD_STATE_IDLE, base::string16()), | 312 load_state_(net::LOAD_STATE_IDLE, base::string16()), |
| 314 loading_total_progress_(0.0), | |
| 315 upload_size_(0), | 313 upload_size_(0), |
| 316 upload_position_(0), | 314 upload_position_(0), |
| 317 displayed_insecure_content_(false), | 315 displayed_insecure_content_(false), |
| 318 has_accessed_initial_document_(false), | 316 has_accessed_initial_document_(false), |
| 319 theme_color_(SK_ColorTRANSPARENT), | 317 theme_color_(SK_ColorTRANSPARENT), |
| 320 last_sent_theme_color_(SK_ColorTRANSPARENT), | 318 last_sent_theme_color_(SK_ColorTRANSPARENT), |
| 321 capturer_count_(0), | 319 capturer_count_(0), |
| 322 should_normally_be_visible_(true), | 320 should_normally_be_visible_(true), |
| 323 is_being_destroyed_(false), | 321 is_being_destroyed_(false), |
| 324 notify_disconnection_(false), | 322 notify_disconnection_(false), |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 | 504 |
| 507 bool handled = true; | 505 bool handled = true; |
| 508 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) | 506 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) |
| 509 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | 507 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, |
| 510 OnDomOperationResponse) | 508 OnDomOperationResponse) |
| 511 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 509 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
| 512 OnThemeColorChanged) | 510 OnThemeColorChanged) |
| 513 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 511 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
| 514 OnDocumentLoadedInFrame) | 512 OnDocumentLoadedInFrame) |
| 515 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 513 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 516 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) | |
| 517 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) | |
| 518 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, | |
| 519 OnDidChangeLoadProgress) | |
| 520 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) | 514 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenColorChooser, OnOpenColorChooser) |
| 521 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) | 515 IPC_MESSAGE_HANDLER(FrameHostMsg_EndColorChooser, OnEndColorChooser) |
| 522 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, | 516 IPC_MESSAGE_HANDLER(FrameHostMsg_SetSelectedColorInColorChooser, |
| 523 OnSetSelectedColorInColorChooser) | 517 OnSetSelectedColorInColorChooser) |
| 524 IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPlayingNotification, | 518 IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPlayingNotification, |
| 525 OnMediaPlayingNotification) | 519 OnMediaPlayingNotification) |
| 526 IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPausedNotification, | 520 IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPausedNotification, |
| 527 OnMediaPausedNotification) | 521 OnMediaPausedNotification) |
| 528 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFirstVisuallyNonEmptyPaint, | 522 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFirstVisuallyNonEmptyPaint, |
| 529 OnFirstVisuallyNonEmptyPaint) | 523 OnFirstVisuallyNonEmptyPaint) |
| (...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2839 RenderProcessHost* render_process_host = | 2833 RenderProcessHost* render_process_host = |
| 2840 render_frame_message_source_->GetProcess(); | 2834 render_frame_message_source_->GetProcess(); |
| 2841 render_process_host->FilterURL(false, &validated_url); | 2835 render_process_host->FilterURL(false, &validated_url); |
| 2842 | 2836 |
| 2843 RenderFrameHostImpl* rfh = | 2837 RenderFrameHostImpl* rfh = |
| 2844 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 2838 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 2845 FOR_EACH_OBSERVER( | 2839 FOR_EACH_OBSERVER( |
| 2846 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); | 2840 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); |
| 2847 } | 2841 } |
| 2848 | 2842 |
| 2849 void WebContentsImpl::OnDidStartLoading(bool to_different_document) { | |
| 2850 if (!HasValidFrameSource()) | |
| 2851 return; | |
| 2852 | |
| 2853 RenderFrameHostImpl* rfh = | |
| 2854 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2855 | |
| 2856 // Any main frame load to a new document should reset the load progress, since | |
| 2857 // it will replace the current page and any frames. | |
| 2858 if (to_different_document && !rfh->GetParent()) { | |
| 2859 ResetLoadProgressState(); | |
| 2860 rfh->set_is_loading(false); | |
| 2861 } | |
| 2862 | |
| 2863 // This method should never be called when the frame is loading. | |
| 2864 // Unfortunately, it can happen if a history navigation happens during a | |
| 2865 // BeforeUnload or Unload event. | |
| 2866 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 2867 // refactored in Blink. See crbug.com/466089 | |
| 2868 if (rfh->is_loading()) { | |
| 2869 LOG(WARNING) << "OnDidStartLoading was called twice."; | |
| 2870 return; | |
| 2871 } | |
| 2872 | |
| 2873 if (!frame_tree_.IsLoading()) | |
| 2874 DidStartLoading(rfh, to_different_document); | |
| 2875 | |
| 2876 rfh->set_is_loading(true); | |
| 2877 | |
| 2878 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2879 ftn->set_loading_progress(FrameTreeNode::kLoadingProgressMinimum); | |
| 2880 | |
| 2881 // Notify the RenderFrameHostManager of the event. | |
| 2882 ftn->render_manager()->OnDidStartLoading(); | |
| 2883 | |
| 2884 SendLoadProgressChanged(); | |
| 2885 } | |
| 2886 | |
| 2887 void WebContentsImpl::OnDidStopLoading() { | |
| 2888 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2889 // fixed. | |
| 2890 tracked_objects::ScopedTracker tracking_profile1( | |
| 2891 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2892 "465796 WebContentsImpl::OnDidStopLoading::Start")); | |
| 2893 | |
| 2894 if (!HasValidFrameSource()) | |
| 2895 return; | |
| 2896 | |
| 2897 RenderFrameHostImpl* rfh = | |
| 2898 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2899 | |
| 2900 // This method should never be called when the frame is not loading. | |
| 2901 // Unfortunately, it can happen if a history navigation happens during a | |
| 2902 // BeforeUnload or Unload event. | |
| 2903 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 2904 // refactored in Blink. See crbug.com/466089 | |
| 2905 if (!rfh->is_loading()) { | |
| 2906 LOG(WARNING) << "OnDidStopLoading was called twice."; | |
| 2907 return; | |
| 2908 } | |
| 2909 | |
| 2910 rfh->set_is_loading(false); | |
| 2911 | |
| 2912 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2913 ftn->set_loading_progress(FrameTreeNode::kLoadingProgressDone); | |
| 2914 | |
| 2915 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2916 // fixed. | |
| 2917 tracked_objects::ScopedTracker tracking_profile2( | |
| 2918 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2919 "465796 " | |
| 2920 "WebContentsImpl::OnDidStopLoading::SendLoadProgressChanged")); | |
| 2921 | |
| 2922 // Update progress based on this frame's completion. | |
| 2923 SendLoadProgressChanged(); | |
| 2924 | |
| 2925 // Then clean-up the states. | |
| 2926 if (loading_total_progress_ == 1.0) | |
| 2927 ResetLoadProgressState(); | |
| 2928 | |
| 2929 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2930 // fixed. | |
| 2931 tracked_objects::ScopedTracker tracking_profile3( | |
| 2932 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2933 "465796 WebContentsImpl::OnDidStopLoading::NotifyRenderManager")); | |
| 2934 // Notify the RenderFrameHostManager of the event. | |
| 2935 ftn->render_manager()->OnDidStopLoading(); | |
| 2936 | |
| 2937 if (!frame_tree_.IsLoading()) { | |
| 2938 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2939 // fixed. | |
| 2940 tracked_objects::ScopedTracker tracking_profile4( | |
| 2941 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2942 "465796 WebContentsImpl::OnDidStopLoading::WCIDidStopLoading")); | |
| 2943 DidStopLoading(); | |
| 2944 } | |
| 2945 | |
| 2946 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2947 // fixed. | |
| 2948 tracked_objects::ScopedTracker tracking_profile4( | |
| 2949 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2950 "465796 WebContentsImpl::OnDidStopLoading::End")); | |
| 2951 } | |
| 2952 | |
| 2953 void WebContentsImpl::OnDidChangeLoadProgress(double load_progress) { | |
| 2954 if (!HasValidFrameSource()) | |
| 2955 return; | |
| 2956 | |
| 2957 RenderFrameHostImpl* rfh = | |
| 2958 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2959 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2960 | |
| 2961 ftn->set_loading_progress(load_progress); | |
| 2962 | |
| 2963 // We notify progress change immediately for the first and last updates. | |
| 2964 // Also, since the message loop may be pretty busy when a page is loaded, it | |
| 2965 // might not execute a posted task in a timely manner so we make sure to | |
| 2966 // immediately send progress report if enough time has passed. | |
| 2967 base::TimeDelta min_delay = | |
| 2968 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); | |
| 2969 if (load_progress == 1.0 || loading_last_progress_update_.is_null() || | |
| 2970 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay) { | |
| 2971 // If there is a pending task to send progress, it is now obsolete. | |
| 2972 loading_weak_factory_.InvalidateWeakPtrs(); | |
| 2973 SendLoadProgressChanged(); | |
| 2974 if (loading_total_progress_ == 1.0) | |
| 2975 ResetLoadProgressState(); | |
| 2976 return; | |
| 2977 } | |
| 2978 | |
| 2979 if (loading_weak_factory_.HasWeakPtrs()) | |
| 2980 return; | |
| 2981 | |
| 2982 base::MessageLoop::current()->PostDelayedTask( | |
| 2983 FROM_HERE, | |
| 2984 base::Bind(&WebContentsImpl::SendLoadProgressChanged, | |
| 2985 loading_weak_factory_.GetWeakPtr()), | |
| 2986 min_delay); | |
| 2987 } | |
| 2988 | |
| 2989 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 2843 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { |
| 2990 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 2844 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 2991 controller_.GoToOffset(offset); | 2845 controller_.GoToOffset(offset); |
| 2992 } | 2846 } |
| 2993 | 2847 |
| 2994 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 2848 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
| 2995 int maximum_percent) { | 2849 int maximum_percent) { |
| 2996 minimum_zoom_percent_ = minimum_percent; | 2850 minimum_zoom_percent_ = minimum_percent; |
| 2997 maximum_zoom_percent_ = maximum_percent; | 2851 maximum_zoom_percent_ = maximum_percent; |
| 2998 } | 2852 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3427 std::pair<NavigationEntry*, bool> details = | 3281 std::pair<NavigationEntry*, bool> details = |
| 3428 std::make_pair(entry, explicit_set); | 3282 std::make_pair(entry, explicit_set); |
| 3429 NotificationService::current()->Notify( | 3283 NotificationService::current()->Notify( |
| 3430 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 3284 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
| 3431 Source<WebContents>(this), | 3285 Source<WebContents>(this), |
| 3432 Details<std::pair<NavigationEntry*, bool> >(&details)); | 3286 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 3433 | 3287 |
| 3434 return true; | 3288 return true; |
| 3435 } | 3289 } |
| 3436 | 3290 |
| 3437 void WebContentsImpl::SendLoadProgressChanged() { | 3291 void WebContentsImpl::SendChangeLoadProgress() { |
| 3438 loading_last_progress_update_ = base::TimeTicks::Now(); | 3292 loading_last_progress_update_ = base::TimeTicks::Now(); |
| 3439 double progress = frame_tree_.GetLoadProgress(); | |
| 3440 | |
| 3441 DCHECK_LE(progress, 1.0); | |
| 3442 | |
| 3443 if (progress <= loading_total_progress_) | |
| 3444 return; | |
| 3445 loading_total_progress_ = progress; | |
| 3446 | |
| 3447 if (delegate_) | 3293 if (delegate_) |
| 3448 delegate_->LoadProgressChanged(this, progress); | 3294 delegate_->LoadProgressChanged(this, frame_tree_.GetLoadProgress()); |
|
Fabrice (no longer in Chrome)
2015/04/14 16:54:11
This is the reason why we have to keep some of the
nasko
2015/04/14 19:54:41
Yes, notifying the WebContents' delegate makes sen
Fabrice (no longer in Chrome)
2015/04/15 15:15:03
Acknowledged.
| |
| 3449 } | 3295 } |
| 3450 | 3296 |
| 3451 void WebContentsImpl::ResetLoadProgressState() { | 3297 void WebContentsImpl::ResetLoadProgressState() { |
| 3452 frame_tree_.ResetLoadProgress(); | 3298 frame_tree_.ResetLoadProgress(); |
| 3453 loading_total_progress_ = 0.0; | |
| 3454 loading_weak_factory_.InvalidateWeakPtrs(); | 3299 loading_weak_factory_.InvalidateWeakPtrs(); |
| 3455 loading_last_progress_update_ = base::TimeTicks(); | 3300 loading_last_progress_update_ = base::TimeTicks(); |
| 3456 } | 3301 } |
| 3457 | 3302 |
| 3458 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, | 3303 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, |
| 3459 RenderViewHost* new_host) { | 3304 RenderViewHost* new_host) { |
| 3460 // After sending out a swap notification, we need to send a disconnect | 3305 // After sending out a swap notification, we need to send a disconnect |
| 3461 // notification so that clients that pick up a pointer to |this| can NULL the | 3306 // notification so that clients that pick up a pointer to |this| can NULL the |
| 3462 // pointer. See Bug 1230284. | 3307 // pointer. See Bug 1230284. |
| 3463 notify_disconnection_ = true; | 3308 notify_disconnection_ = true; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3844 #else | 3689 #else |
| 3845 return false; | 3690 return false; |
| 3846 #endif | 3691 #endif |
| 3847 } | 3692 } |
| 3848 | 3693 |
| 3849 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3694 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 3850 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3695 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 3851 delegate_->MoveContents(this, new_bounds); | 3696 delegate_->MoveContents(this, new_bounds); |
| 3852 } | 3697 } |
| 3853 | 3698 |
| 3854 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, | 3699 void WebContentsImpl::DidStartLoading(FrameTreeNode* frame_tree_node, |
| 3855 bool to_different_document) { | 3700 bool to_different_document) { |
| 3856 SetIsLoading(true, to_different_document, nullptr); | 3701 SetIsLoading(true, to_different_document, nullptr); |
| 3857 | 3702 |
| 3858 // Notify accessibility that the user is navigating away from the | 3703 // Notify accessibility that the user is navigating away from the |
| 3859 // current document. | 3704 // current document. |
| 3860 // | 3705 // |
| 3861 // TODO(dmazzoni): do this using a WebContentsObserver. | 3706 // TODO(dmazzoni): do this using a WebContentsObserver. |
| 3862 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)-> | |
| 3863 frame_tree_node(); | |
| 3864 BrowserAccessibilityManager* manager = | 3707 BrowserAccessibilityManager* manager = |
| 3865 ftn->current_frame_host()->browser_accessibility_manager(); | 3708 frame_tree_node->current_frame_host()->browser_accessibility_manager(); |
| 3866 if (manager) | 3709 if (manager) |
| 3867 manager->UserIsNavigatingAway(); | 3710 manager->UserIsNavigatingAway(); |
| 3868 } | 3711 } |
| 3869 | 3712 |
| 3870 void WebContentsImpl::DidStopLoading() { | 3713 void WebContentsImpl::DidStopLoading() { |
| 3871 scoped_ptr<LoadNotificationDetails> details; | 3714 scoped_ptr<LoadNotificationDetails> details; |
| 3872 | 3715 |
| 3873 // Use the last committed entry rather than the active one, in case a | 3716 // Use the last committed entry rather than the active one, in case a |
| 3874 // pending entry has been created. | 3717 // pending entry has been created. |
| 3875 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 3718 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
| 3876 Navigator* navigator = frame_tree_.root()->navigator(); | 3719 Navigator* navigator = frame_tree_.root()->navigator(); |
| 3877 | 3720 |
| 3878 // An entry may not exist for a stop when loading an initial blank page or | 3721 // An entry may not exist for a stop when loading an initial blank page or |
| 3879 // if an iframe injected by script into a blank page finishes loading. | 3722 // if an iframe injected by script into a blank page finishes loading. |
| 3880 if (entry) { | 3723 if (entry) { |
| 3881 base::TimeDelta elapsed = | 3724 base::TimeDelta elapsed = |
| 3882 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); | 3725 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); |
| 3883 | 3726 |
| 3884 details.reset(new LoadNotificationDetails( | 3727 details.reset(new LoadNotificationDetails( |
| 3885 entry->GetVirtualURL(), | 3728 entry->GetVirtualURL(), |
| 3886 entry->GetTransitionType(), | 3729 entry->GetTransitionType(), |
| 3887 elapsed, | 3730 elapsed, |
| 3888 &controller_, | 3731 &controller_, |
| 3889 controller_.GetCurrentEntryIndex())); | 3732 controller_.GetCurrentEntryIndex())); |
| 3890 } | 3733 } |
| 3891 | 3734 |
| 3892 SetIsLoading(false, true, details.get()); | 3735 SetIsLoading(false, true, details.get()); |
| 3893 } | 3736 } |
| 3894 | 3737 |
| 3738 void WebContentsImpl::DidChangeLoadProgress() { | |
| 3739 double load_progress = frame_tree_.GetLoadProgress(); | |
| 3740 | |
| 3741 // The change is notified immediately for the first and last updates. | |
| 3742 // Also, since the message loop may be pretty busy when a page is loaded, it | |
| 3743 // might not execute a posted task in a timely manner so the progress report | |
| 3744 // is sent immediately if enough time has passed. | |
| 3745 base::TimeDelta min_delay = | |
| 3746 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); | |
| 3747 bool delay_elapsed = loading_last_progress_update_.is_null() || | |
| 3748 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay; | |
| 3749 | |
| 3750 if (load_progress == 0.0 || load_progress == 1.0 || delay_elapsed) { | |
| 3751 // If there is a pending task to send progress, it is now obsolete. | |
| 3752 loading_weak_factory_.InvalidateWeakPtrs(); | |
| 3753 | |
| 3754 // Notify the load progress change. | |
| 3755 SendChangeLoadProgress(); | |
| 3756 | |
| 3757 // Clean-up the states if needed. | |
| 3758 if (load_progress == 1.0) | |
| 3759 ResetLoadProgressState(); | |
| 3760 return; | |
| 3761 } | |
| 3762 | |
| 3763 if (loading_weak_factory_.HasWeakPtrs()) | |
| 3764 return; | |
| 3765 | |
| 3766 base::MessageLoop::current()->PostDelayedTask( | |
| 3767 FROM_HERE, | |
| 3768 base::Bind(&WebContentsImpl::SendChangeLoadProgress, | |
| 3769 loading_weak_factory_.GetWeakPtr()), | |
| 3770 min_delay); | |
| 3771 } | |
| 3772 | |
| 3895 void WebContentsImpl::DidCancelLoading() { | 3773 void WebContentsImpl::DidCancelLoading() { |
| 3896 controller_.DiscardNonCommittedEntries(); | 3774 controller_.DiscardNonCommittedEntries(); |
| 3897 | 3775 |
| 3898 // Update the URL display. | 3776 // Update the URL display. |
| 3899 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 3777 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 3900 } | 3778 } |
| 3901 | 3779 |
| 3902 void WebContentsImpl::DidAccessInitialDocument() { | 3780 void WebContentsImpl::DidAccessInitialDocument() { |
| 3903 has_accessed_initial_document_ = true; | 3781 has_accessed_initial_document_ = true; |
| 3904 | 3782 |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4559 node->render_manager()->ResumeResponseDeferredAtStart(); | 4437 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4560 } | 4438 } |
| 4561 | 4439 |
| 4562 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4440 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4563 force_disable_overscroll_content_ = force_disable; | 4441 force_disable_overscroll_content_ = force_disable; |
| 4564 if (view_) | 4442 if (view_) |
| 4565 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4443 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4566 } | 4444 } |
| 4567 | 4445 |
| 4568 } // namespace content | 4446 } // namespace content |
| OLD | NEW |