Chromium Code Reviews| Index: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm |
| diff --git a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm |
| index 4bf6254ae98e0f00f6756cdde5220ca1c84242a7..0097e41b9e362492ec52697025944501ddb15525 100644 |
| --- a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm |
| +++ b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm |
| @@ -13,6 +13,7 @@ |
| #include "content/public/browser/render_widget_host_view.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_view.h" |
| +#include "content/public/common/draggable_region.h" |
| #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| @interface NSWindow (NSPrivateApis) |
| @@ -139,18 +140,6 @@ ShellWindowCocoa::ShellWindowCocoa(Profile* profile, |
| NSView* view = web_contents()->GetView()->GetNativeView(); |
| [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| - if (!has_frame_) { |
| - // TODO(jeremya): this is a temporary hack to allow moving the window while |
| - // we still don't have proper draggable region support. |
| - NSView* controlRegion = [[ControlRegionView alloc] init]; |
| - [controlRegion setFrame:NSMakeRect(0, 0, NSWidth([view bounds]), |
| - NSHeight([view bounds]) - 20)]; |
| - [controlRegion setAutoresizingMask: |
| - NSViewWidthSizable | NSViewHeightSizable]; |
| - [view addSubview:controlRegion]; |
| - [controlRegion release]; |
| - } |
| - |
| InstallView(); |
| [[window_controller_ window] setDelegate:window_controller_]; |
| @@ -343,6 +332,44 @@ void ShellWindowCocoa::SetDraggableRegion(SkRegion* region) { |
| // TODO: implement |
| } |
| +void ShellWindowCocoa::UpdateDraggableRegions( |
| + const std::vector<content::DraggableRegion>& regions) { |
| + // Draggable region is not supported for non-frameless window. |
| + if (has_frame_) |
| + return; |
| + |
| + NSView* frameView = [[window() contentView] superview]; |
| + int frameHeight = NSHeight([frameView bounds]); |
| + |
| + // Remove all ControlRegionView that are added last time. |
| + // Note that we need to copy subviews because [frameView subviews] returns the |
| + // view's mutable internal array and we do not want to mutate the array while |
| + // enumerating it. |
| + NSArray* subviews = [[frameView subviews] copy]; |
| + for (NSView* subview in subviews) { |
| + if ([subview isKindOfClass:[ControlRegionView class]]) { |
| + [subview setHidden:YES]; |
| + [subview removeFromSuperview]; |
| + } |
| + } |
| + [subviews release]; |
| + |
| + // Create and add ControlRegionView for each region that needs to be excluded |
| + // from the dragging. |
| + for (std::vector<content::DraggableRegion>::const_iterator iter = |
| + regions.begin(); |
| + iter != regions.end(); ++iter) { |
| + const content::DraggableRegion& region = *iter; |
| + NSView* controlRegion = [[ControlRegionView alloc] init]; |
| + [controlRegion setFrame:NSMakeRect(region.bounds.x(), |
| + frameHeight - region.bounds.bottom(), |
| + region.bounds.width(), |
| + region.bounds.height())]; |
| + [frameView addSubview:controlRegion]; |
|
jeremya
2012/08/07 00:38:53
We should add the ControlRegionViews as children o
jianli
2012/08/08 21:26:31
Done.
|
| + [controlRegion release]; |
| + } |
| +} |
| + |
| void ShellWindowCocoa::FlashFrame(bool flash) { |
| if (flash) { |
| attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; |