| 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 #include "base/mac/mac_util.h" |
| 11 #import "base/mac/scoped_sending_event.h" | 12 #import "base/mac/scoped_sending_event.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #import "base/message_loop/message_pump_mac.h" | 14 #import "base/message_loop/message_pump_mac.h" |
| 14 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 15 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| 15 #include "content/browser/renderer_host/render_view_host_factory.h" | 16 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 17 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #import "content/browser/web_contents/web_drag_dest_mac.h" | 20 #import "content/browser/web_contents/web_drag_dest_mac.h" |
| 20 #import "content/browser/web_contents/web_drag_source_mac.h" | 21 #import "content/browser/web_contents/web_drag_source_mac.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 588 |
| 588 // When the subviews require a layout, their size should be reset to the size | 589 // 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 | 590 // 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. | 591 // optimization in preparation for an upcoming WebContentsView resize. |
| 591 // http://crbug.com/264207) | 592 // http://crbug.com/264207) |
| 592 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 593 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
| 593 for (NSView* subview in self.subviews) | 594 for (NSView* subview in self.subviews) |
| 594 [subview setFrame:self.bounds]; | 595 [subview setFrame:self.bounds]; |
| 595 } | 596 } |
| 596 | 597 |
| 598 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
| 599 // Occlusion notification is new in Mavericks. |
| 600 if (base::mac::IsOSMavericksOrLater()) |
| 601 return; |
| 602 |
| 603 NSWindow* oldWindow = [self window]; |
| 604 |
| 605 if (oldWindow) { |
| 606 [[NSNotificationCenter defaultCenter] |
| 607 removeObserver:self |
| 608 name:NSWindowDidChangeOcclusionStateNotification |
| 609 object:oldWindow]; |
| 610 } |
| 611 |
| 612 if (newWindow) { |
| 613 [[NSNotificationCenter defaultCenter] |
| 614 addObserver:self |
| 615 selector:@selector(windowChangedOcclusionState:) |
| 616 name:NSWindowDidChangeOcclusionStateNotification |
| 617 object:newWindow]; |
| 618 } |
| 619 } |
| 620 |
| 621 - (void)windowChangedOcclusionState:(NSNotification*)notification { |
| 622 DCHECK(base::mac::IsOSMavericksOrLater()); |
| 623 NSWindow* window = [notification object]; |
| 624 WebContentsImpl* webContents = [self webContents]; |
| 625 if ([window occlusionState] & NSWindowOcclusionStateVisible) { |
| 626 if (!webContents->should_normally_be_visible()) |
| 627 webContents->WasShown(); |
| 628 } else { |
| 629 if (webContents->should_normally_be_visible()) |
| 630 webContents->WasHidden(); |
| 631 } |
| 632 } |
| 633 |
| 597 @end | 634 @end |
| OLD | NEW |