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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 5f209d8b89933ecea1b291a7ca9bdb675361a3a4..e02c77031447bd168bd78da1759ae6fdceb488a9 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -338,6 +338,7 @@
this,
this,
this),
+ is_loading_(false),
is_load_to_different_document_(false),
crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
crashed_error_code_(0),
@@ -346,7 +347,6 @@
upload_size_(0),
upload_position_(0),
is_resume_pending_(false),
- paused_throbber_for_interstitial_(false),
displayed_insecure_content_(false),
has_accessed_initial_document_(false),
theme_color_(SK_ColorTRANSPARENT),
@@ -896,7 +896,7 @@
// Reload the page if a load is currently in progress to avoid having
// different parts of the page loaded using different user agents.
NavigationEntry* entry = controller_.GetVisibleEntry();
- if (IsLoading() && entry != NULL && entry->GetIsOverridingUserAgent())
+ if (is_loading_ && entry != NULL && entry->GetIsOverridingUserAgent())
controller_.ReloadIgnoringCache(true);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
@@ -1036,11 +1036,11 @@
}
bool WebContentsImpl::IsLoading() const {
- return frame_tree_.IsLoading() && !paused_throbber_for_interstitial_;
+ return is_loading_;
}
bool WebContentsImpl::IsLoadingToDifferentDocument() const {
- return IsLoading() && is_load_to_different_document_;
+ return is_loading_ && is_load_to_different_document_;
}
bool WebContentsImpl::IsWaitingForResponse() const {
@@ -2308,18 +2308,6 @@
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidAttachInterstitialPage());
-
- // Stop the throbber if needed while the interstitial page is shown.
- if (IsLoading())
- LoadingStateChanged(false, true, true, nullptr);
-}
-
-void WebContentsImpl::DidProceedOnInterstitial() {
- // Restart the throbber now that the interstitial page is going away.
- if (paused_throbber_for_interstitial_) {
- if (frame_tree_.IsLoading())
- LoadingStateChanged(true, true, false, nullptr);
- }
}
void WebContentsImpl::DetachInterstitialPage() {
@@ -2327,11 +2315,6 @@
GetRenderManager()->remove_interstitial_page();
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidDetachInterstitialPage());
- // Restart the throbber now that the interstitial page is going away.
- if (paused_throbber_for_interstitial_) {
- if (frame_tree_.IsLoading())
- LoadingStateChanged(true, true, false, nullptr);
- }
}
void WebContentsImpl::SetHistoryOffsetAndLength(int history_offset,
@@ -3604,16 +3587,11 @@
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading.
-void WebContentsImpl::LoadingStateChanged(bool is_loading,
- bool to_different_document,
- bool pause_throbber_for_interstitial,
- LoadNotificationDetails* details) {
- // Do not send notifications about loading while the interstitial is showing.
- if (paused_throbber_for_interstitial_ && pause_throbber_for_interstitial)
- return;
-
- // Update whether the interstitial state.
- paused_throbber_for_interstitial_ = pause_throbber_for_interstitial;
+void WebContentsImpl::SetIsLoading(bool is_loading,
+ bool to_different_document,
+ LoadNotificationDetails* details) {
+ if (is_loading == is_loading_)
+ return;
if (!is_loading) {
load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE,
@@ -3625,6 +3603,7 @@
GetRenderManager()->SetIsLoading(is_loading);
+ is_loading_ = is_loading;
waiting_for_response_ = is_loading;
is_load_to_different_document_ = to_different_document;
@@ -3977,13 +3956,15 @@
if (delegate_)
delegate_->HideValidationMessage(this);
+ SetIsLoading(false, true, nullptr);
+ NotifyDisconnected();
+ SetIsCrashed(status, error_code);
+
// Reset the loading progress. TODO(avi): What does it mean to have a
// "renderer crash" when there is more than one renderer process serving a
// webpage? Once this function is called at a more granular frame level, we
// probably will need to more granularly reset the state here.
ResetLoadProgressState();
- NotifyDisconnected();
- SetIsCrashed(status, error_code);
FOR_EACH_OBSERVER(WebContentsObserver,
observers_,
@@ -4077,8 +4058,7 @@
void WebContentsImpl::DidStartLoading(FrameTreeNode* frame_tree_node,
bool to_different_document) {
- LoadingStateChanged(true, to_different_document,
- paused_throbber_for_interstitial_, nullptr);
+ SetIsLoading(true, to_different_document, nullptr);
// Notify accessibility that the user is navigating away from the
// current document.
@@ -4112,8 +4092,7 @@
controller_.GetCurrentEntryIndex()));
}
- LoadingStateChanged(false, true, paused_throbber_for_interstitial_,
- details.get());
+ SetIsLoading(false, true, details.get());
}
void WebContentsImpl::DidChangeLoadProgress() {
@@ -4650,8 +4629,10 @@
last_dialog_suppressed_ = dialog_was_suppressed;
if (is_showing_before_unload_dialog_ && !success) {
+ // If a beforeunload dialog is canceled, we need to stop the throbber from
+ // spinning, since we forced it to start spinning in Navigate.
if (rfh)
- rfh->frame_tree_node()->BeforeUnloadCanceled();
+ DidStopLoading();
controller_.DiscardNonCommittedEntries();
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
« 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