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

Unified Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 666123003: Mac: Use Mavericks occlusion APIs for power savings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move occlusion handling to WebContentsViewMac Created 6 years, 2 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_view_mac.mm
diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm
index 42348a97bca9cd9c2c15006740f5fcafc521d603..b2e3dd71a0f4da1173d3f42949c469493d0235bf 100644
--- a/content/browser/web_contents/web_contents_view_mac.mm
+++ b/content/browser/web_contents/web_contents_view_mac.mm
@@ -8,6 +8,7 @@
#include <string>
+#include "base/mac/mac_util.h"
#import "base/mac/scoped_sending_event.h"
#include "base/message_loop/message_loop.h"
#import "base/message_loop/message_pump_mac.h"
@@ -594,4 +595,40 @@ void WebContentsViewMac::CloseTab() {
[subview setFrame:self.bounds];
}
+- (void)viewWillMoveToWindow:(NSWindow*)newWindow {
+ // Occlusion notification is new in Mavericks.
+ if (base::mac::IsOSMavericksOrLater())
+ return;
+
+ NSWindow* oldWindow = [self window];
+
+ if (oldWindow) {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:NSWindowDidChangeOcclusionStateNotification
+ object:oldWindow];
+ }
+
+ if (newWindow) {
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(windowChangedOcclusionState:)
+ name:NSWindowDidChangeOcclusionStateNotification
+ object:newWindow];
+ }
+}
+
+- (void)windowChangedOcclusionState:(NSNotification*)notification {
+ DCHECK(base::mac::IsOSMavericksOrLater());
+ NSWindow* window = [notification object];
+ WebContentsImpl* webContents = [self webContents];
+ if ([window occlusionState] & NSWindowOcclusionStateVisible) {
+ if (!webContents->should_normally_be_visible())
+ webContents->WasShown();
+ } else {
+ if (webContents->should_normally_be_visible())
+ webContents->WasHidden();
+ }
+}
+
@end
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698