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/browser | |
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/browser')
-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 |
6 files changed, 41 insertions, 27 deletions
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) { } |