OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 }; | 147 }; |
148 | 148 |
149 } // namespace ToolbarControllerInternal | 149 } // namespace ToolbarControllerInternal |
150 | 150 |
151 @implementation ToolbarController | 151 @implementation ToolbarController |
152 | 152 |
153 - (id)initWithModel:(ToolbarModel*)model | 153 - (id)initWithModel:(ToolbarModel*)model |
154 commands:(CommandUpdater*)commands | 154 commands:(CommandUpdater*)commands |
155 profile:(Profile*)profile | 155 profile:(Profile*)profile |
156 browser:(Browser*)browser | 156 browser:(Browser*)browser |
157 resizeDelegate:(id<ViewResizer>)resizeDelegate { | 157 resizeDelegate:(id<ViewResizer>)resizeDelegate |
158 DCHECK(model && commands && profile); | 158 nibFileNamed:(NSString*)nibName { |
159 if ((self = [super initWithNibName:@"Toolbar" | 159 DCHECK(model && commands && profile && [nibName length]); |
| 160 if ((self = [super initWithNibName:nibName |
160 bundle:mac_util::MainAppBundle()])) { | 161 bundle:mac_util::MainAppBundle()])) { |
161 toolbarModel_ = model; | 162 toolbarModel_ = model; |
162 commands_ = commands; | 163 commands_ = commands; |
163 profile_ = profile; | 164 profile_ = profile; |
164 browser_ = browser; | 165 browser_ = browser; |
165 resizeDelegate_ = resizeDelegate; | 166 resizeDelegate_ = resizeDelegate; |
166 hasToolbar_ = YES; | 167 hasToolbar_ = YES; |
167 hasLocationBar_ = YES; | 168 hasLocationBar_ = YES; |
168 | 169 |
169 // Register for notifications about state changes for the toolbar buttons | 170 // Register for notifications about state changes for the toolbar buttons |
170 commandObserver_.reset(new CommandObserverBridge(self, commands)); | 171 commandObserver_.reset(new CommandObserverBridge(self, commands)); |
171 commandObserver_->ObserveCommand(IDC_BACK); | 172 commandObserver_->ObserveCommand(IDC_BACK); |
172 commandObserver_->ObserveCommand(IDC_FORWARD); | 173 commandObserver_->ObserveCommand(IDC_FORWARD); |
173 commandObserver_->ObserveCommand(IDC_RELOAD); | 174 commandObserver_->ObserveCommand(IDC_RELOAD); |
174 commandObserver_->ObserveCommand(IDC_HOME); | 175 commandObserver_->ObserveCommand(IDC_HOME); |
175 commandObserver_->ObserveCommand(IDC_BOOKMARK_PAGE); | 176 commandObserver_->ObserveCommand(IDC_BOOKMARK_PAGE); |
176 } | 177 } |
177 return self; | 178 return self; |
178 } | 179 } |
179 | 180 |
| 181 - (id)initWithModel:(ToolbarModel*)model |
| 182 commands:(CommandUpdater*)commands |
| 183 profile:(Profile*)profile |
| 184 browser:(Browser*)browser |
| 185 resizeDelegate:(id<ViewResizer>)resizeDelegate { |
| 186 if ((self = [self initWithModel:model |
| 187 commands:commands |
| 188 profile:profile |
| 189 browser:browser |
| 190 resizeDelegate:resizeDelegate |
| 191 nibFileNamed:@"Toolbar"])) { |
| 192 } |
| 193 return self; |
| 194 } |
| 195 |
| 196 |
180 - (void)dealloc { | 197 - (void)dealloc { |
181 // Make sure any code in the base class which assumes [self view] is | 198 // Make sure any code in the base class which assumes [self view] is |
182 // the "parent" view continues to work. | 199 // the "parent" view continues to work. |
183 hasToolbar_ = YES; | 200 hasToolbar_ = YES; |
184 hasLocationBar_ = YES; | 201 hasLocationBar_ = YES; |
185 | 202 |
186 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 203 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
187 | 204 |
188 if (trackingArea_.get()) | 205 if (trackingArea_.get()) |
189 [[self view] removeTrackingArea:trackingArea_.get()]; | 206 [[self view] removeTrackingArea:trackingArea_.get()]; |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 838 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
822 // Do nothing. | 839 // Do nothing. |
823 } | 840 } |
824 | 841 |
825 // (URLDropTargetController protocol) | 842 // (URLDropTargetController protocol) |
826 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 843 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
827 // Do nothing. | 844 // Do nothing. |
828 } | 845 } |
829 | 846 |
830 @end | 847 @end |
OLD | NEW |