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

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

Issue 286943005: Reducing CPU cycles of hidden/minimized browser windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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_view_aura.cc
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index f134da3b24a005846f9d5709db22112628a86698..610d9d095149f9517ba987644997fb16ded8abb9 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -98,6 +98,18 @@ bool ShouldNavigateBack(const NavigationController& controller,
controller.CanGoBack();
}
+// Update the |visibility| of the |web contents|.
+void UpdateWebContentsVisibility(WebContentsImpl* web_contents,
+ bool visibility) {
sky 2014/05/20 23:33:51 visibility->visible
Mr4D (OOO till 08-26) 2014/05/21 14:25:03 Done.
+ if (visibility) {
+ if (!web_contents->should_normally_be_visible())
+ web_contents->WasShown();
+ } else {
+ if (web_contents->should_normally_be_visible())
+ web_contents->WasHidden();
+ }
+}
+
RenderWidgetHostViewAura* ToRenderWidgetHostViewAura(
RenderWidgetHostView* view) {
if (!view || RenderViewHostFactory::has_factory())
@@ -721,6 +733,7 @@ WebContentsViewAura::~WebContentsViewAura() {
// Window needs a valid delegate during its destructor, so we explicitly
// delete it here.
+ window_->RemoveObserver(this);
sky 2014/05/20 23:33:51 nit: move this above comment (since comment applie
Mr4D (OOO till 08-26) 2014/05/21 14:25:03 Done.
window_.reset();
}
@@ -1045,6 +1058,7 @@ void WebContentsViewAura::CreateView(
window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
window_->SetTransparent(false);
window_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
+ window_->AddObserver(this);
aura::Window* root_window = context ? context->GetRootWindow() : NULL;
if (root_window) {
// There are places where there is no context currently because object
@@ -1429,10 +1443,6 @@ void WebContentsViewAura::OnWindowDestroyed(aura::Window* window) {
}
void WebContentsViewAura::OnWindowTargetVisibilityChanged(bool visible) {
- if (visible)
- web_contents_->WasShown();
- else
- web_contents_->WasHidden();
}
bool WebContentsViewAura::HasHitTestMask() const {
@@ -1555,4 +1565,18 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) {
return ConvertFromWeb(current_drag_op_);
}
+void WebContentsViewAura::OnWindowParentChanged(aura::Window* window,
+ aura::Window* parent) {
+ UpdateWebContentsVisibility(web_contents_, !parent || parent->IsVisible());
+}
+
+void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window,
+ bool visible) {
+ // Ignore any visibility changes in the hierarchy below.
+ if (window != window_.get() && window_->Contains(window))
+ return;
+
+ UpdateWebContentsVisibility(web_contents_, visible);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698