summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm3
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm37
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc13
-rw-r--r--chrome/common/temp_scaffolding_stubs.h2
4 files changed, 40 insertions, 15 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index 420071a..e3bc4fe 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -30,6 +30,8 @@ void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
NSScreen* screen = [window_ screen];
cocoa_bounds.origin.y =
[screen frame].size.height - bounds.height() - bounds.y();
+
+ [window_ setFrame:cocoa_bounds display:YES];
}
// Callers assume that this doesn't immediately delete the Browser object.
@@ -203,4 +205,3 @@ void BrowserWindowCocoa::DestroyBrowser() {
// at this point the controller is dead (autoreleased), so
// make sure we don't try to reference it any more.
}
-
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index b749e17..bd71540 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -22,6 +22,22 @@
browser_ = browser;
DCHECK(browser_);
windowShim_ = new BrowserWindowCocoa(browser, self, [self window]);
+
+ // The window is now fully realized and |-windowDidLoad:| has been
+ // called. We shouldn't do much in wDL because |windowShim_| won't yet
+ // be initialized (as it's called in response to |[self window]| above).
+
+ // Get the most appropriate size for the window. The window shim will handle
+ // flipping the coordinates for us so we can use it to save some code.
+ gfx::Rect windowRect = browser_->GetSavedWindowBounds();
+ windowShim_->SetBounds(windowRect);
+
+ // Create a controller for the tab strip, giving it the model object for
+ // this window's Browser and the tab strip view. The controller will handle
+ // registering for the appropriate tab notifications from the back-end and
+ // managing the creation of new tabs.
+ tabStripController_ = [[TabStripController alloc]
+ initWithView:[self tabStripView] browser:browser_];
}
return self;
}
@@ -39,17 +55,6 @@
return windowShim_;
}
-- (void)windowDidLoad {
- [super windowDidLoad];
-
- // Create a controller for the tab strip, giving it the model object for
- // this window's Browser and the tab strip view. The controller will handle
- // registering for the appropriate tab notifications from the back-end and
- // managing the creation of new tabs.
- tabStripController_ = [[TabStripController alloc]
- initWithView:[self tabStripView] browser:browser_];
-}
-
- (void)destroyBrowser {
// We need the window to go away now.
[self autorelease];
@@ -212,8 +217,14 @@
TabContents* contents = browser_->tabstrip_model()->GetTabContentsAt(index);
// Set the window size. Need to do this before we detach the tab so it's
- // still in the window.
- NSRect windowRect = [[tabView window] frame];
+ // still in the window. We have to flip the coordinates as that's what
+ // is expected by the Browser code.
+ NSWindow* sourceWindow = [tabView window];
+ NSRect windowRect = [sourceWindow frame];
+ NSScreen* screen = [sourceWindow screen];
+ windowRect.origin.y =
+ [screen frame].size.height - windowRect.size.height -
+ windowRect.origin.y;
gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y,
windowRect.size.width, windowRect.size.height);
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 181d4b1..abd26d8 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -369,3 +369,16 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) {
}
} // namespace download_util
+
+void WindowSizer::GetBrowserWindowBounds(const std::wstring& app_name,
+ const gfx::Rect& specified_bounds,
+ gfx::Rect* window_bounds,
+ bool* maximized) {
+ // If we're given a bounds, use it (for things like tearing off tabs during
+ // drags). If not, make up something reasonable until the rest of the
+ // WindowSizer infrastructure is in place.
+ *window_bounds = specified_bounds;
+ if (specified_bounds.IsEmpty()) {
+ *window_bounds = gfx::Rect(0, 0, 1024, 768);
+ }
+}
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index c1a12e5..b662fa9 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -450,7 +450,7 @@ class WindowSizer {
static void GetBrowserWindowBounds(const std::wstring& app_name,
const gfx::Rect& specified_bounds,
gfx::Rect* window_bounds,
- bool* maximized) { NOTIMPLEMENTED(); }
+ bool* maximized);
};
//---------------------------------------------------------------------------