summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm12
-rw-r--r--chrome/browser/cocoa/browser_window_controller_unittest.mm18
-rw-r--r--chrome/browser/cocoa/tab_window_controller.h6
-rw-r--r--chrome/browser/cocoa/tab_window_controller.mm24
4 files changed, 54 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 6e7b629..5eff438 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -422,6 +422,11 @@ willPositionSheet:(NSWindow *)sheet
return NO;
}
+ // Can't drag a tab from a normal browser to a pop-up
+ if (browser_->type() != realSource->browser_->type()) {
+ return NO;
+ }
+
return YES;
}
@@ -684,6 +689,13 @@ willPositionSheet:(NSWindow *)sheet
return base::SysUTF16ToNSString(contents->GetTitle());
}
+// TYPE_POPUP is not normal (e.g. no tab strip)
+- (BOOL)isNormalWindow {
+ if (browser_->type() == Browser::TYPE_NORMAL)
+ return YES;
+ return NO;
+}
+
- (void)selectTabWithContents:(TabContents*)newContents
previousContents:(TabContents*)oldContents
atIndex:(NSInteger)index
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm
index d640922..25a5e43 100644
--- a/chrome/browser/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm
@@ -77,4 +77,22 @@ TEST_F(BrowserWindowControllerTest, TestFullscreen) {
EXPECT_TRUE([controller_ fullscreenWindow]);
}
+TEST_F(BrowserWindowControllerTest, TestNormal) {
+ // Make sure a normal BrowserWindowController is, uh, normal.
+ EXPECT_TRUE([controller_ isNormalWindow]);
+
+ // And make sure a controller for a pop-up window is not normal.
+ scoped_ptr<Browser> popup_browser(Browser::CreateForPopup(
+ browser_helper_.profile()));
+ controller_.reset([[BrowserWindowController alloc]
+ initWithBrowser:popup_browser.get()
+ takeOwnership:NO]);
+ EXPECT_FALSE([controller_ isNormalWindow]);
+
+ // The created BrowserWindowController gets autoreleased, so make
+ // sure we don't also release it.
+ // (Confirmed with valgrind).
+ controller_.release();
+}
+
/* TODO(???): test other methods of BrowserWindowController */
diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h
index 4f97173..256732d 100644
--- a/chrome/browser/cocoa/tab_window_controller.h
+++ b/chrome/browser/cocoa/tab_window_controller.h
@@ -86,6 +86,12 @@
// The title of the selected tab.
- (NSString*)selectedTabTitle;
+// Called to check if we are a normal window (e.g. not a pop-up) and
+// want normal behavior (e.g. a tab strip). Return YES if so. The
+// default implementation returns YES.
+- (BOOL)isNormalWindow;
+
+
@end
@interface TabWindowController(ProtectedMethods)
diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm
index 12fc4a5..41d0b78 100644
--- a/chrome/browser/cocoa/tab_window_controller.mm
+++ b/chrome/browser/cocoa/tab_window_controller.mm
@@ -16,12 +16,18 @@
@synthesize tabContentArea = tabContentArea_;
- (void)windowDidLoad {
- // Place the tab bar above the content box and add it to the view hierarchy
- // as a sibling of the content view so it can overlap with the window frame.
- NSRect tabFrame = [tabContentArea_ frame];
- tabFrame.origin = NSMakePoint(0, NSMaxY(tabFrame));
- tabFrame.size.height = NSHeight([tabStripView_ frame]);
- [tabStripView_ setFrame:tabFrame];
+ // TODO(jrg): a non-normal window (e.g. for pop-ups) needs more work
+ // than just removal of the tab strip offset. But this is enough to
+ // avoid confusion (e.g. "new tab" on popup gets created in a
+ // different window).
+ if ([self isNormalWindow]) {
+ // Place the tab bar above the content box and add it to the view hierarchy
+ // as a sibling of the content view so it can overlap with the window frame.
+ NSRect tabFrame = [tabContentArea_ frame];
+ tabFrame.origin = NSMakePoint(0, NSMaxY(tabFrame));
+ tabFrame.size.height = NSHeight([tabStripView_ frame]);
+ [tabStripView_ setFrame:tabFrame];
+ }
[[[[self window] contentView] superview] addSubview:tabStripView_];
}
@@ -156,4 +162,10 @@
return @"";
}
+- (BOOL)isNormalWindow {
+ // subclass must implement
+ NOTIMPLEMENTED();
+ return YES;
+}
+
@end