From 8a53ee044de003495430e48203c8606dbf9aa261 Mon Sep 17 00:00:00 2001 From: "pinkerton@google.com" Date: Wed, 21 Jan 2009 16:41:33 +0000 Subject: Get browser window showing using a Browser object and accompanying scaffolding. Adds browser window controller and shim from NSWindow to BrowserWindow. Review URL: http://codereview.chromium.org/18368 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8364 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_window_cocoa.mm | 141 +++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 chrome/browser/browser_window_cocoa.mm (limited to 'chrome/browser/browser_window_cocoa.mm') diff --git a/chrome/browser/browser_window_cocoa.mm b/chrome/browser/browser_window_cocoa.mm new file mode 100644 index 0000000..d3061d9 --- /dev/null +++ b/chrome/browser/browser_window_cocoa.mm @@ -0,0 +1,141 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/gfx/rect.h" +#include "chrome/browser/browser_window_cocoa.h" +#include "chrome/browser/browser_window_controller.h" + +BrowserWindowCocoa::BrowserWindowCocoa(BrowserWindowController* controller, + NSWindow* window) + : controller_(controller), window_(window) { +} + +BrowserWindowCocoa::~BrowserWindowCocoa() { +} + +void BrowserWindowCocoa::Init() { +} + +void BrowserWindowCocoa::Show() { + [window_ makeKeyAndOrderFront:controller_]; +} + +void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { + NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, bounds.width(), + bounds.height()); + // flip coordinates + NSScreen* screen = [window_ screen]; + cocoa_bounds.origin.y = + [screen frame].size.height - bounds.height() - bounds.y(); +} + +void BrowserWindowCocoa::Close() { + [window_ orderOut:controller_]; +} + +void BrowserWindowCocoa::Activate() { + [window_ makeKeyAndOrderFront:controller_]; +} + +void BrowserWindowCocoa::FlashFrame() { + [[NSApplication sharedApplication] + requestUserAttention:NSInformationalRequest]; +} + +void* BrowserWindowCocoa::GetNativeHandle() { + return [controller_ window]; +} + +TabStrip* BrowserWindowCocoa::GetTabStrip() const { + return NULL; +} + +StatusBubble* BrowserWindowCocoa::GetStatusBubble() { + return NULL; +} + +void BrowserWindowCocoa::SelectedTabToolbarSizeChanged(bool is_animating) { +} + +void BrowserWindowCocoa::UpdateTitleBar() { +} + +void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { +} + +gfx::Rect BrowserWindowCocoa::GetNormalBounds() const { + // TODO(pinkerton): not sure if we can get the non-zoomed bounds, or if it + // really matters. We may want to let Cocoa handle all this for us. + NSRect frame = [window_ frame]; + NSScreen* screen = [window_ screen]; + gfx::Rect bounds(frame.origin.x, 0, frame.size.width, frame.size.height); + bounds.set_y([screen frame].size.height + frame.size.height + frame.origin.y); + return bounds; +} + +bool BrowserWindowCocoa::IsMaximized() { + return [window_ isZoomed]; +} + +ToolbarStarToggle* BrowserWindowCocoa::GetStarButton() const { + return NULL; +} + +LocationBarView* BrowserWindowCocoa::GetLocationBarView() const { + return NULL; +} + +GoButton* BrowserWindowCocoa::GetGoButton() const { + return NULL; +} + +BookmarkBarView* BrowserWindowCocoa::GetBookmarkBarView() { + return NULL; +} + +void BrowserWindowCocoa::UpdateToolbar(TabContents* contents, + bool should_restore_state) { +} + +void BrowserWindowCocoa::FocusToolbar() { +} + +bool BrowserWindowCocoa::IsBookmarkBarVisible() const { + return true; +} + +void BrowserWindowCocoa::ToggleBookmarkBar() { +} + +void BrowserWindowCocoa::ShowAboutChromeDialog() { +} + +void BrowserWindowCocoa::ShowBookmarkManager() { +} + +void BrowserWindowCocoa::ShowReportBugDialog() { +} + +void BrowserWindowCocoa::ShowClearBrowsingDataDialog() { +} + +void BrowserWindowCocoa::ShowImportDialog() { +} + +void BrowserWindowCocoa::ShowSearchEnginesDialog() { +} + +void BrowserWindowCocoa::ShowPasswordManager() { +} + +void BrowserWindowCocoa::ShowHTMLDialog(HtmlDialogContentsDelegate* delegate, + void* parent_window) { +} + +void BrowserWindowCocoa::DestroyBrowser() { + [controller_ destroyBrowser]; + + // at this point the controller is dead (autoreleased), so + // make sure we don't try to reference it any more. +} -- cgit v1.1