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 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 // We still need one ControlRegionView to cover the whole window such that | 576 // We still need one ControlRegionView to cover the whole window such that |
577 // mouse events could be captured. | 577 // mouse events could be captured. |
578 NSView* web_view = web_contents()->GetView()->GetNativeView(); | 578 NSView* web_view = web_contents()->GetView()->GetNativeView(); |
579 gfx::Rect window_bounds( | 579 gfx::Rect window_bounds( |
580 0, 0, NSWidth([web_view bounds]), NSHeight([web_view bounds])); | 580 0, 0, NSWidth([web_view bounds]), NSHeight([web_view bounds])); |
581 system_drag_exclude_areas_.clear(); | 581 system_drag_exclude_areas_.clear(); |
582 system_drag_exclude_areas_.push_back(window_bounds); | 582 system_drag_exclude_areas_.push_back(window_bounds); |
583 | 583 |
584 // Aggregate the draggable areas and non-draggable areas such that hit test | 584 // Aggregate the draggable areas and non-draggable areas such that hit test |
585 // could be performed easily. | 585 // could be performed easily. |
586 SkRegion* draggable_region = new SkRegion; | 586 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
587 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | |
588 regions.begin(); | |
589 iter != regions.end(); | |
590 ++iter) { | |
591 const extensions::DraggableRegion& region = *iter; | |
592 draggable_region->op( | |
593 region.bounds.x(), | |
594 region.bounds.y(), | |
595 region.bounds.right(), | |
596 region.bounds.bottom(), | |
597 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | |
598 } | |
599 draggable_region_.reset(draggable_region); | |
600 } | |
601 | |
602 void ShellWindowCocoa::UpdateLegacyDraggableRegions( | |
603 const std::vector<extensions::DraggableRegion>& regions) { | |
604 // Draggable region is not supported for non-frameless window. | |
605 if (has_frame_) | |
606 return; | |
607 | |
608 system_drag_exclude_areas_.clear(); | |
609 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | |
610 regions.begin(); | |
611 iter != regions.end(); | |
612 ++iter) { | |
613 system_drag_exclude_areas_.push_back(iter->bounds); | |
614 } | |
615 InstallDraggableRegionViews(); | |
616 } | 587 } |
617 | 588 |
618 void ShellWindowCocoa::HandleKeyboardEvent( | 589 void ShellWindowCocoa::HandleKeyboardEvent( |
619 const content::NativeWebKeyboardEvent& event) { | 590 const content::NativeWebKeyboardEvent& event) { |
620 if (event.skip_in_browser || | 591 if (event.skip_in_browser || |
621 event.type == content::NativeWebKeyboardEvent::Char) { | 592 event.type == content::NativeWebKeyboardEvent::Char) { |
622 return; | 593 return; |
623 } | 594 } |
624 [window() redispatchKeyEvent:event.os_event]; | 595 [window() redispatchKeyEvent:event.os_event]; |
625 } | 596 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 NSWindow* window = [window_controller_ window]; | 704 NSWindow* window = [window_controller_ window]; |
734 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 705 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
735 return static_cast<ShellNSWindow*>(window); | 706 return static_cast<ShellNSWindow*>(window); |
736 } | 707 } |
737 | 708 |
738 // static | 709 // static |
739 NativeShellWindow* NativeShellWindow::Create( | 710 NativeShellWindow* NativeShellWindow::Create( |
740 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 711 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
741 return new ShellWindowCocoa(shell_window, params); | 712 return new ShellWindowCocoa(shell_window, params); |
742 } | 713 } |
OLD | NEW |