OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
6 | 6 |
7 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 674 } |
675 | 675 |
676 if (use_system_drag_) | 676 if (use_system_drag_) |
677 UpdateDraggableRegionsForSystemDrag(regions, draggable_area); | 677 UpdateDraggableRegionsForSystemDrag(regions, draggable_area); |
678 else | 678 else |
679 UpdateDraggableRegionsForCustomDrag(regions); | 679 UpdateDraggableRegionsForCustomDrag(regions); |
680 | 680 |
681 InstallDraggableRegionViews(); | 681 InstallDraggableRegionViews(); |
682 } | 682 } |
683 | 683 |
| 684 SkRegion* NativeAppWindowCocoa::GetDraggableRegion() { |
| 685 return draggable_region_.get(); |
| 686 } |
| 687 |
684 void NativeAppWindowCocoa::UpdateDraggableRegionsForSystemDrag( | 688 void NativeAppWindowCocoa::UpdateDraggableRegionsForSystemDrag( |
685 const std::vector<extensions::DraggableRegion>& regions, | 689 const std::vector<extensions::DraggableRegion>& regions, |
686 const extensions::DraggableRegion* draggable_area) { | 690 const extensions::DraggableRegion* draggable_area) { |
687 NSView* web_view = web_contents()->GetView()->GetNativeView(); | 691 NSView* web_view = web_contents()->GetView()->GetNativeView(); |
688 NSInteger web_view_width = NSWidth([web_view bounds]); | 692 NSInteger web_view_width = NSWidth([web_view bounds]); |
689 NSInteger web_view_height = NSHeight([web_view bounds]); | 693 NSInteger web_view_height = NSHeight([web_view bounds]); |
690 | 694 |
691 system_drag_exclude_areas_.clear(); | 695 system_drag_exclude_areas_.clear(); |
692 | 696 |
693 // The whole window is not draggable if no draggable area is given. | 697 // The whole window is not draggable if no draggable area is given. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { | 825 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { |
822 return [window() level] == kAlwaysOnTopWindowLevel; | 826 return [window() level] == kAlwaysOnTopWindowLevel; |
823 } | 827 } |
824 | 828 |
825 void NativeAppWindowCocoa::RenderViewHostChanged( | 829 void NativeAppWindowCocoa::RenderViewHostChanged( |
826 content::RenderViewHost* old_host, | 830 content::RenderViewHost* old_host, |
827 content::RenderViewHost* new_host) { | 831 content::RenderViewHost* new_host) { |
828 web_contents()->GetView()->Focus(); | 832 web_contents()->GetView()->Focus(); |
829 } | 833 } |
830 | 834 |
| 835 bool NativeAppWindowCocoa::IsFrameless() const { |
| 836 return !has_frame_; |
| 837 } |
| 838 |
831 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { | 839 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { |
832 if (!has_frame_) | 840 if (!has_frame_) |
833 return gfx::Insets(); | 841 return gfx::Insets(); |
834 | 842 |
835 // Flip the coordinates based on the main screen. | 843 // Flip the coordinates based on the main screen. |
836 NSInteger screen_height = | 844 NSInteger screen_height = |
837 NSHeight([[[NSScreen screens] objectAtIndex:0] frame]); | 845 NSHeight([[[NSScreen screens] objectAtIndex:0] frame]); |
838 | 846 |
839 NSRect frame_nsrect = [window() frame]; | 847 NSRect frame_nsrect = [window() frame]; |
840 gfx::Rect frame_rect(NSRectToCGRect(frame_nsrect)); | 848 gfx::Rect frame_rect(NSRectToCGRect(frame_nsrect)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 ShellNSWindow* NativeAppWindowCocoa::window() const { | 1019 ShellNSWindow* NativeAppWindowCocoa::window() const { |
1012 NSWindow* window = [window_controller_ window]; | 1020 NSWindow* window = [window_controller_ window]; |
1013 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 1021 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
1014 return static_cast<ShellNSWindow*>(window); | 1022 return static_cast<ShellNSWindow*>(window); |
1015 } | 1023 } |
1016 | 1024 |
1017 void NativeAppWindowCocoa::UpdateRestoredBounds() { | 1025 void NativeAppWindowCocoa::UpdateRestoredBounds() { |
1018 if (IsRestored(*this)) | 1026 if (IsRestored(*this)) |
1019 restored_bounds_ = [window() frame]; | 1027 restored_bounds_ = [window() frame]; |
1020 } | 1028 } |
OLD | NEW |