summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 20:32:54 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 20:32:54 +0000
commitc33ab08d62663fff70526b1a3d5b2a57c487ac06 (patch)
treeeef8c1f53ea6d8e906e910ff03ef13bb56ebeb91 /chrome/browser/cocoa
parentdbd43729289b80832900af7338fa3d351d81499d (diff)
downloadchromium_src-c33ab08d62663fff70526b1a3d5b2a57c487ac06.zip
chromium_src-c33ab08d62663fff70526b1a3d5b2a57c487ac06.tar.gz
chromium_src-c33ab08d62663fff70526b1a3d5b2a57c487ac06.tar.bz2
Pop-up chrome.
BUG=http://crbug.com/15727 TEST=Load a web page that has a popup. Example: <!DOCTYPE html> Click button to open a new window. <br> <button onclick="w = window.open('http://www.google.com', 'New Window', 'width=512,height=512'); w.moveTo(300,300);">Open with w,h</button> Now click on the button to get a pop-up. In the new window, make sure there is no "tab" area above the URL bar, and no "new tab" button. Hit Cmd-T to create a new tab, and make sure it gets created in the OTHER window. More work is needed to minimize pop-up chrome more, but this'll prevent the most brutal failures (e.g. team meeting "demo" today). Review URL: http://codereview.chromium.org/151135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-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