diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 18:05:11 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 18:05:11 +0000 |
commit | f0d550860b6b9402df5dd5855b885e2e3a9be1d2 (patch) | |
tree | f68d73624488d11635925aa98bbcc16c3ade0e5b /chrome | |
parent | c83203d27e7f79bc395d1702b1a7fcaecc65c23c (diff) | |
download | chromium_src-f0d550860b6b9402df5dd5855b885e2e3a9be1d2.zip chromium_src-f0d550860b6b9402df5dd5855b885e2e3a9be1d2.tar.gz chromium_src-f0d550860b6b9402df5dd5855b885e2e3a9be1d2.tar.bz2 |
Implement UpdateToolbar from BrowserWindow on Mac without dragging in too much of the Omnibar code.
Review URL: http://codereview.chromium.org/20306
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_window_cocoa.mm | 3 | ||||
-rw-r--r-- | chrome/browser/browser_window_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/browser_window_controller.mm | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 16 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 9 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 13 |
7 files changed, 57 insertions, 1 deletions
diff --git a/chrome/browser/browser_window_cocoa.mm b/chrome/browser/browser_window_cocoa.mm index 7f313729..3c03c3d 100644 --- a/chrome/browser/browser_window_cocoa.mm +++ b/chrome/browser/browser_window_cocoa.mm @@ -101,7 +101,8 @@ void BrowserWindowCocoa::UpdateStopGoState(bool is_loading) { void BrowserWindowCocoa::UpdateToolbar(TabContents* contents, bool should_restore_state) { - NOTIMPLEMENTED(); + [controller_ updateToolbarWithContents:contents + shouldRestoreState:should_restore_state ? YES : NO]; } void BrowserWindowCocoa::FocusToolbar() { diff --git a/chrome/browser/browser_window_controller.h b/chrome/browser/browser_window_controller.h index 290b1b4..455c45f 100644 --- a/chrome/browser/browser_window_controller.h +++ b/chrome/browser/browser_window_controller.h @@ -45,6 +45,13 @@ class BrowserWindow; // Get the C++ bridge object representing the location bar for the current tab. - (LocationBar*)locationBar; +// Updates the toolbar (and transitively the location bar) with the states of +// the specified |tab|. If |shouldRestore| is true, we're switching +// (back?) to this tab and should restore any previous location bar state +// (such as user editing) as well. +- (void)updateToolbarWithContents:(TabContents*)tab + shouldRestoreState:(BOOL)shouldRestore; + @end #endif // CHROME_BROWSER_BROWSER_WINDOW_CONTROLLER_H_ diff --git a/chrome/browser/browser_window_controller.mm b/chrome/browser/browser_window_controller.mm index e5b2d2c..c1feeac 100644 --- a/chrome/browser/browser_window_controller.mm +++ b/chrome/browser/browser_window_controller.mm @@ -111,4 +111,10 @@ return [tabStripController_ locationBar]; } +- (void)updateToolbarWithContents:(TabContents*)tab + shouldRestoreState:(BOOL)shouldRestore { + [tabStripController_ updateToolbarWithContents:tab + shouldRestoreState:shouldRestore]; +} + @end diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index 14e52ca..41a7569 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -56,6 +56,10 @@ class TabStripModel; // enabled. - (void)willBecomeSelectedTab; +// Called when any url bar state changes. If |tabForRestoring| is non-NULL, +// it points to a TabContents whose state we should restore. +- (void)updateToolbarWithContents:(TabContents*)tabForRestoring; + @end #endif // CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index 31948ec..4a517e8 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -168,6 +168,22 @@ class LocationBarBridge : public LocationBar { [[locationBar_ window] makeFirstResponder:locationBar_]; } +- (void)updateToolbarWithContents:(TabContents*)tab { + // TODO(pinkerton): there's a lot of ui code in autocomplete_edit.cc + // that we'll want to duplicate. For now, just handle setting the text. + + // TODO(pinkerton): update the security lock icon and background color + + if (tab) { + NSString* urlString = + [NSString stringWithUTF8String:tab->GetURL().spec().c_str()]; + [locationBar_ setStringValue:urlString]; + } else { + // TODO(pinkerton): just reset the state of the url bar. We're currently + // not saving any state as that drags in too much Omnibar code. + } +} + @end //-------------------------------------------------------------------------- diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index 6c181f2..1564983 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -12,6 +12,7 @@ class LocationBar; @class TabStripView; class TabStripBridge; class TabStripModel; +class TabContents; // A class that handles managing the tab strip in a browser window. It uses // a supporting C++ bridge object to register for notifications from the @@ -25,6 +26,7 @@ class TabStripModel; @interface TabStripController : NSObject { @private + TabContents* currentTab_; // weak, tab for which we're showing state TabStripView* tabView_; // weak NSButton* newTabButton_; TabStripBridge* bridge_; @@ -45,6 +47,13 @@ class TabStripModel; // Get the C++ bridge object representing the location bar for the current tab. - (LocationBar*)locationBar; +// Updates the toolbar (and transitively the location bar) with the states of +// the specified |tab|. If |shouldRestore| is true, we're switching +// (back?) to this tab and should restore any previous location bar state +// (such as user editing) as well. +- (void)updateToolbarWithContents:(TabContents*)tab + shouldRestoreState:(BOOL)shouldRestore; + @end #endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index e1b167b..9488695 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -287,6 +287,19 @@ class TabStripBridge : public TabStripModelObserver { return [selectedController locationBar]; } +- (void)updateToolbarWithContents:(TabContents*)tab + shouldRestoreState:(BOOL)shouldRestore { + // TODO(pinkerton): windows maintains this, we probably should though we + // currently aren't using it. + currentTab_ = tab; + + // tell the appropriate controller to update its state. |shouldRestore| being + // YES means we're going back to this tab and should put back any state + // associated with it. + TabContentsController* controller = [self controllerWithContents:tab]; + [controller updateToolbarWithContents:shouldRestore ? tab : nil]; +} + @end //-------------------------------------------------------------------------- |