| 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 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 RenderProcessHost* render_process_host = | 2849 RenderProcessHost* render_process_host = |
| 2856 render_frame_message_source_->GetProcess(); | 2850 render_frame_message_source_->GetProcess(); |
| 2857 render_process_host->FilterURL(false, &validated_url); | 2851 render_process_host->FilterURL(false, &validated_url); |
| 2858 | 2852 |
| 2859 RenderFrameHostImpl* rfh = | 2853 RenderFrameHostImpl* rfh = |
| 2860 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 2854 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 2861 FOR_EACH_OBSERVER( | 2855 FOR_EACH_OBSERVER( |
| 2862 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); | 2856 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); |
| 2863 } | 2857 } |
| 2864 | 2858 |
| 2865 void WebContentsImpl::OnDidStartLoading(bool to_different_document) { | |
| 2866 if (!HasValidFrameSource()) | |
| 2867 return; | |
| 2868 | |
| 2869 RenderFrameHostImpl* rfh = | |
| 2870 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2871 | |
| 2872 // Any main frame load to a new document should reset the load progress, since | |
| 2873 // it will replace the current page and any frames. | |
| 2874 if (to_different_document && !rfh->GetParent()) { | |
| 2875 ResetLoadProgressState(); | |
| 2876 rfh->set_is_loading(false); | |
| 2877 } | |
| 2878 | |
| 2879 // This method should never be called when the frame is loading. | |
| 2880 // Unfortunately, it can happen if a history navigation happens during a | |
| 2881 // BeforeUnload or Unload event. | |
| 2882 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 2883 // refactored in Blink. See crbug.com/466089 | |
| 2884 if (rfh->is_loading()) { | |
| 2885 LOG(WARNING) << "OnDidStartLoading was called twice."; | |
| 2886 return; | |
| 2887 } | |
| 2888 | |
| 2889 if (!frame_tree_.IsLoading()) | |
| 2890 DidStartLoading(rfh, to_different_document); | |
| 2891 | |
| 2892 rfh->set_is_loading(true); | |
| 2893 | |
| 2894 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2895 ftn->set_loading_progress(FrameTreeNode::kLoadingProgressMinimum); | |
| 2896 | |
| 2897 // Notify the RenderFrameHostManager of the event. | |
| 2898 ftn->render_manager()->OnDidStartLoading(); | |
| 2899 | |
| 2900 SendLoadProgressChanged(); | |
| 2901 } | |
| 2902 | |
| 2903 void WebContentsImpl::OnDidStopLoading() { | |
| 2904 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2905 // fixed. | |
| 2906 tracked_objects::ScopedTracker tracking_profile1( | |
| 2907 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2908 "465796 WebContentsImpl::OnDidStopLoading::Start")); | |
| 2909 | |
| 2910 if (!HasValidFrameSource()) | |
| 2911 return; | |
| 2912 | |
| 2913 RenderFrameHostImpl* rfh = | |
| 2914 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2915 | |
| 2916 // This method should never be called when the frame is not loading. | |
| 2917 // Unfortunately, it can happen if a history navigation happens during a | |
| 2918 // BeforeUnload or Unload event. | |
| 2919 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 2920 // refactored in Blink. See crbug.com/466089 | |
| 2921 if (!rfh->is_loading()) { | |
| 2922 LOG(WARNING) << "OnDidStopLoading was called twice."; | |
| 2923 return; | |
| 2924 } | |
| 2925 | |
| 2926 rfh->set_is_loading(false); | |
| 2927 | |
| 2928 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2929 ftn->set_loading_progress(FrameTreeNode::kLoadingProgressDone); | |
| 2930 | |
| 2931 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2932 // fixed. | |
| 2933 tracked_objects::ScopedTracker tracking_profile2( | |
| 2934 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2935 "465796 " | |
| 2936 "WebContentsImpl::OnDidStopLoading::SendLoadProgressChanged")); | |
| 2937 | |
| 2938 // Update progress based on this frame's completion. | |
| 2939 SendLoadProgressChanged(); | |
| 2940 | |
| 2941 // Then clean-up the states. | |
| 2942 if (loading_total_progress_ == 1.0) | |
| 2943 ResetLoadProgressState(); | |
| 2944 | |
| 2945 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2946 // fixed. | |
| 2947 tracked_objects::ScopedTracker tracking_profile3( | |
| 2948 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2949 "465796 WebContentsImpl::OnDidStopLoading::NotifyRenderManager")); | |
| 2950 // Notify the RenderFrameHostManager of the event. | |
| 2951 ftn->render_manager()->OnDidStopLoading(); | |
| 2952 | |
| 2953 if (!frame_tree_.IsLoading()) { | |
| 2954 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2955 // fixed. | |
| 2956 tracked_objects::ScopedTracker tracking_profile4( | |
| 2957 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2958 "465796 WebContentsImpl::OnDidStopLoading::WCIDidStopLoading")); | |
| 2959 DidStopLoading(); | |
| 2960 } | |
| 2961 | |
| 2962 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | |
| 2963 // fixed. | |
| 2964 tracked_objects::ScopedTracker tracking_profile4( | |
| 2965 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 2966 "465796 WebContentsImpl::OnDidStopLoading::End")); | |
| 2967 } | |
| 2968 | |
| 2969 void WebContentsImpl::OnDidChangeLoadProgress(double load_progress) { | |
| 2970 if (!HasValidFrameSource()) | |
| 2971 return; | |
| 2972 | |
| 2973 RenderFrameHostImpl* rfh = | |
| 2974 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | |
| 2975 FrameTreeNode* ftn = rfh->frame_tree_node(); | |
| 2976 | |
| 2977 ftn->set_loading_progress(load_progress); | |
| 2978 | |
| 2979 // We notify progress change immediately for the first and last updates. | |
| 2980 // Also, since the message loop may be pretty busy when a page is loaded, it | |
| 2981 // might not execute a posted task in a timely manner so we make sure to | |
| 2982 // immediately send progress report if enough time has passed. | |
| 2983 base::TimeDelta min_delay = | |
| 2984 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); | |
| 2985 if (load_progress == 1.0 || loading_last_progress_update_.is_null() || | |
| 2986 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay) { | |
| 2987 // If there is a pending task to send progress, it is now obsolete. | |
| 2988 loading_weak_factory_.InvalidateWeakPtrs(); | |
| 2989 SendLoadProgressChanged(); | |
| 2990 if (loading_total_progress_ == 1.0) | |
| 2991 ResetLoadProgressState(); | |
| 2992 return; | |
| 2993 } | |
| 2994 | |
| 2995 if (loading_weak_factory_.HasWeakPtrs()) | |
| 2996 return; | |
| 2997 | |
| 2998 base::MessageLoop::current()->PostDelayedTask( | |
| 2999 FROM_HERE, | |
| 3000 base::Bind(&WebContentsImpl::SendLoadProgressChanged, | |
| 3001 loading_weak_factory_.GetWeakPtr()), | |
| 3002 min_delay); | |
| 3003 } | |
| 3004 | |
| 3005 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 2859 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { |
| 3006 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 2860 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 3007 controller_.GoToOffset(offset); | 2861 controller_.GoToOffset(offset); |
| 3008 } | 2862 } |
| 3009 | 2863 |
| 3010 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 2864 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
| 3011 int maximum_percent) { | 2865 int maximum_percent) { |
| 3012 minimum_zoom_percent_ = minimum_percent; | 2866 minimum_zoom_percent_ = minimum_percent; |
| 3013 maximum_zoom_percent_ = maximum_percent; | 2867 maximum_zoom_percent_ = maximum_percent; |
| 3014 } | 2868 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3443 std::pair<NavigationEntry*, bool> details = | 3297 std::pair<NavigationEntry*, bool> details = |
| 3444 std::make_pair(entry, explicit_set); | 3298 std::make_pair(entry, explicit_set); |
| 3445 NotificationService::current()->Notify( | 3299 NotificationService::current()->Notify( |
| 3446 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 3300 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
| 3447 Source<WebContents>(this), | 3301 Source<WebContents>(this), |
| 3448 Details<std::pair<NavigationEntry*, bool> >(&details)); | 3302 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 3449 | 3303 |
| 3450 return true; | 3304 return true; |
| 3451 } | 3305 } |
| 3452 | 3306 |
| 3453 void WebContentsImpl::SendLoadProgressChanged() { | 3307 void WebContentsImpl::SendChangeLoadProgress() { |
| 3454 loading_last_progress_update_ = base::TimeTicks::Now(); | 3308 loading_last_progress_update_ = base::TimeTicks::Now(); |
| 3455 double progress = frame_tree_.GetLoadProgress(); | |
| 3456 | |
| 3457 DCHECK_LE(progress, 1.0); | |
| 3458 | |
| 3459 if (progress <= loading_total_progress_) | |
| 3460 return; | |
| 3461 loading_total_progress_ = progress; | |
| 3462 | |
| 3463 if (delegate_) | 3309 if (delegate_) |
| 3464 delegate_->LoadProgressChanged(this, progress); | 3310 delegate_->LoadProgressChanged(this, frame_tree_.load_progress()); |
| 3465 } | 3311 } |
| 3466 | 3312 |
| 3467 void WebContentsImpl::ResetLoadProgressState() { | 3313 void WebContentsImpl::ResetLoadProgressState() { |
| 3468 frame_tree_.ResetLoadProgress(); | 3314 frame_tree_.ResetLoadProgress(); |
| 3469 loading_total_progress_ = 0.0; | |
| 3470 loading_weak_factory_.InvalidateWeakPtrs(); | 3315 loading_weak_factory_.InvalidateWeakPtrs(); |
| 3471 loading_last_progress_update_ = base::TimeTicks(); | 3316 loading_last_progress_update_ = base::TimeTicks(); |
| 3472 } | 3317 } |
| 3473 | 3318 |
| 3474 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, | 3319 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, |
| 3475 RenderViewHost* new_host) { | 3320 RenderViewHost* new_host) { |
| 3476 // After sending out a swap notification, we need to send a disconnect | 3321 // After sending out a swap notification, we need to send a disconnect |
| 3477 // notification so that clients that pick up a pointer to |this| can NULL the | 3322 // notification so that clients that pick up a pointer to |this| can NULL the |
| 3478 // pointer. See Bug 1230284. | 3323 // pointer. See Bug 1230284. |
| 3479 notify_disconnection_ = true; | 3324 notify_disconnection_ = true; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 #else | 3705 #else |
| 3861 return false; | 3706 return false; |
| 3862 #endif | 3707 #endif |
| 3863 } | 3708 } |
| 3864 | 3709 |
| 3865 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3710 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 3866 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3711 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 3867 delegate_->MoveContents(this, new_bounds); | 3712 delegate_->MoveContents(this, new_bounds); |
| 3868 } | 3713 } |
| 3869 | 3714 |
| 3870 void WebContentsImpl::DidStartLoading(RenderFrameHost* render_frame_host, | 3715 void WebContentsImpl::DidStartLoading(FrameTreeNode* frame_tree_node, |
| 3871 bool to_different_document) { | 3716 bool to_different_document) { |
| 3872 SetIsLoading(true, to_different_document, nullptr); | 3717 SetIsLoading(true, to_different_document, nullptr); |
| 3873 | 3718 |
| 3874 // Notify accessibility that the user is navigating away from the | 3719 // Notify accessibility that the user is navigating away from the |
| 3875 // current document. | 3720 // current document. |
| 3876 // | 3721 // |
| 3877 // TODO(dmazzoni): do this using a WebContentsObserver. | 3722 // TODO(dmazzoni): do this using a WebContentsObserver. |
| 3878 FrameTreeNode* ftn = static_cast<RenderFrameHostImpl*>(render_frame_host)-> | |
| 3879 frame_tree_node(); | |
| 3880 BrowserAccessibilityManager* manager = | 3723 BrowserAccessibilityManager* manager = |
| 3881 ftn->current_frame_host()->browser_accessibility_manager(); | 3724 frame_tree_node->current_frame_host()->browser_accessibility_manager(); |
| 3882 if (manager) | 3725 if (manager) |
| 3883 manager->UserIsNavigatingAway(); | 3726 manager->UserIsNavigatingAway(); |
| 3884 } | 3727 } |
| 3885 | 3728 |
| 3886 void WebContentsImpl::DidStopLoading() { | 3729 void WebContentsImpl::DidStopLoading() { |
| 3887 scoped_ptr<LoadNotificationDetails> details; | 3730 scoped_ptr<LoadNotificationDetails> details; |
| 3888 | 3731 |
| 3889 // Use the last committed entry rather than the active one, in case a | 3732 // Use the last committed entry rather than the active one, in case a |
| 3890 // pending entry has been created. | 3733 // pending entry has been created. |
| 3891 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 3734 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
| 3892 Navigator* navigator = frame_tree_.root()->navigator(); | 3735 Navigator* navigator = frame_tree_.root()->navigator(); |
| 3893 | 3736 |
| 3894 // An entry may not exist for a stop when loading an initial blank page or | 3737 // An entry may not exist for a stop when loading an initial blank page or |
| 3895 // if an iframe injected by script into a blank page finishes loading. | 3738 // if an iframe injected by script into a blank page finishes loading. |
| 3896 if (entry) { | 3739 if (entry) { |
| 3897 base::TimeDelta elapsed = | 3740 base::TimeDelta elapsed = |
| 3898 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); | 3741 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); |
| 3899 | 3742 |
| 3900 details.reset(new LoadNotificationDetails( | 3743 details.reset(new LoadNotificationDetails( |
| 3901 entry->GetVirtualURL(), | 3744 entry->GetVirtualURL(), |
| 3902 entry->GetTransitionType(), | 3745 entry->GetTransitionType(), |
| 3903 elapsed, | 3746 elapsed, |
| 3904 &controller_, | 3747 &controller_, |
| 3905 controller_.GetCurrentEntryIndex())); | 3748 controller_.GetCurrentEntryIndex())); |
| 3906 } | 3749 } |
| 3907 | 3750 |
| 3908 SetIsLoading(false, true, details.get()); | 3751 SetIsLoading(false, true, details.get()); |
| 3909 } | 3752 } |
| 3910 | 3753 |
| 3754 void WebContentsImpl::DidChangeLoadProgress() { |
| 3755 double load_progress = frame_tree_.load_progress(); |
| 3756 |
| 3757 // The delegate is notified immediately for the first and last updates. Also, |
| 3758 // since the message loop may be pretty busy when a page is loaded, it might |
| 3759 // not execute a posted task in a timely manner so the progress report is sent |
| 3760 // immediately if enough time has passed. |
| 3761 base::TimeDelta min_delay = |
| 3762 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); |
| 3763 bool delay_elapsed = loading_last_progress_update_.is_null() || |
| 3764 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay; |
| 3765 |
| 3766 if (load_progress == 0.0 || load_progress == 1.0 || delay_elapsed) { |
| 3767 // If there is a pending task to send progress, it is now obsolete. |
| 3768 loading_weak_factory_.InvalidateWeakPtrs(); |
| 3769 |
| 3770 // Notify the load progress change. |
| 3771 SendChangeLoadProgress(); |
| 3772 |
| 3773 // Clean-up the states if needed. |
| 3774 if (load_progress == 1.0) |
| 3775 ResetLoadProgressState(); |
| 3776 return; |
| 3777 } |
| 3778 |
| 3779 if (loading_weak_factory_.HasWeakPtrs()) |
| 3780 return; |
| 3781 |
| 3782 base::MessageLoop::current()->PostDelayedTask( |
| 3783 FROM_HERE, |
| 3784 base::Bind(&WebContentsImpl::SendChangeLoadProgress, |
| 3785 loading_weak_factory_.GetWeakPtr()), |
| 3786 min_delay); |
| 3787 } |
| 3788 |
| 3911 void WebContentsImpl::DidCancelLoading() { | 3789 void WebContentsImpl::DidCancelLoading() { |
| 3912 controller_.DiscardNonCommittedEntries(); | 3790 controller_.DiscardNonCommittedEntries(); |
| 3913 | 3791 |
| 3914 // Update the URL display. | 3792 // Update the URL display. |
| 3915 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 3793 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 3916 } | 3794 } |
| 3917 | 3795 |
| 3918 void WebContentsImpl::DidAccessInitialDocument() { | 3796 void WebContentsImpl::DidAccessInitialDocument() { |
| 3919 has_accessed_initial_document_ = true; | 3797 has_accessed_initial_document_ = true; |
| 3920 | 3798 |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4537 node->render_manager()->ResumeResponseDeferredAtStart(); | 4415 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4538 } | 4416 } |
| 4539 | 4417 |
| 4540 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4418 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4541 force_disable_overscroll_content_ = force_disable; | 4419 force_disable_overscroll_content_ = force_disable; |
| 4542 if (view_) | 4420 if (view_) |
| 4543 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4421 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4544 } | 4422 } |
| 4545 | 4423 |
| 4546 } // namespace content | 4424 } // namespace content |
| OLD | NEW |