| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/toolbar_controller.h" | 5 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #import "chrome/browser/cocoa/location_bar_view_mac.h" | 9 #import "chrome/browser/cocoa/location_bar_view_mac.h" |
| 10 #include "chrome/browser/toolbar_model.h" | 10 #include "chrome/browser/toolbar_model.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 commandObserver_->ObserveCommand(IDC_STAR); | 35 commandObserver_->ObserveCommand(IDC_STAR); |
| 36 } | 36 } |
| 37 return self; | 37 return self; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Called after the view is done loading and the outlets have been hooked up. | 40 // Called after the view is done loading and the outlets have been hooked up. |
| 41 // Now we can hook up bridges that rely on UI objects such as the location | 41 // Now we can hook up bridges that rely on UI objects such as the location |
| 42 // bar and button state. | 42 // bar and button state. |
| 43 - (void)awakeFromNib { | 43 - (void)awakeFromNib { |
| 44 [self initCommandStatus:commands_]; | 44 [self initCommandStatus:commands_]; |
| 45 locationBarView_ = new LocationBarViewMac(locationBar_); | 45 locationBarView_ = new LocationBarViewMac(locationBar_, commands_, |
| 46 toolbarModel_); |
| 46 locationBarView_->Init(); | 47 locationBarView_->Init(); |
| 47 [locationBar_ setStringValue:@"http://dev.chromium.org"]; | 48 [locationBar_ setStringValue:@"http://dev.chromium.org"]; |
| 48 } | 49 } |
| 49 | 50 |
| 50 - (void)dealloc { | 51 - (void)dealloc { |
| 51 delete locationBarView_; | 52 delete locationBarView_; |
| 52 delete commandObserver_; | 53 delete commandObserver_; |
| 53 [super dealloc]; | 54 [super dealloc]; |
| 54 } | 55 } |
| 55 | 56 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 [reloadButton_ | 94 [reloadButton_ |
| 94 setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO]; | 95 setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO]; |
| 95 // TODO(pinkerton): Add home button. | 96 // TODO(pinkerton): Add home button. |
| 96 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; | 97 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; |
| 97 } | 98 } |
| 98 | 99 |
| 99 - (void)updateToolbarWithContents:(TabContents*)tab { | 100 - (void)updateToolbarWithContents:(TabContents*)tab { |
| 100 // TODO(pinkerton): there's a lot of ui code in autocomplete_edit.cc | 101 // TODO(pinkerton): there's a lot of ui code in autocomplete_edit.cc |
| 101 // that we'll want to duplicate. For now, just handle setting the text. | 102 // that we'll want to duplicate. For now, just handle setting the text. |
| 102 | 103 |
| 104 // TODO(shess): This is the start of what pinkerton refers to. |
| 105 // Unfortunately, I'm going to need to spend some time wiring things |
| 106 // up. This call should suffice to close any open autocomplete |
| 107 // pulldown. It should also be the right thing to do to save and |
| 108 // restore state, but at this time it's not clear that this is the |
| 109 // right place, and tab is not the right parameter. |
| 110 if (locationBarView_) { |
| 111 locationBarView_->SaveStateToContents(NULL); |
| 112 } |
| 113 |
| 103 // TODO(pinkerton): update the security lock icon and background color | 114 // TODO(pinkerton): update the security lock icon and background color |
| 104 | 115 |
| 116 // TODO(shess): Determine whether this should happen via |
| 117 // locationBarView_, instead, in which case this class can |
| 118 // potentially lose the locationBar_ reference. |
| 105 NSString* urlString = base::SysWideToNSString(toolbarModel_->GetText()); | 119 NSString* urlString = base::SysWideToNSString(toolbarModel_->GetText()); |
| 106 [locationBar_ setStringValue:urlString]; | 120 [locationBar_ setStringValue:urlString]; |
| 107 } | 121 } |
| 108 | 122 |
| 109 - (void)setStarredState:(BOOL)isStarred { | 123 - (void)setStarredState:(BOOL)isStarred { |
| 110 NSString* starImageName = kStarImageName; | 124 NSString* starImageName = kStarImageName; |
| 111 if (isStarred) | 125 if (isStarred) |
| 112 starImageName = kStarredImageName; | 126 starImageName = kStarredImageName; |
| 113 [starButton_ setImage:[NSImage imageNamed:starImageName]]; | 127 [starButton_ setImage:[NSImage imageNamed:starImageName]]; |
| 114 } | 128 } |
| 115 | 129 |
| 116 - (void)setIsLoading:(BOOL)isLoading { | 130 - (void)setIsLoading:(BOOL)isLoading { |
| 117 NSString* imageName = @"go"; | 131 NSString* imageName = @"go"; |
| 118 if (isLoading) | 132 if (isLoading) |
| 119 imageName = @"stop"; | 133 imageName = @"stop"; |
| 120 [goButton_ setImage:[NSImage imageNamed:imageName]]; | 134 [goButton_ setImage:[NSImage imageNamed:imageName]]; |
| 121 } | 135 } |
| 122 | 136 |
| 123 @end | 137 @end |
| OLD | NEW |