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 (supportsOcclusionAPIs) { |
| 609 if (oldWindow) { |
| 610 [notificationCenter |
| 611 removeObserver:self |
| 612 name:NSWindowDidChangeOcclusionStateNotification |
| 613 object:oldWindow]; |
| 614 } |
| 615 if (newWindow) { |
| 616 [notificationCenter |
| 617 addObserver:self |
| 618 selector:@selector(windowChangedOcclusionState:) |
| 619 name:NSWindowDidChangeOcclusionStateNotification |
| 620 object:newWindow]; |
| 621 } |
| 622 } |
| 623 } |
| 624 |
| 625 - (void)windowChangedOcclusionState:(NSNotification*)notification { |
| 626 DCHECK(base::mac::IsOSMavericksOrLater()); |
| 627 NSWindow* window = [notification object]; |
| 628 WebContentsImpl* webContents = [self webContents]; |
| 629 if (window && webContents) { |
| 630 if ([window occlusionState] & NSWindowOcclusionStateVisible) { |
| 631 if (!webContents->should_normally_be_visible()) |
| 632 webContents->WasShown(); |
| 633 } else { |
| 634 if (webContents->should_normally_be_visible()) |
| 635 webContents->WasHidden(); |
| 636 } |
| 637 } |
| 638 } |
| 639 |
597 @end | 640 @end |
OLD | NEW |