| 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/mac_util.h" | 7 #include "base/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 @implementation ToolbarController | 52 @implementation ToolbarController |
| 53 | 53 |
| 54 - (id)initWithModel:(ToolbarModel*)model | 54 - (id)initWithModel:(ToolbarModel*)model |
| 55 commands:(CommandUpdater*)commands | 55 commands:(CommandUpdater*)commands |
| 56 profile:(Profile*)profile | 56 profile:(Profile*)profile |
| 57 webContentView:(NSView*)webContentView | 57 webContentView:(NSView*)webContentView |
| 58 infoBarsView:(NSView*)infoBarsView |
| 58 bookmarkDelegate:(id<BookmarkURLOpener>)delegate { | 59 bookmarkDelegate:(id<BookmarkURLOpener>)delegate { |
| 59 DCHECK(model && commands && profile); | 60 DCHECK(model && commands && profile); |
| 60 if ((self = [super initWithNibName:@"Toolbar" | 61 if ((self = [super initWithNibName:@"Toolbar" |
| 61 bundle:mac_util::MainAppBundle()])) { | 62 bundle:mac_util::MainAppBundle()])) { |
| 62 toolbarModel_ = model; | 63 toolbarModel_ = model; |
| 63 commands_ = commands; | 64 commands_ = commands; |
| 64 profile_ = profile; | 65 profile_ = profile; |
| 65 bookmarkBarDelegate_ = delegate; | 66 bookmarkBarDelegate_ = delegate; |
| 66 webContentView_ = webContentView; | 67 webContentView_ = webContentView; |
| 68 infoBarsView_ = infoBarsView; |
| 67 hasToolbar_ = YES; | 69 hasToolbar_ = YES; |
| 68 | 70 |
| 69 // Register for notifications about state changes for the toolbar buttons | 71 // Register for notifications about state changes for the toolbar buttons |
| 70 commandObserver_.reset(new CommandObserverBridge(self, commands)); | 72 commandObserver_.reset(new CommandObserverBridge(self, commands)); |
| 71 commandObserver_->ObserveCommand(IDC_BACK); | 73 commandObserver_->ObserveCommand(IDC_BACK); |
| 72 commandObserver_->ObserveCommand(IDC_FORWARD); | 74 commandObserver_->ObserveCommand(IDC_FORWARD); |
| 73 commandObserver_->ObserveCommand(IDC_RELOAD); | 75 commandObserver_->ObserveCommand(IDC_RELOAD); |
| 74 commandObserver_->ObserveCommand(IDC_HOME); | 76 commandObserver_->ObserveCommand(IDC_HOME); |
| 75 commandObserver_->ObserveCommand(IDC_STAR); | 77 commandObserver_->ObserveCommand(IDC_STAR); |
| 76 } | 78 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 102 showPageOptionButtons_.Init(prefs::kShowPageOptionsButtons, prefs, | 104 showPageOptionButtons_.Init(prefs::kShowPageOptionsButtons, prefs, |
| 103 prefObserver_.get()); | 105 prefObserver_.get()); |
| 104 [self showOptionalHomeButton]; | 106 [self showOptionalHomeButton]; |
| 105 [self showOptionalPageWrenchButtons]; | 107 [self showOptionalPageWrenchButtons]; |
| 106 | 108 |
| 107 // Create a sub-controller for the bookmark bar. | 109 // Create a sub-controller for the bookmark bar. |
| 108 bookmarkBarController_.reset([[BookmarkBarController alloc] | 110 bookmarkBarController_.reset([[BookmarkBarController alloc] |
| 109 initWithProfile:profile_ | 111 initWithProfile:profile_ |
| 110 parentView:[self view] | 112 parentView:[self view] |
| 111 webContentView:webContentView_ | 113 webContentView:webContentView_ |
| 114 infoBarsView:infoBarsView_ |
| 112 delegate:bookmarkBarDelegate_]); | 115 delegate:bookmarkBarDelegate_]); |
| 113 | 116 |
| 114 // Add bookmark bar to the view hierarchy. This also triggers the | 117 // Add bookmark bar to the view hierarchy. This also triggers the |
| 115 // nib load. The bookmark bar is defined (in the nib) to be | 118 // nib load. The bookmark bar is defined (in the nib) to be |
| 116 // bottom-aligned to it's parent view (among other things), so | 119 // bottom-aligned to it's parent view (among other things), so |
| 117 // position and resize properties don't need to be set. | 120 // position and resize properties don't need to be set. |
| 118 [[self view] addSubview:[bookmarkBarController_ view]]; | 121 [[self view] addSubview:[bookmarkBarController_ view]]; |
| 119 } | 122 } |
| 120 | 123 |
| 121 - (LocationBar*)locationBar { | 124 - (LocationBar*)locationBar { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 forView:pageButton_]; | 325 forView:pageButton_]; |
| 323 } | 326 } |
| 324 | 327 |
| 325 - (IBAction)showWrenchMenu:(id)sender { | 328 - (IBAction)showWrenchMenu:(id)sender { |
| 326 [NSMenu popUpContextMenu:wrenchMenu_ | 329 [NSMenu popUpContextMenu:wrenchMenu_ |
| 327 withEvent:[NSApp currentEvent] | 330 withEvent:[NSApp currentEvent] |
| 328 forView:wrenchButton_]; | 331 forView:wrenchButton_]; |
| 329 } | 332 } |
| 330 | 333 |
| 331 @end | 334 @end |
| OLD | NEW |