Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1696973002: Revert of Reland #1 Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 render_view_host_delegate_view_(NULL), 331 render_view_host_delegate_view_(NULL),
332 created_with_opener_(false), 332 created_with_opener_(false),
333 #if defined(OS_WIN) 333 #if defined(OS_WIN)
334 accessible_parent_(NULL), 334 accessible_parent_(NULL),
335 #endif 335 #endif
336 frame_tree_(new NavigatorImpl(&controller_, this), 336 frame_tree_(new NavigatorImpl(&controller_, this),
337 this, 337 this,
338 this, 338 this,
339 this, 339 this,
340 this), 340 this),
341 is_loading_(false),
341 is_load_to_different_document_(false), 342 is_load_to_different_document_(false),
342 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 343 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
343 crashed_error_code_(0), 344 crashed_error_code_(0),
344 waiting_for_response_(false), 345 waiting_for_response_(false),
345 load_state_(net::LOAD_STATE_IDLE, base::string16()), 346 load_state_(net::LOAD_STATE_IDLE, base::string16()),
346 upload_size_(0), 347 upload_size_(0),
347 upload_position_(0), 348 upload_position_(0),
348 is_resume_pending_(false), 349 is_resume_pending_(false),
349 paused_throbber_for_interstitial_(false),
350 displayed_insecure_content_(false), 350 displayed_insecure_content_(false),
351 has_accessed_initial_document_(false), 351 has_accessed_initial_document_(false),
352 theme_color_(SK_ColorTRANSPARENT), 352 theme_color_(SK_ColorTRANSPARENT),
353 last_sent_theme_color_(SK_ColorTRANSPARENT), 353 last_sent_theme_color_(SK_ColorTRANSPARENT),
354 did_first_visually_non_empty_paint_(false), 354 did_first_visually_non_empty_paint_(false),
355 capturer_count_(0), 355 capturer_count_(0),
356 should_normally_be_visible_(true), 356 should_normally_be_visible_(true),
357 is_being_destroyed_(false), 357 is_being_destroyed_(false),
358 notify_disconnection_(false), 358 notify_disconnection_(false),
359 dialog_manager_(NULL), 359 dialog_manager_(NULL),
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 renderer_preferences_.user_agent_override = override; 889 renderer_preferences_.user_agent_override = override;
890 890
891 // Send the new override string to the renderer. 891 // Send the new override string to the renderer.
892 RenderViewHost* host = GetRenderViewHost(); 892 RenderViewHost* host = GetRenderViewHost();
893 if (host) 893 if (host)
894 host->SyncRendererPrefs(); 894 host->SyncRendererPrefs();
895 895
896 // Reload the page if a load is currently in progress to avoid having 896 // Reload the page if a load is currently in progress to avoid having
897 // different parts of the page loaded using different user agents. 897 // different parts of the page loaded using different user agents.
898 NavigationEntry* entry = controller_.GetVisibleEntry(); 898 NavigationEntry* entry = controller_.GetVisibleEntry();
899 if (IsLoading() && entry != NULL && entry->GetIsOverridingUserAgent()) 899 if (is_loading_ && entry != NULL && entry->GetIsOverridingUserAgent())
900 controller_.ReloadIgnoringCache(true); 900 controller_.ReloadIgnoringCache(true);
901 901
902 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 902 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
903 UserAgentOverrideSet(override)); 903 UserAgentOverrideSet(override));
904 } 904 }
905 905
906 const std::string& WebContentsImpl::GetUserAgentOverride() const { 906 const std::string& WebContentsImpl::GetUserAgentOverride() const {
907 return renderer_preferences_.user_agent_override; 907 return renderer_preferences_.user_agent_override;
908 } 908 }
909 909
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1029
1030 SiteInstanceImpl* WebContentsImpl::GetPendingSiteInstance() const { 1030 SiteInstanceImpl* WebContentsImpl::GetPendingSiteInstance() const {
1031 RenderViewHostImpl* dest_rvh = 1031 RenderViewHostImpl* dest_rvh =
1032 GetRenderManager()->pending_render_view_host() ? 1032 GetRenderManager()->pending_render_view_host() ?
1033 GetRenderManager()->pending_render_view_host() : 1033 GetRenderManager()->pending_render_view_host() :
1034 GetRenderManager()->current_host(); 1034 GetRenderManager()->current_host();
1035 return dest_rvh->GetSiteInstance(); 1035 return dest_rvh->GetSiteInstance();
1036 } 1036 }
1037 1037
1038 bool WebContentsImpl::IsLoading() const { 1038 bool WebContentsImpl::IsLoading() const {
1039 return frame_tree_.IsLoading() && !paused_throbber_for_interstitial_; 1039 return is_loading_;
1040 } 1040 }
1041 1041
1042 bool WebContentsImpl::IsLoadingToDifferentDocument() const { 1042 bool WebContentsImpl::IsLoadingToDifferentDocument() const {
1043 return IsLoading() && is_load_to_different_document_; 1043 return is_loading_ && is_load_to_different_document_;
1044 } 1044 }
1045 1045
1046 bool WebContentsImpl::IsWaitingForResponse() const { 1046 bool WebContentsImpl::IsWaitingForResponse() const {
1047 return waiting_for_response_ && is_load_to_different_document_; 1047 return waiting_for_response_ && is_load_to_different_document_;
1048 } 1048 }
1049 1049
1050 const net::LoadStateWithParam& WebContentsImpl::GetLoadState() const { 1050 const net::LoadStateWithParam& WebContentsImpl::GetLoadState() const {
1051 return load_state_; 1051 return load_state_;
1052 } 1052 }
1053 1053
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 InterstitialPageImpl* interstitial_page) { 2301 InterstitialPageImpl* interstitial_page) {
2302 DCHECK(interstitial_page); 2302 DCHECK(interstitial_page);
2303 GetRenderManager()->set_interstitial_page(interstitial_page); 2303 GetRenderManager()->set_interstitial_page(interstitial_page);
2304 2304
2305 // Cancel any visible dialogs so that they don't interfere with the 2305 // Cancel any visible dialogs so that they don't interfere with the
2306 // interstitial. 2306 // interstitial.
2307 CancelActiveAndPendingDialogs(); 2307 CancelActiveAndPendingDialogs();
2308 2308
2309 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2309 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2310 DidAttachInterstitialPage()); 2310 DidAttachInterstitialPage());
2311
2312 // Stop the throbber if needed while the interstitial page is shown.
2313 if (IsLoading())
2314 LoadingStateChanged(false, true, true, nullptr);
2315 }
2316
2317 void WebContentsImpl::DidProceedOnInterstitial() {
2318 // Restart the throbber now that the interstitial page is going away.
2319 if (paused_throbber_for_interstitial_) {
2320 if (frame_tree_.IsLoading())
2321 LoadingStateChanged(true, true, false, nullptr);
2322 }
2323 } 2311 }
2324 2312
2325 void WebContentsImpl::DetachInterstitialPage() { 2313 void WebContentsImpl::DetachInterstitialPage() {
2326 if (ShowingInterstitialPage()) 2314 if (ShowingInterstitialPage())
2327 GetRenderManager()->remove_interstitial_page(); 2315 GetRenderManager()->remove_interstitial_page();
2328 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2316 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2329 DidDetachInterstitialPage()); 2317 DidDetachInterstitialPage());
2330 // Restart the throbber now that the interstitial page is going away.
2331 if (paused_throbber_for_interstitial_) {
2332 if (frame_tree_.IsLoading())
2333 LoadingStateChanged(true, true, false, nullptr);
2334 }
2335 } 2318 }
2336 2319
2337 void WebContentsImpl::SetHistoryOffsetAndLength(int history_offset, 2320 void WebContentsImpl::SetHistoryOffsetAndLength(int history_offset,
2338 int history_length) { 2321 int history_length) {
2339 SetHistoryOffsetAndLengthForView( 2322 SetHistoryOffsetAndLengthForView(
2340 GetRenderViewHost(), history_offset, history_length); 2323 GetRenderViewHost(), history_offset, history_length);
2341 } 2324 }
2342 2325
2343 void WebContentsImpl::SetHistoryOffsetAndLengthForView( 2326 void WebContentsImpl::SetHistoryOffsetAndLengthForView(
2344 RenderViewHost* render_view_host, 2327 RenderViewHost* render_view_host,
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
3597 if (delegate_) 3580 if (delegate_)
3598 delegate_->ShowRepostFormWarningDialog(this); 3581 delegate_->ShowRepostFormWarningDialog(this);
3599 } 3582 }
3600 3583
3601 bool WebContentsImpl::HasAccessedInitialDocument() { 3584 bool WebContentsImpl::HasAccessedInitialDocument() {
3602 return has_accessed_initial_document_; 3585 return has_accessed_initial_document_;
3603 } 3586 }
3604 3587
3605 // Notifies the RenderWidgetHost instance about the fact that the page is 3588 // Notifies the RenderWidgetHost instance about the fact that the page is
3606 // loading, or done loading. 3589 // loading, or done loading.
3607 void WebContentsImpl::LoadingStateChanged(bool is_loading, 3590 void WebContentsImpl::SetIsLoading(bool is_loading,
3608 bool to_different_document, 3591 bool to_different_document,
3609 bool pause_throbber_for_interstitial, 3592 LoadNotificationDetails* details) {
3610 LoadNotificationDetails* details) { 3593 if (is_loading == is_loading_)
3611 // Do not send notifications about loading while the interstitial is showing.
3612 if (paused_throbber_for_interstitial_ && pause_throbber_for_interstitial)
3613 return; 3594 return;
3614 3595
3615 // Update whether the interstitial state.
3616 paused_throbber_for_interstitial_ = pause_throbber_for_interstitial;
3617
3618 if (!is_loading) { 3596 if (!is_loading) {
3619 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, 3597 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE,
3620 base::string16()); 3598 base::string16());
3621 load_state_host_.clear(); 3599 load_state_host_.clear();
3622 upload_size_ = 0; 3600 upload_size_ = 0;
3623 upload_position_ = 0; 3601 upload_position_ = 0;
3624 } 3602 }
3625 3603
3626 GetRenderManager()->SetIsLoading(is_loading); 3604 GetRenderManager()->SetIsLoading(is_loading);
3627 3605
3606 is_loading_ = is_loading;
3628 waiting_for_response_ = is_loading; 3607 waiting_for_response_ = is_loading;
3629 is_load_to_different_document_ = to_different_document; 3608 is_load_to_different_document_ = to_different_document;
3630 3609
3631 if (delegate_) 3610 if (delegate_)
3632 delegate_->LoadingStateChanged(this, to_different_document); 3611 delegate_->LoadingStateChanged(this, to_different_document);
3633 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); 3612 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD);
3634 3613
3635 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); 3614 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL");
3636 if (is_loading) { 3615 if (is_loading) {
3637 TRACE_EVENT_ASYNC_BEGIN2("browser,navigation", "WebContentsImpl Loading", 3616 TRACE_EVENT_ASYNC_BEGIN2("browser,navigation", "WebContentsImpl Loading",
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 // renderer may not have made a clean exit. 3949 // renderer may not have made a clean exit.
3971 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) 3950 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()))
3972 ExitFullscreenMode(false); 3951 ExitFullscreenMode(false);
3973 3952
3974 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3953 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3975 CancelActiveAndPendingDialogs(); 3954 CancelActiveAndPendingDialogs();
3976 3955
3977 if (delegate_) 3956 if (delegate_)
3978 delegate_->HideValidationMessage(this); 3957 delegate_->HideValidationMessage(this);
3979 3958
3959 SetIsLoading(false, true, nullptr);
3960 NotifyDisconnected();
3961 SetIsCrashed(status, error_code);
3962
3980 // Reset the loading progress. TODO(avi): What does it mean to have a 3963 // Reset the loading progress. TODO(avi): What does it mean to have a
3981 // "renderer crash" when there is more than one renderer process serving a 3964 // "renderer crash" when there is more than one renderer process serving a
3982 // webpage? Once this function is called at a more granular frame level, we 3965 // webpage? Once this function is called at a more granular frame level, we
3983 // probably will need to more granularly reset the state here. 3966 // probably will need to more granularly reset the state here.
3984 ResetLoadProgressState(); 3967 ResetLoadProgressState();
3985 NotifyDisconnected();
3986 SetIsCrashed(status, error_code);
3987 3968
3988 FOR_EACH_OBSERVER(WebContentsObserver, 3969 FOR_EACH_OBSERVER(WebContentsObserver,
3989 observers_, 3970 observers_,
3990 RenderProcessGone(GetCrashedStatus())); 3971 RenderProcessGone(GetCrashedStatus()));
3991 } 3972 }
3992 3973
3993 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { 3974 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) {
3994 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); 3975 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh));
3995 } 3976 }
3996 3977
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
4070 delegate_->SwappedOut(this); 4051 delegate_->SwappedOut(this);
4071 } 4052 }
4072 4053
4073 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { 4054 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
4074 if (delegate_ && delegate_->IsPopupOrPanel(this)) 4055 if (delegate_ && delegate_->IsPopupOrPanel(this))
4075 delegate_->MoveContents(this, new_bounds); 4056 delegate_->MoveContents(this, new_bounds);
4076 } 4057 }
4077 4058
4078 void WebContentsImpl::DidStartLoading(FrameTreeNode* frame_tree_node, 4059 void WebContentsImpl::DidStartLoading(FrameTreeNode* frame_tree_node,
4079 bool to_different_document) { 4060 bool to_different_document) {
4080 LoadingStateChanged(true, to_different_document, 4061 SetIsLoading(true, to_different_document, nullptr);
4081 paused_throbber_for_interstitial_, nullptr);
4082 4062
4083 // Notify accessibility that the user is navigating away from the 4063 // Notify accessibility that the user is navigating away from the
4084 // current document. 4064 // current document.
4085 // 4065 //
4086 // TODO(dmazzoni): do this using a WebContentsObserver. 4066 // TODO(dmazzoni): do this using a WebContentsObserver.
4087 BrowserAccessibilityManager* manager = 4067 BrowserAccessibilityManager* manager =
4088 frame_tree_node->current_frame_host()->browser_accessibility_manager(); 4068 frame_tree_node->current_frame_host()->browser_accessibility_manager();
4089 if (manager) 4069 if (manager)
4090 manager->UserIsNavigatingAway(); 4070 manager->UserIsNavigatingAway();
4091 } 4071 }
(...skipping 13 matching lines...) Expand all
4105 base::TimeTicks::Now() - navigator->GetCurrentLoadStart(); 4085 base::TimeTicks::Now() - navigator->GetCurrentLoadStart();
4106 4086
4107 details.reset(new LoadNotificationDetails( 4087 details.reset(new LoadNotificationDetails(
4108 entry->GetVirtualURL(), 4088 entry->GetVirtualURL(),
4109 entry->GetTransitionType(), 4089 entry->GetTransitionType(),
4110 elapsed, 4090 elapsed,
4111 &controller_, 4091 &controller_,
4112 controller_.GetCurrentEntryIndex())); 4092 controller_.GetCurrentEntryIndex()));
4113 } 4093 }
4114 4094
4115 LoadingStateChanged(false, true, paused_throbber_for_interstitial_, 4095 SetIsLoading(false, true, details.get());
4116 details.get());
4117 } 4096 }
4118 4097
4119 void WebContentsImpl::DidChangeLoadProgress() { 4098 void WebContentsImpl::DidChangeLoadProgress() {
4120 double load_progress = frame_tree_.load_progress(); 4099 double load_progress = frame_tree_.load_progress();
4121 4100
4122 // The delegate is notified immediately for the first and last updates. Also, 4101 // The delegate is notified immediately for the first and last updates. Also,
4123 // since the message loop may be pretty busy when a page is loaded, it might 4102 // since the message loop may be pretty busy when a page is loaded, it might
4124 // not execute a posted task in a timely manner so the progress report is sent 4103 // not execute a posted task in a timely manner so the progress report is sent
4125 // immediately if enough time has passed. 4104 // immediately if enough time has passed.
4126 base::TimeDelta min_delay = 4105 base::TimeDelta min_delay =
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
4643 int render_frame_id, 4622 int render_frame_id,
4644 IPC::Message* reply_msg, 4623 IPC::Message* reply_msg,
4645 bool dialog_was_suppressed, 4624 bool dialog_was_suppressed,
4646 bool success, 4625 bool success,
4647 const base::string16& user_input) { 4626 const base::string16& user_input) {
4648 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, 4627 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id,
4649 render_frame_id); 4628 render_frame_id);
4650 last_dialog_suppressed_ = dialog_was_suppressed; 4629 last_dialog_suppressed_ = dialog_was_suppressed;
4651 4630
4652 if (is_showing_before_unload_dialog_ && !success) { 4631 if (is_showing_before_unload_dialog_ && !success) {
4632 // If a beforeunload dialog is canceled, we need to stop the throbber from
4633 // spinning, since we forced it to start spinning in Navigate.
4653 if (rfh) 4634 if (rfh)
4654 rfh->frame_tree_node()->BeforeUnloadCanceled(); 4635 DidStopLoading();
4655 controller_.DiscardNonCommittedEntries(); 4636 controller_.DiscardNonCommittedEntries();
4656 4637
4657 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 4638 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
4658 BeforeUnloadDialogCancelled()); 4639 BeforeUnloadDialogCancelled());
4659 } 4640 }
4660 4641
4661 is_showing_before_unload_dialog_ = false; 4642 is_showing_before_unload_dialog_ = false;
4662 if (rfh) { 4643 if (rfh) {
4663 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, 4644 rfh->JavaScriptDialogClosed(reply_msg, success, user_input,
4664 dialog_was_suppressed); 4645 dialog_was_suppressed);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 const WebContentsObserver::MediaPlayerId& id) { 4751 const WebContentsObserver::MediaPlayerId& id) {
4771 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); 4752 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id));
4772 } 4753 }
4773 4754
4774 void WebContentsImpl::MediaStoppedPlaying( 4755 void WebContentsImpl::MediaStoppedPlaying(
4775 const WebContentsObserver::MediaPlayerId& id) { 4756 const WebContentsObserver::MediaPlayerId& id) {
4776 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); 4757 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id));
4777 } 4758 }
4778 4759
4779 } // namespace content 4760 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698