diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 22:00:45 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 22:00:45 +0000 |
commit | e191c147e4704d4e75f548cdaf90f914d196aa63 (patch) | |
tree | 566187bf422d3cf5ed8a66a4d7cb6fd05596e02e /chrome | |
parent | 60f7ba59cf2b26b9c8d19abfae3ca9fb6cc36cc1 (diff) | |
download | chromium_src-e191c147e4704d4e75f548cdaf90f914d196aa63.zip chromium_src-e191c147e4704d4e75f548cdaf90f914d196aa63.tar.gz chromium_src-e191c147e4704d4e75f548cdaf90f914d196aa63.tar.bz2 |
Change url bar text according to the model when updating the toolbar. Fix vtable issue in ToolbarModel by using correct declaration.
Review URL: http://codereview.chromium.org/27163
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/nibs/English.lproj/TabContents.xib | 23 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 28 | ||||
-rw-r--r-- | chrome/browser/toolbar_model.cc | 8 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 1 |
8 files changed, 48 insertions, 44 deletions
diff --git a/chrome/app/nibs/English.lproj/TabContents.xib b/chrome/app/nibs/English.lproj/TabContents.xib index 0f493fa..3d6bf8a 100644 --- a/chrome/app/nibs/English.lproj/TabContents.xib +++ b/chrome/app/nibs/English.lproj/TabContents.xib @@ -2,12 +2,13 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9G55</string> + <string key="IBDocument.SystemVersion">9F33</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.43</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> + <string key="IBDocument.AppKitVersion">949.34</string> + <string key="IBDocument.HIToolboxVersion">352.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="94"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -64,12 +65,10 @@ <int key="NSvFlags">256</int> <string key="NSFrameSize">{480, 322}</string> <reference key="NSSuperview" ref="753762894"/> - <reference key="NSWindow"/> </object> </object> <string key="NSFrameSize">{480, 322}</string> <reference key="NSSuperview" ref="675542922"/> - <reference key="NSWindow"/> <string key="NSOffsets">{0, 0}</string> <object class="NSTextFieldCell" key="NSTitleCell"> <int key="NSCellFlags">67239424</int> @@ -111,7 +110,6 @@ <int key="NSvFlags">265</int> <string key="NSFrame">{{411, 5}, {24, 27}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="145095454"> <int key="NSCellFlags">67239424</int> @@ -144,12 +142,11 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{131, 5}, {308, 27}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">33004</int> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="971876011"> - <int key="NSCellFlags">-1805517311</int> - <int key="NSCellFlags2">1073774592</int> + <int key="NSCellFlags">-1804468671</int> + <int key="NSCellFlags2">1073775616</int> <object class="NSAttributedString" key="NSContents"> <string key="NSString">chromium.org</string> <object class="NSDictionary" key="NSAttributes"> @@ -196,7 +193,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{102, 4}, {29, 29}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">35000</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="279099892"> @@ -223,7 +219,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{67, 4}, {31, 29}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">33002</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="352237189"> @@ -249,7 +244,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{34, 4}, {28, 29}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">33001</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="616960232"> @@ -276,7 +270,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{6, 4}, {29, 29}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">33000</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="599914932"> @@ -303,7 +296,6 @@ <int key="NSvFlags">265</int> <string key="NSFrame">{{439, 4}, {29, 29}}</string> <reference key="NSSuperview" ref="588745489"/> - <reference key="NSWindow"/> <int key="NSTag">33005</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="932073098"> @@ -328,7 +320,6 @@ </object> <string key="NSFrame">{{0, 322}, {480, 38}}</string> <reference key="NSSuperview" ref="675542922"/> - <reference key="NSWindow"/> <string key="NSClassName">ToolbarView</string> </object> <object class="NSCustomView" id="995989345"> @@ -336,13 +327,11 @@ <int key="NSvFlags">289</int> <string key="NSFrame">{{465, 0}, {15, 15}}</string> <reference key="NSSuperview" ref="675542922"/> - <reference key="NSWindow"/> <string key="NSClassName">GrowBoxView</string> </object> </object> <string key="NSFrameSize">{480, 360}</string> <reference key="NSSuperview"/> - <reference key="NSWindow"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{480, 382}</string> diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 68cf7cf..dafb98b 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -43,7 +43,8 @@ tabStripController_ = [[TabStripController alloc] initWithView:tabStripView_ - model:browser_->tabstrip_model() + tabModel:browser_->tabstrip_model() + toolbarModel:browser_->toolbar_model() commands:browser_->command_updater()]; // Place the tab bar above the content box and add it to the view hierarchy diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index 9f2eddd..99d5a8a 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -13,6 +13,7 @@ class LocationBar; class TabContents; class TabContentsCommandObserver; class TabStripModel; +class ToolbarModel; // A class that controls the contents of a tab, including the toolbar and // web area. @@ -31,6 +32,7 @@ class TabStripModel; TabContentsCommandObserver* observer_; // nil if |commands_| is nil LocationBar* locationBarBridge_; TabContents* contents_; // weak + ToolbarModel* toolbarModel_; // weak, one per window IBOutlet NSButton* backButton_; IBOutlet NSButton* forwardButton_; IBOutlet NSButton* reloadStopButton_; @@ -46,7 +48,8 @@ class TabStripModel; - (id)initWithNibName:(NSString*)name bundle:(NSBundle*)bundle contents:(TabContents*)contents - commands:(CommandUpdater*)commands; + commands:(CommandUpdater*)commands + toolbarModel:(ToolbarModel*)toolbarModel; // Take this view (toolbar and web contents) full screen - (IBAction)fullScreen:(id)sender; diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index 8924a87..ed6ebaa 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -8,6 +8,7 @@ #import "chrome/app/chrome_dll_resource.h" #import "chrome/browser/command_updater.h" #import "chrome/browser/location_bar.h" +#import "chrome/browser/toolbar_model.h" // For now, tab_contents lives here. TODO(port):fix #include "chrome/common/temp_scaffolding_stubs.h" @@ -73,13 +74,15 @@ class LocationBarBridge : public LocationBar { - (id)initWithNibName:(NSString*)name bundle:(NSBundle*)bundle contents:(TabContents*)contents - commands:(CommandUpdater*)commands { + commands:(CommandUpdater*)commands + toolbarModel:(ToolbarModel*)toolbarModel { if ((self = [super initWithNibName:name bundle:bundle])) { commands_ = commands; if (commands_) observer_ = new TabContentsCommandObserver(self, commands); locationBarBridge_ = new LocationBarBridge(self); contents_ = contents; + toolbarModel_ = toolbarModel; } return self; } @@ -184,15 +187,9 @@ class LocationBarBridge : public LocationBar { // 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. - } + + NSString* urlString = base::SysWideToNSString(toolbarModel_->GetText()); + [locationBar_ setStringValue:urlString]; } - (void)setStarredState:(BOOL)isStarred { diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index 5a03525..45f6459 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -13,6 +13,7 @@ class LocationBar; class TabStripBridge; class TabStripModel; class TabContents; +class ToolbarModel; // 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 @@ -30,7 +31,8 @@ class TabContents; TabStripView* tabView_; // weak NSButton* newTabButton_; TabStripBridge* bridge_; - TabStripModel* model_; // weak + TabStripModel* tabModel_; // weak + ToolbarModel* toolbarModel_; // weak, one per browser CommandUpdater* commands_; // weak, may be nil // maps TabContents to a TabContentsController (which owns the parent view // for the toolbar and associated tab contents) @@ -41,7 +43,8 @@ class TabContents; // tracking what's enabled and disabled. |commands| may be nil if no updating // is desired. - (id)initWithView:(TabStripView*)view - model:(TabStripModel*)model + tabModel:(TabStripModel*)tabModel + toolbarModel:(ToolbarModel*)toolbarModel commands:(CommandUpdater*)commands; // Get the C++ bridge object representing the location bar for the current tab. diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 2f821e5..1613952 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -61,14 +61,16 @@ class TabStripBridge : public TabStripModelObserver { @implementation TabStripController - (id)initWithView:(TabStripView*)view - model:(TabStripModel*)model + tabModel:(TabStripModel*)tabModel + toolbarModel:(ToolbarModel*)toolbarModel commands:(CommandUpdater*)commands { - DCHECK(view && model); + DCHECK(view && tabModel && toolbarModel); if ((self = [super init])) { tabView_ = view; - model_ = model; + tabModel_ = tabModel; + toolbarModel_ = toolbarModel; commands_ = commands; - bridge_ = new TabStripBridge(model, self); + bridge_ = new TabStripBridge(tabModel, self); tabContentsToController_ = [[NSMutableDictionary alloc] init]; // Create the new tab button separate from the nib so we can make sure @@ -165,8 +167,8 @@ class TabStripBridge : public TabStripModelObserver { // which feeds back into us via a notification. - (void)selectTab:(id)sender { int index = [self indexForTabView:sender]; // for testing... - if (index >= 0 && model_->ContainsIndex(index)) - model_->SelectTabContentsAt(index, true); + if (index >= 0 && tabModel_->ContainsIndex(index)) + tabModel_->SelectTabContentsAt(index, true); } // Return the frame for a new tab that will go to the immediate right of the @@ -202,7 +204,7 @@ class TabStripBridge : public TabStripModelObserver { atIndex:(NSInteger)index inForeground:(bool)inForeground { DCHECK(contents); - DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index)); + DCHECK(index == TabStripModel::kNoTab || tabModel_->ContainsIndex(index)); // TODO(pinkerton): handle tab dragging in here @@ -212,7 +214,9 @@ class TabStripBridge : public TabStripModelObserver { [[[TabContentsController alloc] initWithNibName:@"TabContents" bundle:nil contents:contents - commands:commands_] autorelease]; + commands:commands_ + toolbarModel:toolbarModel_] + autorelease]; NSValue* key = [NSValue valueWithPointer:contents]; [tabContentsToController_ setObject:contentsController forKey:key]; @@ -308,7 +312,7 @@ class TabStripBridge : public TabStripModelObserver { } - (LocationBar*)locationBar { - TabContents* selectedContents = model_->GetSelectedTabContents(); + TabContents* selectedContents = tabModel_->GetSelectedTabContents(); TabContentsController* selectedController = [self controllerWithContents:selectedContents]; return [selectedController locationBar]; @@ -328,7 +332,7 @@ class TabStripBridge : public TabStripModelObserver { } - (void)setStarredState:(BOOL)isStarred { - TabContents* selectedContents = model_->GetSelectedTabContents(); + TabContents* selectedContents = tabModel_->GetSelectedTabContents(); TabContentsController* selectedController = [self controllerWithContents:selectedContents]; [selectedController setStarredState:isStarred]; @@ -337,12 +341,12 @@ class TabStripBridge : public TabStripModelObserver { // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. - (NSRect)selectedTabGrowBoxRect { - TabContents* selectedContents = model_->GetSelectedTabContents(); + TabContents* selectedContents = tabModel_->GetSelectedTabContents(); if (!selectedContents) { // When the window is initially being constructed, there may be no currently // selected tab, so pick the first one. If there aren't any, just bail with // an empty rect. - selectedContents = model_->GetTabContentsAt(0); + selectedContents = tabModel_->GetTabContentsAt(0); if (!selectedContents) return NSMakeRect(0, 0, 0, 0); } diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index b1d6127..08dc00b 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -8,7 +8,6 @@ #include "chrome/browser/ssl/ssl_error_info.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" @@ -16,6 +15,13 @@ #include "grit/generated_resources.h" #include "net/base/net_util.h" +#if defined(OS_WIN) +#include "chrome/browser/tab_contents/tab_contents.h" +#elif defined(OS_POSIX) +// TODO(port): remove when tab_contents is ported +#include "chrome/common/temp_scaffolding_stubs.h" +#endif + ToolbarModel::ToolbarModel() : input_in_progress_(false) { } diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index 0cb2e24..b1f745b 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -473,6 +473,7 @@ class TabContents : public PageNavigator, public NotificationObserver { TabContentsFactory* factory); void OnStartDownload(DownloadItem* download) { NOTIMPLEMENTED(); } void RemoveInfoBar(InfoBarDelegate* delegate) { NOTIMPLEMENTED(); } + virtual bool ShouldDisplayURL() { return true; } protected: typedef std::vector<ConstrainedWindow*> ConstrainedWindowList; ConstrainedWindowList child_windows_; |