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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1733173002: Mac: Make calling WebContents::WasShown/WasHidden the responsibility of the content layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments 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 3103e95e56624064e720877fba1a733c05020155..d08a20988a0bea07fadf417175b7853dcb9524f4 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -338,6 +338,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
did_first_visually_non_empty_paint_(false),
capturer_count_(0),
should_normally_be_visible_(true),
+ did_first_set_visible_(false),
is_being_destroyed_(false),
notify_disconnection_(false),
dialog_manager_(NULL),
@@ -4798,6 +4799,29 @@ void WebContentsImpl::MediaStoppedPlaying(
FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id));
}
+void WebContentsImpl::UpdateWebContentsVisibility(bool visible) {
+ if (!did_first_set_visible_) {
+ // If this WebContents has not yet been set to be visible for the first
+ // time, ignore any requests to make it hidden, since resources would
+ // immediately be destroyed and only re-created after content loaded. In
+ // this state the window content is undefined and can show garbage.
+ // However, the page load mechanism requires an activation call through a
+ // visibility call to (re)load.
+ if (visible) {
+ did_first_set_visible_ = true;
+ WasShown();
+ }
+ return;
+ }
+ if (visible == should_normally_be_visible_)
+ return;
+
+ if (visible)
+ WasShown();
+ else
+ WasHidden();
+}
+
void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
JavaScriptDialogManager* dialog_manager) {
dialog_manager_ = dialog_manager;

Powered by Google App Engine
This is Rietveld 408576698