summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 16:41:33 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 16:41:33 +0000
commit8a53ee044de003495430e48203c8606dbf9aa261 (patch)
treed6171016214fa15a4b586b008a5b75f0e0777a96 /chrome/browser
parent9c19aa146af6d80de43f00fd109a43bb8f018b24 (diff)
downloadchromium_src-8a53ee044de003495430e48203c8606dbf9aa261.zip
chromium_src-8a53ee044de003495430e48203c8606dbf9aa261.tar.gz
chromium_src-8a53ee044de003495430e48203c8606dbf9aa261.tar.bz2
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
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac.mm11
-rw-r--r--chrome/browser/browser.cc42
-rw-r--r--chrome/browser/browser.h40
-rw-r--r--chrome/browser/browser_list.cc10
-rw-r--r--chrome/browser/browser_window_cocoa.h64
-rw-r--r--chrome/browser/browser_window_cocoa.mm141
-rw-r--r--chrome/browser/browser_window_controller.h44
-rw-r--r--chrome/browser/browser_window_controller.mm75
-rw-r--r--chrome/browser/browser_window_factory.mm20
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h6
10 files changed, 427 insertions, 26 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index cf0c49f..16073d8 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -5,13 +5,14 @@
#import "app_controller_mac.h"
#import "base/message_loop.h"
+#import "chrome/browser/browser_list.h"
@implementation AppController
// We can't use the standard terminate: method because it will abrubptly exit
// the app and leave things on the stack in an unfinalized state. We need to
// post a quit message to our run loop so the stack can gracefully unwind.
-- (IBAction)quit:(id)sender {
+- (IBAction)quit:(id)sender {
// TODO(pinkerton):
// since we have to roll it ourselves, ask the delegate (ourselves, really)
// if we should terminate. For example, we might not want to if the user
@@ -19,6 +20,14 @@
// require posting UI and may require spinning up another run loop to
// handle it. If it says to continue, post the quit message, otherwise
// go back to normal.
+
+ // Close all the windows.
+ // TODO(pinkerton): the close code assumes that teardown happens
+ // synchronously, however with autorelease pools and ref-counting, we can't
+ // guarantee the window controller hits 0 inside this call, and thus the
+ // number of Browsers still alive will certainly be non-zero. Not sure yet
+ // how to handle this case.
+ // BrowserList::CloseAllBrowsers(false);
MessageLoopForUI::current()->Quit();
}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 3e12603..ddceec2 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2,19 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
+#include "base/idle_timer.h"
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+#include "net/base/cookie_monster.h"
+#include "net/base/cookie_policy.h"
+#include "net/base/net_util.h"
+#include "net/base/registry_controlled_domain.h"
+#include "net/url_request/url_request_context.h"
+
+#if defined(OS_WIN)
+
#include <windows.h>
#include <shellapi.h>
#include "chrome/browser/browser.h"
-#include "base/command_line.h"
-#include "base/idle_timer.h"
-#include "base/logging.h"
-#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/app/locales/locale_settings.h"
#include "chrome/browser/automation/ui_controls.h"
-#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_url_handler.h"
@@ -53,20 +63,14 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/pref_service.h"
#include "chrome/common/win_util.h"
-#include "net/base/cookie_monster.h"
-#include "net/base/cookie_policy.h"
-#include "net/base/net_util.h"
-#include "net/base/registry_controlled_domain.h"
#include "chromium_strings.h"
#include "generated_resources.h"
-using base::TimeDelta;
+#endif // OS_WIN
-static BrowserList g_browserlist;
+using base::TimeDelta;
// How long we wait before updating the browser chrome while loading a page.
static const int kUIUpdateCoalescingTimeMS = 200;
@@ -84,12 +88,14 @@ static const int kWindowTilePixels = 20;
class ReducePluginsWorkingSetTask : public Task {
public:
virtual void Run() {
+#if defined(OS_WIN)
for (PluginProcessHostIterator iter; !iter.Done(); ++iter) {
PluginProcessHost* plugin = const_cast<PluginProcessHost*>(*iter);
DCHECK(plugin->process());
base::Process process(plugin->process());
process.ReduceWorkingSet();
}
+#endif
}
};
@@ -104,6 +110,7 @@ class BrowserIdleTimer : public base::IdleTimer {
}
virtual void OnIdle() {
+#if defined(OS_WIN)
// We're idle. Release browser and renderer unused pages.
// Handle the Browser.
@@ -123,6 +130,7 @@ class BrowserIdleTimer : public base::IdleTimer {
// collection.
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
new ReducePluginsWorkingSetTask());
+#endif
}
};
@@ -164,8 +172,12 @@ Browser::Browser(Type type, Profile* profile)
InitCommandState();
BrowserList::AddBrowser(this);
+#if defined(OS_WIN)
+ // TODO(port): turn this back on when prefs are fleshed out. This asserts
+ // because the pref hasn't yet been registered.
encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
profile_->GetPrefs(), NULL);
+#endif
// Trim browser memory on idle for low & medium memory models.
if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL)
@@ -266,6 +278,8 @@ void Browser::OpenEmptyWindow(Profile* profile) {
browser->window()->Show();
}
+#if defined(OS_WIN)
+
// static
void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
Profile* off_the_record_profile = profile->GetOffTheRecordProfile();
@@ -2404,3 +2418,5 @@ void Browser::RegisterAppPrefs(const std::wstring& app_name) {
prefs->RegisterDictionaryPref(window_pref.c_str());
}
+
+#endif // OS_WIN
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 1faa8ab..3157e5a 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -5,19 +5,31 @@
#ifndef CHROME_BROWSER_BROWSER_H_
#define CHROME_BROWSER_BROWSER_H_
+#include "base/basictypes.h"
+
#include <vector>
+#if defined(OS_MACOSX) || defined(OS_LINUX)
+// Remove when we've finished porting the supporting classes.
+#include "chrome/common/temp_scaffolding_stubs.h"
+#endif
+
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/command_updater.h"
-#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/sessions/session_id.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_member.h"
+#include "base/gfx/rect.h"
+#include "skia/include/SkBitmap.h"
+
+#if defined(OS_WIN)
+#include "chrome/browser/command_updater.h"
+#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/toolbar_model.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/pref_member.h"
+#endif
class BrowserIdleTimer;
class BrowserWindow;
@@ -105,14 +117,15 @@ class Browser : public TabStripModelDelegate,
// Opens a new window with the default blank tab.
static void OpenEmptyWindow(Profile* profile);
+#if defined(OS_WIN)
+ // Opens the a new application window for the specified WebApp.
+ static void OpenWebApplication(Profile* profile, WebApp* app);
+
// Opens the specified URL in a new browser window in an incognito session.
// If there is already an existing active incognito session for the specified
// |profile|, that session is re-used.
static void OpenURLOffTheRecord(Profile* profile, const GURL& url);
- // Opens the a new application window for the specified WebApp.
- static void OpenWebApplication(Profile* profile, WebApp* app);
-
// State Storage and Retrieval for UI ///////////////////////////////////////
// Save and restore the window position.
@@ -139,6 +152,7 @@ class Browser : public TabStripModelDelegate,
// Invoked when the window containing us is closing. Performs the necessary
// cleanup.
void OnWindowClosing();
+#endif // OS_WIN
// TabStripModel pass-thrus /////////////////////////////////////////////////
@@ -168,6 +182,7 @@ class Browser : public TabStripModelDelegate,
}
// Tab adding/showing functions /////////////////////////////////////////////
+#if defined(OS_WIN)
// Add a new tab with the specified URL. If instance is not null, its process
// will be used to render the tab.
@@ -364,7 +379,7 @@ class Browser : public TabStripModelDelegate,
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating);
virtual void URLStarredChanged(TabContents* source, bool starred);
- virtual void ContentsMouseEvent(TabContents* source, UINT message);
+ virtual void ContentsMouseEvent(TabContents* source, uint32 message);
virtual void UpdateTargetURL(TabContents* source, const GURL& url);
virtual void ContentsZoomChange(bool zoom_in);
@@ -381,6 +396,8 @@ class Browser : public TabStripModelDelegate,
// Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const std::wstring& path, void* params);
+#endif // OS_WIN
+
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
@@ -392,6 +409,7 @@ class Browser : public TabStripModelDelegate,
// Initialize state for all browser commands.
void InitCommandState();
+#if defined(OS_WIN)
// Update commands which may be enabled or disabled depending on the tab's
// state.
void UpdateCommandsForTabState();
@@ -432,7 +450,9 @@ class Browser : public TabStripModelDelegate,
friend class AutomationProvider;
// Getters for the location bar and go button.
+#endif // OS_WIN
LocationBarView* GetLocationBarView() const;
+#if defined(OS_WIN)
GoButton* GetGoButton();
// Returns the StatusBubble from the current toolbar. It is possible for
@@ -454,9 +474,11 @@ class Browser : public TabStripModelDelegate,
int selected_navigation);
// OnBeforeUnload handling //////////////////////////////////////////////////
+#endif
typedef std::set<TabContents*> UnloadListenerSet;
+#if defined(OS_WIN)
// Processes the next tab that needs it's beforeunload/unload event fired.
void ProcessPendingTabs();
@@ -512,6 +534,8 @@ class Browser : public TabStripModelDelegate,
// done only once per application name / per session.
static void RegisterAppPrefs(const std::wstring& app_name);
+#endif // OS_WIN
+
// Data members /////////////////////////////////////////////////////////////
// This Browser's type.
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 90ccb56..739dadb 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
#include "chrome/browser/browser_list.h"
#include "base/logging.h"
@@ -10,10 +12,14 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
+#if defined(OS_WIN)
+// TODO(port): these can probably all go away, even on win
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/notification_service.h"
+#endif
+
BrowserList::list_type BrowserList::browsers_;
std::vector<BrowserList::Observer*> BrowserList::observers_;
@@ -143,9 +149,13 @@ void BrowserList::WindowsSessionEnding() {
// And shutdown.
browser_shutdown::Shutdown();
+#if defined(OS_WIN)
// At this point the message loop is still running yet we've shut everything
// down. If any messages are processed we'll likely crash. Exit now.
ExitProcess(ResultCodes::NORMAL_EXIT);
+#else
+ NOTIMPLEMENTED();
+#endif
}
// static
diff --git a/chrome/browser/browser_window_cocoa.h b/chrome/browser/browser_window_cocoa.h
new file mode 100644
index 0000000..74847bd
--- /dev/null
+++ b/chrome/browser/browser_window_cocoa.h
@@ -0,0 +1,64 @@
+// 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.
+
+#ifndef CHROME_BROWSER_WINDOW_COCOA_H_
+#define CHROME_BROWSER_WINDOW_COCOA_H_
+
+#include "chrome/browser/browser_window.h"
+
+@class BrowserWindowController;
+@class NSWindow;
+
+// An implementation of BrowserWindow for Cocoa. Bridges between C++ and
+// the Cocoa NSWindow. Cross-platform code will interact with this object when
+// it needs to manipulate the window.
+
+class BrowserWindowCocoa : public BrowserWindow {
+ public:
+ BrowserWindowCocoa(BrowserWindowController* controller, NSWindow* window);
+ virtual ~BrowserWindowCocoa();
+
+ // Overridden from BrowserWindow
+ virtual void Init();
+ virtual void Show();
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void Close();
+ virtual void Activate();
+ virtual void FlashFrame();
+ virtual void* GetNativeHandle();
+ virtual TabStrip* GetTabStrip() const;
+ virtual StatusBubble* GetStatusBubble();
+ virtual void SelectedTabToolbarSizeChanged(bool is_animating);
+ virtual void UpdateTitleBar();
+ virtual void UpdateLoadingAnimations(bool should_animate);
+ virtual gfx::Rect GetNormalBounds() const;
+ virtual bool IsMaximized();
+ virtual ToolbarStarToggle* GetStarButton() const;
+ virtual LocationBarView* GetLocationBarView() const;
+ virtual GoButton* GetGoButton() const;
+ virtual BookmarkBarView* GetBookmarkBarView();
+ virtual void UpdateToolbar(TabContents* contents,
+ bool should_restore_state);
+ virtual void FocusToolbar();
+ virtual bool IsBookmarkBarVisible() const;
+ virtual void ToggleBookmarkBar();
+ virtual void ShowAboutChromeDialog();
+ virtual void ShowBookmarkManager();
+ virtual void ShowReportBugDialog();
+ virtual void ShowClearBrowsingDataDialog();
+ virtual void ShowImportDialog();
+ virtual void ShowSearchEnginesDialog();
+ virtual void ShowPasswordManager();
+ virtual void ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
+ void* parent_window);
+
+ protected:
+ virtual void DestroyBrowser();
+
+ private:
+ BrowserWindowController* controller_; // weak, owns us
+ NSWindow* window_; // weak, owned by |controller_|
+};
+
+#endif // CHROME_BROWSER_WINDOW_COCOA_H_
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.
+}
diff --git a/chrome/browser/browser_window_controller.h b/chrome/browser/browser_window_controller.h
new file mode 100644
index 0000000..7ae2bd0
--- /dev/null
+++ b/chrome/browser/browser_window_controller.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef CHROME_BROWSER_BROWSER_WINDOW_CONTROLLER_H_
+#define CHROME_BROWSER_BROWSER_WINDOW_CONTROLLER_H_
+
+// A class acting as the Objective-C controller for the Browser object. Handles
+// interactions between Cocoa and the cross-platform code.
+
+#import <Cocoa/Cocoa.h>
+
+class Browser;
+class BrowserWindow;
+
+@interface BrowserWindowController : NSWindowController {
+ @private
+ Browser* browser_; // strong
+ BrowserWindow* window_shim_; // strong
+
+ // Some toolbar items for IB. We can remove these if we stop using IB for
+ // NSToolbar support (it only half works).
+ IBOutlet NSToolbarItem* back_button_;
+ IBOutlet NSToolbarItem* forward_button_;
+ IBOutlet NSToolbarItem* url_bar_;
+
+ // This will become its own view at some point.
+ IBOutlet NSView* tab_bar_view_;
+}
+
+// Load the browser window nib and do any Cocoa-specific initialization.
+// Takes ownership of |browser|.
+- (id)initWithBrowser:(Browser*)browser;
+
+// call to make the browser go away from other places in the cross-platform
+// code.
+- (void)destroyBrowser;
+
+// Access the C++ bridge between the NSWindow and the rest of Chromium
+- (BrowserWindow*)browserWindow;
+
+@end
+
+#endif // CHROME_BROWSER_BROWSER_WINDOW_CONTROLLER_H_
diff --git a/chrome/browser/browser_window_controller.mm b/chrome/browser/browser_window_controller.mm
new file mode 100644
index 0000000..c5e4abc
--- /dev/null
+++ b/chrome/browser/browser_window_controller.mm
@@ -0,0 +1,75 @@
+// 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.
+
+#import "chrome/browser/browser.h"
+#import "chrome/browser/browser_window_cocoa.h"
+#import "chrome/browser/browser_window_controller.h"
+
+@implementation BrowserWindowController
+
+// Load the browser window nib and do any Cocoa-specific initialization.
+// Takes ownership of |browser|. Note that the nib also sets this controller
+// up as the window's delegate.
+- (id)initWithBrowser:(Browser*)browser {
+ if ((self = [super initWithWindowNibName:@"BrowserWindow"])) {
+ browser_ = browser;
+ window_shim_ = new BrowserWindowCocoa(self, [self window]);
+ }
+ return self;
+}
+
+- (void)dealloc {
+ browser_->CloseAllTabs();
+ delete browser_;
+ delete window_shim_;
+ [super dealloc];
+}
+
+// Access the C++ bridge between the NSWindow and the rest of Chromium
+- (BrowserWindow*)browserWindow {
+ return window_shim_;
+}
+
+- (void)windowDidLoad {
+ [(NSControl*)[url_bar_ view]
+ setStringValue:@"http://the.interwebs.start.here"];
+}
+
+- (void)destroyBrowser {
+ // we need the window to go away now, other areas of code will be checking
+ // the number of browser objects remaining after we finish so we can't defer
+ // deletion via autorelease.
+ [self autorelease];
+}
+
+// Called when the window is closing from Cocoa. Destroy this controller,
+// which will tear down the rest of the infrastructure as the Browser is
+// itself destroyed.
+- (void)windowWillClose:(NSNotification *)notification {
+ [self autorelease];
+}
+
+// Called when the user wants to close a window. Usually it's ok, but we may
+// want to prompt the user when they have multiple tabs open, for example.
+- (BOOL)windowShouldClose:(id)sender {
+ // TODO(pinkerton): check tab model to see if it's ok to close the
+ // window. Use NSGetAlertPanel() and runModalForWindow:.
+ return YES;
+}
+
+// NSToolbar delegate methods
+
+- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
+ return [NSArray arrayWithObjects:[back_button_ itemIdentifier],
+ [forward_button_ itemIdentifier],
+ [url_bar_ itemIdentifier], nil];
+}
+
+- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
+ return [NSArray arrayWithObjects:[back_button_ itemIdentifier],
+ [forward_button_ itemIdentifier],
+ [url_bar_ itemIdentifier], nil];
+}
+
+@end
diff --git a/chrome/browser/browser_window_factory.mm b/chrome/browser/browser_window_factory.mm
new file mode 100644
index 0000000..ea813be
--- /dev/null
+++ b/chrome/browser/browser_window_factory.mm
@@ -0,0 +1,20 @@
+// 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 "chrome/browser/browser_window.h"
+#include "chrome/browser/browser_window_controller.h"
+
+// Create the controller for the Browser, which handles loading the browser
+// window from the nib. The controller takes ownership of |browser|.
+// static
+BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
+ // TODO(pinkerton): figure out ownership model. If BrowserList keeps track
+ // of the browser windows, it will probably tell us when it needs to go
+ // away, and it seems we need to feed back to that when we get a
+ // performClose: from the UI.
+ BrowserWindowController* controller =
+ [[BrowserWindowController alloc] initWithBrowser:browser];
+ return [controller browserWindow];
+}
+
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index 10ea799..599b64c 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -5,9 +5,7 @@
#ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_
#define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_
-// TODO(maruel): Remove once UINT and HWND are replaced / typedef.
-#include <windows.h>
-
+#include "base/basictypes.h"
#include "chrome/browser/tab_contents/page_navigator.h"
#include "chrome/common/navigation_types.h"
@@ -95,7 +93,7 @@ class TabContentsDelegate : public PageNavigator {
virtual void UpdateTargetURL(TabContents* source, const GURL& url) = 0;
// Notification that the target URL has changed
- virtual void ContentsMouseEvent(TabContents* source, UINT message) { }
+ virtual void ContentsMouseEvent(TabContents* source, uint32 message) { }
// Request the delegate to change the zoom level of the current tab.
virtual void ContentsZoomChange(bool zoom_in) { }