| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
| 118 #include "base/mac/foundation_util.h" | 118 #include "base/mac/foundation_util.h" |
| 119 #endif | 119 #endif |
| 120 | 120 |
| 121 namespace content { | 121 namespace content { |
| 122 namespace { | 122 namespace { |
| 123 | 123 |
| 124 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 124 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
| 125 | |
| 126 // This matches what Blink's ProgressTracker has traditionally used for a | |
| 127 // minimum progress value. | |
| 128 const double kMinimumLoadingProgress = 0.1; | |
| 129 | |
| 130 const char kDotGoogleDotCom[] = ".google.com"; | 125 const char kDotGoogleDotCom[] = ".google.com"; |
| 131 | 126 |
| 132 #if defined(OS_ANDROID) | 127 #if defined(OS_ANDROID) |
| 133 const char kWebContentsAndroidKey[] = "web_contents_android"; | 128 const char kWebContentsAndroidKey[] = "web_contents_android"; |
| 134 #endif // OS_ANDROID | 129 #endif // OS_ANDROID |
| 135 | 130 |
| 136 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 131 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
| 137 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 132 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
| 138 | 133 |
| 139 static int StartDownload(RenderFrameHost* rfh, | 134 static int StartDownload(RenderFrameHost* rfh, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 160 } | 155 } |
| 161 | 156 |
| 162 // Helper function for retrieving all the sites in a frame tree. | 157 // Helper function for retrieving all the sites in a frame tree. |
| 163 bool CollectSites(BrowserContext* context, | 158 bool CollectSites(BrowserContext* context, |
| 164 std::set<GURL>* sites, | 159 std::set<GURL>* sites, |
| 165 FrameTreeNode* node) { | 160 FrameTreeNode* node) { |
| 166 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); | 161 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); |
| 167 return true; | 162 return true; |
| 168 } | 163 } |
| 169 | 164 |
| 165 // Helper function used with FrameTree::ForEach() for retrieving the total |
| 166 // loading progress and number of frames in a frame tree. |
| 167 bool CollectLoadProgress(double* progress, |
| 168 int* frame_count, |
| 169 FrameTreeNode* node) { |
| 170 // Ignore the current frame if it has not started loading. |
| 171 double frame_progress = node->GetLoadingProgress(); |
| 172 if (frame_progress == RenderFrameHostImpl::kLoadingProgressNotStarted) |
| 173 return true; |
| 174 |
| 175 // Collect progress. |
| 176 *progress += node->GetLoadingProgress(); |
| 177 (*frame_count)++; |
| 178 return true; |
| 179 } |
| 180 |
| 181 // Helper function used with FrameTree::ForEach() to check if at least one of |
| 182 // the nodes is loading. |
| 183 bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) { |
| 184 if (node->IsLoading()) { |
| 185 // There is at least one node loading, so abort traversal. |
| 186 *is_loading = true; |
| 187 return false; |
| 188 } |
| 189 return true; |
| 190 } |
| 191 |
| 192 // Helper function used with FrameTree::ForEach() to reset the load progress. |
| 193 bool ResetLoadProgress(FrameTreeNode* node) { |
| 194 node->current_frame_host()->set_loading_progress( |
| 195 RenderFrameHostImpl::kLoadingProgressNotStarted); |
| 196 return true; |
| 197 } |
| 198 |
| 170 bool ForEachFrameInternal( | 199 bool ForEachFrameInternal( |
| 171 const base::Callback<void(RenderFrameHost*)>& on_frame, | 200 const base::Callback<void(RenderFrameHost*)>& on_frame, |
| 172 FrameTreeNode* node) { | 201 FrameTreeNode* node) { |
| 173 on_frame.Run(node->current_frame_host()); | 202 on_frame.Run(node->current_frame_host()); |
| 174 return true; | 203 return true; |
| 175 } | 204 } |
| 176 | 205 |
| 177 bool ForEachPendingFrameInternal( | 206 bool ForEachPendingFrameInternal( |
| 178 const base::Callback<void(RenderFrameHost*)>& on_frame, | 207 const base::Callback<void(RenderFrameHost*)>& on_frame, |
| 179 FrameTreeNode* node) { | 208 FrameTreeNode* node) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // termination is not allowed for the current RenderFrameHost of | 250 // termination is not allowed for the current RenderFrameHost of |
| 222 // |frame_tree_node|. Used with FrameTree::ForEach. | 251 // |frame_tree_node|. Used with FrameTree::ForEach. |
| 223 bool SuddenTerminationAllowed(bool* sudden_termination_allowed, | 252 bool SuddenTerminationAllowed(bool* sudden_termination_allowed, |
| 224 FrameTreeNode* frame_tree_node) { | 253 FrameTreeNode* frame_tree_node) { |
| 225 if (frame_tree_node->current_frame_host()->SuddenTerminationAllowed()) | 254 if (frame_tree_node->current_frame_host()->SuddenTerminationAllowed()) |
| 226 return true; | 255 return true; |
| 227 *sudden_termination_allowed = false; | 256 *sudden_termination_allowed = false; |
| 228 return false; | 257 return false; |
| 229 } | 258 } |
| 230 | 259 |
| 260 // Returns true if at least one of the nodes in the |frame_tree| is loading. |
| 261 bool IsFrameTreeLoading(FrameTree& frame_tree) { |
| 262 bool is_loading = false; |
| 263 frame_tree.ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
| 264 return is_loading; |
| 265 } |
| 266 |
| 231 } // namespace | 267 } // namespace |
| 232 | 268 |
| 233 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 269 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| 234 return WebContentsImpl::CreateWithOpener( | 270 return WebContentsImpl::CreateWithOpener( |
| 235 params, static_cast<WebContentsImpl*>(params.opener)); | 271 params, static_cast<WebContentsImpl*>(params.opener)); |
| 236 } | 272 } |
| 237 | 273 |
| 238 WebContents* WebContents::CreateWithSessionStorage( | 274 WebContents* WebContents::CreateWithSessionStorage( |
| 239 const WebContents::CreateParams& params, | 275 const WebContents::CreateParams& params, |
| 240 const SessionStorageNamespaceMap& session_storage_namespace_map) { | 276 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 this, | 366 this, |
| 331 this, | 367 this, |
| 332 this), | 368 this), |
| 333 is_loading_(false), | 369 is_loading_(false), |
| 334 is_load_to_different_document_(false), | 370 is_load_to_different_document_(false), |
| 335 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 371 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 336 crashed_error_code_(0), | 372 crashed_error_code_(0), |
| 337 waiting_for_response_(false), | 373 waiting_for_response_(false), |
| 338 load_state_(net::LOAD_STATE_IDLE, base::string16()), | 374 load_state_(net::LOAD_STATE_IDLE, base::string16()), |
| 339 loading_total_progress_(0.0), | 375 loading_total_progress_(0.0), |
| 340 loading_frames_in_progress_(0), | |
| 341 upload_size_(0), | 376 upload_size_(0), |
| 342 upload_position_(0), | 377 upload_position_(0), |
| 343 displayed_insecure_content_(false), | 378 displayed_insecure_content_(false), |
| 344 has_accessed_initial_document_(false), | 379 has_accessed_initial_document_(false), |
| 345 theme_color_(SK_ColorTRANSPARENT), | 380 theme_color_(SK_ColorTRANSPARENT), |
| 346 last_sent_theme_color_(SK_ColorTRANSPARENT), | 381 last_sent_theme_color_(SK_ColorTRANSPARENT), |
| 347 capturer_count_(0), | 382 capturer_count_(0), |
| 348 should_normally_be_visible_(true), | 383 should_normally_be_visible_(true), |
| 349 is_being_destroyed_(false), | 384 is_being_destroyed_(false), |
| 350 notify_disconnection_(false), | 385 notify_disconnection_(false), |
| (...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 FOR_EACH_OBSERVER( | 2927 FOR_EACH_OBSERVER( |
| 2893 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); | 2928 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); |
| 2894 } | 2929 } |
| 2895 | 2930 |
| 2896 void WebContentsImpl::OnDidStartLoading(bool to_different_document) { | 2931 void WebContentsImpl::OnDidStartLoading(bool to_different_document) { |
| 2897 if (!HasValidFrameSource()) | 2932 if (!HasValidFrameSource()) |
| 2898 return; | 2933 return; |
| 2899 | 2934 |
| 2900 RenderFrameHostImpl* rfh = | 2935 RenderFrameHostImpl* rfh = |
| 2901 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 2936 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 2902 int64 render_frame_id = rfh->frame_tree_node()->frame_tree_node_id(); | |
| 2903 | 2937 |
| 2904 // Any main frame load to a new document should reset the load progress, since | 2938 // Any main frame load to a new document should reset the load progress, since |
| 2905 // it will replace the current page and any frames. | 2939 // it will replace the current page and any frames. |
| 2906 if (to_different_document && !rfh->GetParent()) { | 2940 if (to_different_document && !rfh->GetParent()) { |
| 2907 ResetLoadProgressState(); | 2941 ResetLoadProgressState(); |
| 2908 loading_frames_in_progress_ = 0; | 2942 rfh->set_is_loading(false); |
| 2909 rfh->frame_tree_node()->set_is_loading(false); | |
| 2910 } | 2943 } |
| 2911 | 2944 |
| 2912 // It is possible to get multiple calls to OnDidStartLoading that don't have | 2945 // This method should never be called when the frame is loading. |
| 2913 // corresponding calls to OnDidStopLoading: | 2946 // Unfortunately, it can happen if a history navigation happens during a |
| 2914 // - With "swappedout://" URLs, this happens when a RenderView gets swapped | 2947 // BeforeUnload or Unload event. |
| 2915 // out for a cross-process navigation, and it turns into a placeholder for | 2948 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 2916 // one being rendered in a different process. | 2949 // refactored in Blink. See crbug.com/466089 |
| 2917 // - Also, there might be more than one RenderFrameHost sharing the same | 2950 if (rfh->is_loading()) { |
| 2918 // FrameTreeNode (and thus sharing its ID) each sending a start. | 2951 LOG(WARNING) << "OnDidStartLoading was called twice."; |
| 2919 // - But in the future, once clamy@ moves navigation network requests to the | |
| 2920 // browser process, there's a good chance that callbacks about starting and | |
| 2921 // stopping will all be handled by the browser. When that happens, there | |
| 2922 // should no longer be a start/stop call imbalance. TODO(avi): When this | |
| 2923 // future arrives, update this code to not allow this case. | |
| 2924 if (rfh->frame_tree_node()->is_loading()) | |
| 2925 return; | 2952 return; |
| 2953 } |
| 2926 | 2954 |
| 2927 DCHECK_GE(loading_frames_in_progress_, 0); | 2955 if (!IsFrameTreeLoading(frame_tree_)) |
| 2928 if (loading_frames_in_progress_ == 0) | |
| 2929 DidStartLoading(rfh, to_different_document); | 2956 DidStartLoading(rfh, to_different_document); |
| 2930 | 2957 |
| 2931 ++loading_frames_in_progress_; | 2958 rfh->set_is_loading(true); |
| 2932 rfh->frame_tree_node()->set_is_loading(true); | 2959 rfh->set_loading_progress(RenderFrameHostImpl::kLoadingProgressMinimum); |
| 2933 | 2960 |
| 2934 // Notify the RenderFrameHostManager of the event. | 2961 // Notify the RenderFrameHostManager of the event. |
| 2935 rfh->frame_tree_node()->render_manager()->OnDidStartLoading(); | 2962 rfh->frame_tree_node()->render_manager()->OnDidStartLoading(); |
| 2936 | 2963 |
| 2937 loading_progresses_[render_frame_id] = kMinimumLoadingProgress; | |
| 2938 SendLoadProgressChanged(); | 2964 SendLoadProgressChanged(); |
| 2939 } | 2965 } |
| 2940 | 2966 |
| 2941 void WebContentsImpl::OnDidStopLoading() { | 2967 void WebContentsImpl::OnDidStopLoading() { |
| 2942 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | 2968 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is |
| 2943 // fixed. | 2969 // fixed. |
| 2944 tracked_objects::ScopedTracker tracking_profile1( | 2970 tracked_objects::ScopedTracker tracking_profile1( |
| 2945 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2971 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2946 "465796 WebContentsImpl::OnDidStopLoading::Start")); | 2972 "465796 WebContentsImpl::OnDidStopLoading::Start")); |
| 2947 | 2973 |
| 2948 if (!HasValidFrameSource()) | 2974 if (!HasValidFrameSource()) |
| 2949 return; | 2975 return; |
| 2950 | 2976 |
| 2951 RenderFrameHostImpl* rfh = | 2977 RenderFrameHostImpl* rfh = |
| 2952 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 2978 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 2953 int64 render_frame_id = rfh->frame_tree_node()->frame_tree_node_id(); | |
| 2954 rfh->frame_tree_node()->set_is_loading(false); | |
| 2955 | 2979 |
| 2956 if (loading_progresses_.find(render_frame_id) != loading_progresses_.end()) { | 2980 // This method should never be called when the frame is not loading. |
| 2957 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | 2981 // Unfortunately, it can happen if a history navigation happens during a |
| 2958 // fixed. | 2982 // BeforeUnload or Unload event. |
| 2959 tracked_objects::ScopedTracker tracking_profile2( | 2983 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 2960 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2984 // refactored in Blink. See crbug.com/466089 |
| 2961 "465796 " | 2985 if (!rfh->is_loading()) { |
| 2962 "WebContentsImpl::OnDidStopLoading::SendLoadProgressChanged")); | 2986 LOG(WARNING) << "OnDidStopLoading was called twice."; |
| 2987 return; |
| 2988 } |
| 2963 | 2989 |
| 2964 // Load stopped while we were still tracking load. Make sure we update | 2990 rfh->set_is_loading(false); |
| 2965 // progress based on this frame's completion. | 2991 rfh->set_loading_progress(RenderFrameHostImpl::kLoadingProgressDone); |
| 2966 loading_progresses_[render_frame_id] = 1.0; | 2992 |
| 2967 SendLoadProgressChanged(); | 2993 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is |
| 2968 // Then we clean-up our states. | 2994 // fixed. |
| 2969 if (loading_total_progress_ == 1.0) | 2995 tracked_objects::ScopedTracker tracking_profile2( |
| 2970 ResetLoadProgressState(); | 2996 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2971 } | 2997 "465796 " |
| 2998 "WebContentsImpl::OnDidStopLoading::SendLoadProgressChanged")); |
| 2999 |
| 3000 // Update progress based on this frame's completion. |
| 3001 SendLoadProgressChanged(); |
| 3002 |
| 3003 // Then clean-up the states. |
| 3004 if (loading_total_progress_ == 1.0) |
| 3005 ResetLoadProgressState(); |
| 2972 | 3006 |
| 2973 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | 3007 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is |
| 2974 // fixed. | 3008 // fixed. |
| 2975 tracked_objects::ScopedTracker tracking_profile3( | 3009 tracked_objects::ScopedTracker tracking_profile3( |
| 2976 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 3010 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2977 "465796 WebContentsImpl::OnDidStopLoading::NotifyRenderManager")); | 3011 "465796 WebContentsImpl::OnDidStopLoading::NotifyRenderManager")); |
| 2978 // Notify the RenderFrameHostManager of the event. | 3012 // Notify the RenderFrameHostManager of the event. |
| 2979 rfh->frame_tree_node()->render_manager()->OnDidStopLoading(); | 3013 rfh->frame_tree_node()->render_manager()->OnDidStopLoading(); |
| 2980 | 3014 |
| 2981 // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes | 3015 if (!IsFrameTreeLoading(frame_tree_)) { |
| 2982 // calls DidStopLoading() without a matching DidStartLoading(). | 3016 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is |
| 2983 if (loading_frames_in_progress_ == 0) | 3017 // fixed. |
| 2984 return; | 3018 tracked_objects::ScopedTracker tracking_profile4( |
| 3019 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 3020 "465796 WebContentsImpl::OnDidStopLoading::WCIDidStopLoading")); |
| 3021 DidStopLoading(rfh); |
| 3022 } |
| 2985 | 3023 |
| 2986 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is | 3024 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is |
| 2987 // fixed. | 3025 // fixed. |
| 2988 tracked_objects::ScopedTracker tracking_profile4( | 3026 tracked_objects::ScopedTracker tracking_profile4( |
| 2989 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 3027 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2990 "465796 WebContentsImpl::OnDidStopLoading::PDFDidStopLoading")); | 3028 "465796 WebContentsImpl::OnDidStopLoading::End")); |
| 2991 --loading_frames_in_progress_; | |
| 2992 if (loading_frames_in_progress_ == 0) | |
| 2993 DidStopLoading(rfh); | |
| 2994 } | 3029 } |
| 2995 | 3030 |
| 2996 void WebContentsImpl::OnDidChangeLoadProgress(double load_progress) { | 3031 void WebContentsImpl::OnDidChangeLoadProgress(double load_progress) { |
| 2997 if (!HasValidFrameSource()) | 3032 if (!HasValidFrameSource()) |
| 2998 return; | 3033 return; |
| 2999 | 3034 |
| 3000 RenderFrameHostImpl* rfh = | 3035 RenderFrameHostImpl* rfh = |
| 3001 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 3036 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 3002 int64 render_frame_id = rfh->frame_tree_node()->frame_tree_node_id(); | |
| 3003 | 3037 |
| 3004 loading_progresses_[render_frame_id] = load_progress; | 3038 rfh->set_loading_progress(load_progress); |
| 3005 | 3039 |
| 3006 // We notify progress change immediately for the first and last updates. | 3040 // We notify progress change immediately for the first and last updates. |
| 3007 // Also, since the message loop may be pretty busy when a page is loaded, it | 3041 // Also, since the message loop may be pretty busy when a page is loaded, it |
| 3008 // might not execute a posted task in a timely manner so we make sure to | 3042 // might not execute a posted task in a timely manner so we make sure to |
| 3009 // immediately send progress report if enough time has passed. | 3043 // immediately send progress report if enough time has passed. |
| 3010 base::TimeDelta min_delay = | 3044 base::TimeDelta min_delay = |
| 3011 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); | 3045 base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS); |
| 3012 if (load_progress == 1.0 || loading_last_progress_update_.is_null() || | 3046 if (load_progress == 1.0 || loading_last_progress_update_.is_null() || |
| 3013 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay) { | 3047 base::TimeTicks::Now() - loading_last_progress_update_ > min_delay) { |
| 3014 // If there is a pending task to send progress, it is now obsolete. | 3048 // If there is a pending task to send progress, it is now obsolete. |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3474 Details<std::pair<NavigationEntry*, bool> >(&details)); | 3508 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 3475 | 3509 |
| 3476 return true; | 3510 return true; |
| 3477 } | 3511 } |
| 3478 | 3512 |
| 3479 void WebContentsImpl::SendLoadProgressChanged() { | 3513 void WebContentsImpl::SendLoadProgressChanged() { |
| 3480 loading_last_progress_update_ = base::TimeTicks::Now(); | 3514 loading_last_progress_update_ = base::TimeTicks::Now(); |
| 3481 double progress = 0.0; | 3515 double progress = 0.0; |
| 3482 int frame_count = 0; | 3516 int frame_count = 0; |
| 3483 | 3517 |
| 3484 for (LoadingProgressMap::iterator it = loading_progresses_.begin(); | 3518 frame_tree_.ForEach( |
| 3485 it != loading_progresses_.end(); | 3519 base::Bind(&CollectLoadProgress, &progress, &frame_count)); |
| 3486 ++it) { | 3520 if (frame_count != 0) |
| 3487 progress += it->second; | 3521 progress /= frame_count; |
| 3488 ++frame_count; | 3522 DCHECK_LE(progress, 1.0); |
| 3489 } | |
| 3490 if (frame_count == 0) | |
| 3491 return; | |
| 3492 progress /= frame_count; | |
| 3493 DCHECK(progress <= 1.0); | |
| 3494 | 3523 |
| 3495 if (progress <= loading_total_progress_) | 3524 if (progress <= loading_total_progress_) |
| 3496 return; | 3525 return; |
| 3497 loading_total_progress_ = progress; | 3526 loading_total_progress_ = progress; |
| 3498 | 3527 |
| 3499 if (delegate_) | 3528 if (delegate_) |
| 3500 delegate_->LoadProgressChanged(this, progress); | 3529 delegate_->LoadProgressChanged(this, progress); |
| 3501 } | 3530 } |
| 3502 | 3531 |
| 3503 void WebContentsImpl::ResetLoadProgressState() { | 3532 void WebContentsImpl::ResetLoadProgressState() { |
| 3504 loading_progresses_.clear(); | 3533 frame_tree_.ForEach(base::Bind(&ResetLoadProgress)); |
| 3505 loading_total_progress_ = 0.0; | 3534 loading_total_progress_ = 0.0; |
| 3506 loading_weak_factory_.InvalidateWeakPtrs(); | 3535 loading_weak_factory_.InvalidateWeakPtrs(); |
| 3507 loading_last_progress_update_ = base::TimeTicks(); | 3536 loading_last_progress_update_ = base::TimeTicks(); |
| 3508 } | 3537 } |
| 3509 | 3538 |
| 3510 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, | 3539 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, |
| 3511 RenderViewHost* new_host) { | 3540 RenderViewHost* new_host) { |
| 3512 // After sending out a swap notification, we need to send a disconnect | 3541 // After sending out a swap notification, we need to send a disconnect |
| 3513 // notification so that clients that pick up a pointer to |this| can NULL the | 3542 // notification so that clients that pick up a pointer to |this| can NULL the |
| 3514 // pointer. See Bug 1230284. | 3543 // pointer. See Bug 1230284. |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3799 | 3828 |
| 3800 SetIsLoading(rvh, false, true, NULL); | 3829 SetIsLoading(rvh, false, true, NULL); |
| 3801 NotifyDisconnected(); | 3830 NotifyDisconnected(); |
| 3802 SetIsCrashed(status, error_code); | 3831 SetIsCrashed(status, error_code); |
| 3803 | 3832 |
| 3804 // Reset the loading progress. TODO(avi): What does it mean to have a | 3833 // Reset the loading progress. TODO(avi): What does it mean to have a |
| 3805 // "renderer crash" when there is more than one renderer process serving a | 3834 // "renderer crash" when there is more than one renderer process serving a |
| 3806 // webpage? Once this function is called at a more granular frame level, we | 3835 // webpage? Once this function is called at a more granular frame level, we |
| 3807 // probably will need to more granularly reset the state here. | 3836 // probably will need to more granularly reset the state here. |
| 3808 ResetLoadProgressState(); | 3837 ResetLoadProgressState(); |
| 3809 loading_frames_in_progress_ = 0; | |
| 3810 | 3838 |
| 3811 FOR_EACH_OBSERVER(WebContentsObserver, | 3839 FOR_EACH_OBSERVER(WebContentsObserver, |
| 3812 observers_, | 3840 observers_, |
| 3813 RenderProcessGone(GetCrashedStatus())); | 3841 RenderProcessGone(GetCrashedStatus())); |
| 3814 } | 3842 } |
| 3815 | 3843 |
| 3816 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 3844 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| 3817 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 3845 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); |
| 3818 } | 3846 } |
| 3819 | 3847 |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 node->render_manager()->ResumeResponseDeferredAtStart(); | 4638 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4611 } | 4639 } |
| 4612 | 4640 |
| 4613 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4641 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4614 force_disable_overscroll_content_ = force_disable; | 4642 force_disable_overscroll_content_ = force_disable; |
| 4615 if (view_) | 4643 if (view_) |
| 4616 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4644 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4617 } | 4645 } |
| 4618 | 4646 |
| 4619 } // namespace content | 4647 } // namespace content |
| OLD | NEW |