Chromium Code Reviews| 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..d3ea2dc6db042cc00cb6e9d6be292a148ab62c3c 100644 |
| --- a/content/browser/web_contents/web_contents_view_mac.mm |
| +++ b/content/browser/web_contents/web_contents_view_mac.mm |
| @@ -8,7 +8,9 @@ |
| #include <string> |
| +#import "base/mac/mac_util.h" |
| #import "base/mac/scoped_sending_event.h" |
| +#include "base/mac/sdk_forward_declarations.h" |
| #include "base/message_loop/message_loop.h" |
| #import "base/message_loop/message_pump_mac.h" |
| #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| @@ -594,4 +596,47 @@ void WebContentsViewMac::CloseTab() { |
| [subview setFrame:self.bounds]; |
| } |
| +- (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
| + NSWindow* oldWindow = [self window]; |
| + |
| + NSNotificationCenter* notificationCenter = |
| + [NSNotificationCenter defaultCenter]; |
| + |
| + // Occlusion notification APIs are new in Mavericks. |
| + bool supportsOcclusionAPIs = base::mac::IsOSMavericksOrLater(); |
| + |
| + if (oldWindow) { |
| + if (supportsOcclusionAPIs) { |
| + [notificationCenter |
| + removeObserver:self |
| + name:NSWindowDidChangeOcclusionStateNotification |
| + object:oldWindow]; |
| + } |
| + } |
| + if (newWindow) { |
| + if (supportsOcclusionAPIs) { |
| + [notificationCenter |
| + addObserver:self |
| + selector:@selector(windowChangedOcclusionState:) |
| + name:NSWindowDidChangeOcclusionStateNotification |
| + object:newWindow]; |
| + } |
| + } |
|
Avi (use Gerrit)
2014/10/30 19:32:52
Perhaps it is simpler to do:
if (supportsOcclusio
ccameron
2014/10/30 19:52:10
Yeah, I was mirroring the function in RenderWidget
|
| +} |
| + |
| +- (void)windowChangedOcclusionState:(NSNotification*)notification { |
| + DCHECK(base::mac::IsOSMavericksOrLater()); |
| + NSWindow* window = [notification object]; |
| + WebContentsImpl* webContents = [self webContents]; |
| + if (window && webContents) { |
| + if ([window occlusionState] & NSWindowOcclusionStateVisible) { |
| + if (!webContents->should_normally_be_visible()) |
| + webContents->WasShown(); |
| + } else { |
| + if (webContents->should_normally_be_visible()) |
| + webContents->WasHidden(); |
| + } |
| + } |
| +} |
| + |
| @end |