OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/web_contents/web_contents_view_mac.h" | 7 #import "content/browser/web_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #import "base/mac/mac_util.h" | |
11 #import "base/mac/scoped_sending_event.h" | 12 #import "base/mac/scoped_sending_event.h" |
13 #include "base/mac/sdk_forward_declarations.h" | |
12 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
13 #import "base/message_loop/message_pump_mac.h" | 15 #import "base/message_loop/message_pump_mac.h" |
14 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 16 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
15 #include "content/browser/renderer_host/render_view_host_factory.h" | 17 #include "content/browser/renderer_host/render_view_host_factory.h" |
16 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 19 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
19 #import "content/browser/web_contents/web_drag_dest_mac.h" | 21 #import "content/browser/web_contents/web_drag_dest_mac.h" |
20 #import "content/browser/web_contents/web_drag_source_mac.h" | 22 #import "content/browser/web_contents/web_drag_source_mac.h" |
21 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 | 589 |
588 // When the subviews require a layout, their size should be reset to the size | 590 // When the subviews require a layout, their size should be reset to the size |
589 // of this view. (It is possible for the size to get out of sync as an | 591 // of this view. (It is possible for the size to get out of sync as an |
590 // optimization in preparation for an upcoming WebContentsView resize. | 592 // optimization in preparation for an upcoming WebContentsView resize. |
591 // http://crbug.com/264207) | 593 // http://crbug.com/264207) |
592 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 594 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
593 for (NSView* subview in self.subviews) | 595 for (NSView* subview in self.subviews) |
594 [subview setFrame:self.bounds]; | 596 [subview setFrame:self.bounds]; |
595 } | 597 } |
596 | 598 |
599 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { | |
600 NSWindow* oldWindow = [self window]; | |
601 | |
602 NSNotificationCenter* notificationCenter = | |
603 [NSNotificationCenter defaultCenter]; | |
604 | |
605 // Occlusion notification APIs are new in Mavericks. | |
606 bool supportsOcclusionAPIs = base::mac::IsOSMavericksOrLater(); | |
607 | |
608 if (oldWindow) { | |
609 if (supportsOcclusionAPIs) { | |
610 [notificationCenter | |
611 removeObserver:self | |
612 name:NSWindowDidChangeOcclusionStateNotification | |
613 object:oldWindow]; | |
614 } | |
615 } | |
616 if (newWindow) { | |
617 if (supportsOcclusionAPIs) { | |
618 [notificationCenter | |
619 addObserver:self | |
620 selector:@selector(windowChangedOcclusionState:) | |
621 name:NSWindowDidChangeOcclusionStateNotification | |
622 object:newWindow]; | |
623 } | |
624 } | |
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
| |
625 } | |
626 | |
627 - (void)windowChangedOcclusionState:(NSNotification*)notification { | |
628 DCHECK(base::mac::IsOSMavericksOrLater()); | |
629 NSWindow* window = [notification object]; | |
630 WebContentsImpl* webContents = [self webContents]; | |
631 if (window && webContents) { | |
632 if ([window occlusionState] & NSWindowOcclusionStateVisible) { | |
633 if (!webContents->should_normally_be_visible()) | |
634 webContents->WasShown(); | |
635 } else { | |
636 if (webContents->should_normally_be_visible()) | |
637 webContents->WasHidden(); | |
638 } | |
639 } | |
640 } | |
641 | |
597 @end | 642 @end |
OLD | NEW |