Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm

Issue 10834016: Alternative: access the WebContentsView directly without an interface method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 479114c31a81bbb470f150af05ffa3fdd2f05708..e32d6a84901f728930009afb017d97d09aa291a4 100644
--- a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
@@ -72,6 +72,21 @@
@end
+@interface ControlRegionView : NSView
+@end
+@implementation ControlRegionView
+- (BOOL)mouseDownCanMoveWindow {
+ return NO;
+}
+- (NSView*)hitTest:(NSPoint)aPoint {
+ return nil;
+}
+@end
+
+@interface NSView (WebContentsView)
+- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
+@end
+
ShellWindowCocoa::ShellWindowCocoa(Profile* profile,
const extensions::Extension* extension,
const GURL& url,
@@ -108,9 +123,33 @@ ShellWindowCocoa::ShellWindowCocoa(Profile* profile,
[window setBottomCornerRounded:NO];
NSView* view = web_contents()->GetView()->GetNativeView();
- [view setFrame:[[window contentView] bounds]];
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [[window contentView] addSubview:view];
+ if (params.frame == ShellWindow::CreateParams::FRAME_CHROME) {
+ [view setFrame:[[window contentView] bounds]];
+ [[window contentView] addSubview:view];
+ } else {
+ NSView* web_contents_view =
+ web_contents()->GetView()->GetNativeView();
+ DCHECK([web_contents_view
+ respondsToSelector:@selector(setMouseDownCanMoveWindow:)]);
+ [web_contents_view setMouseDownCanMoveWindow:YES];
+ NSView* frameView = [[window contentView] superview];
+ [view setFrame:[frameView bounds]];
+ [frameView addSubview:view];
+ [[window standardWindowButton:NSWindowZoomButton] setHidden:YES];
+ [[window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
+ [[window standardWindowButton:NSWindowCloseButton] setHidden:YES];
+
+ // 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([frameView bounds]),
+ NSHeight([frameView bounds]) - 20)];
+ [controlRegion setAutoresizingMask:
+ NSViewWidthSizable | NSViewHeightSizable];
+ [frameView addSubview:controlRegion];
+ [controlRegion release];
+ }
window_controller_.reset(
[[ShellWindowController alloc] initWithWindow:window.release()]);
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698