Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 155444: Mac pop-up window happier-ness.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/location_bar_view_mac.h" 10 #import "chrome/browser/cocoa/location_bar_view_mac.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 webContentView:(NSView*)webContentView 79 webContentView:(NSView*)webContentView
80 bookmarkDelegate:(id<BookmarkURLOpener>)delegate { 80 bookmarkDelegate:(id<BookmarkURLOpener>)delegate {
81 DCHECK(model && commands && profile); 81 DCHECK(model && commands && profile);
82 if ((self = [super initWithNibName:@"Toolbar" 82 if ((self = [super initWithNibName:@"Toolbar"
83 bundle:mac_util::MainAppBundle()])) { 83 bundle:mac_util::MainAppBundle()])) {
84 toolbarModel_ = model; 84 toolbarModel_ = model;
85 commands_ = commands; 85 commands_ = commands;
86 profile_ = profile; 86 profile_ = profile;
87 bookmarkBarDelegate_ = delegate; 87 bookmarkBarDelegate_ = delegate;
88 webContentView_ = webContentView; 88 webContentView_ = webContentView;
89 hasToolbar_ = YES;
89 90
90 // Register for notifications about state changes for the toolbar buttons 91 // Register for notifications about state changes for the toolbar buttons
91 commandObserver_.reset(new CommandObserverBridge(self, commands)); 92 commandObserver_.reset(new CommandObserverBridge(self, commands));
92 commandObserver_->ObserveCommand(IDC_BACK); 93 commandObserver_->ObserveCommand(IDC_BACK);
93 commandObserver_->ObserveCommand(IDC_FORWARD); 94 commandObserver_->ObserveCommand(IDC_FORWARD);
94 commandObserver_->ObserveCommand(IDC_RELOAD); 95 commandObserver_->ObserveCommand(IDC_RELOAD);
95 commandObserver_->ObserveCommand(IDC_HOME); 96 commandObserver_->ObserveCommand(IDC_HOME);
96 commandObserver_->ObserveCommand(IDC_STAR); 97 commandObserver_->ObserveCommand(IDC_STAR);
97 } 98 }
98 return self; 99 return self;
99 } 100 }
100 101
102 - (void)dealloc {
103 // Make sure any code in the base class which assumes [self view] is
104 // the "parent" view continues to work.
105 hasToolbar_ = YES;
106
107 [super dealloc];
108 }
109
101 // Called after the view is done loading and the outlets have been hooked up. 110 // Called after the view is done loading and the outlets have been hooked up.
102 // Now we can hook up bridges that rely on UI objects such as the location 111 // Now we can hook up bridges that rely on UI objects such as the location
103 // bar and button state. 112 // bar and button state.
104 - (void)awakeFromNib { 113 - (void)awakeFromNib {
105 [self initCommandStatus:commands_]; 114 [self initCommandStatus:commands_];
106 locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_, 115 locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_,
107 toolbarModel_, profile_)); 116 toolbarModel_, profile_));
108 [locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]]; 117 [locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
109 118
110 // Register pref observers for the optional home and page/options buttons 119 // Register pref observers for the optional home and page/options buttons
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (isLoading) { 206 if (isLoading) {
198 imageName = @"stop_Template.pdf"; 207 imageName = @"stop_Template.pdf";
199 tag = IDC_STOP; 208 tag = IDC_STOP;
200 } 209 }
201 NSImage* stopStartImage = nsimage_cache::ImageNamed(imageName); 210 NSImage* stopStartImage = nsimage_cache::ImageNamed(imageName);
202 [stopStartImage setTemplate:YES]; 211 [stopStartImage setTemplate:YES];
203 [goButton_ setImage:stopStartImage]; 212 [goButton_ setImage:stopStartImage];
204 [goButton_ setTag:tag]; 213 [goButton_ setTag:tag];
205 } 214 }
206 215
216 - (void)setHasToolbar:(BOOL)toolbar {
217 [self view]; // force nib loading
218 hasToolbar_ = toolbar;
219
220 // App mode allows turning off the location bar as well.
221 // TODO(???): add more code here when implementing app mode to allow
222 // turning off both toolbar AND location bar.
223
224 // TODO(jrg): add mode code to make the location bar NOT editable
225 // when in a pop-up.
226 }
227
228 - (NSView*)view {
229 if (hasToolbar_)
230 return [super view];
231 return locationBar_;
232 }
233
207 - (BookmarkBarController*)bookmarkBarController { 234 - (BookmarkBarController*)bookmarkBarController {
235 // Browser has a FEATURE_BOOKMARKBAR but it is ignored by Safari
236 // when using window.open(); the logic seems to be "if no toolbar,
237 // no bookmark bar".
238 // TODO(jrg): investigate non-Mac Chrome behavior and possibly expand this.
239 if (hasToolbar_ == NO)
240 return nil;
208 return bookmarkBarController_.get(); 241 return bookmarkBarController_.get();
209 } 242 }
210 243
211 - (id)customFieldEditorForObject:(id)obj { 244 - (id)customFieldEditorForObject:(id)obj {
212 if (obj == locationBar_) { 245 if (obj == locationBar_) {
213 // Lazilly construct Field editor, Cocoa UI code always runs on the 246 // Lazilly construct Field editor, Cocoa UI code always runs on the
214 // same thread, so there shoudn't be a race condition here. 247 // same thread, so there shoudn't be a race condition here.
215 if (locationBarFieldEditor_.get() == nil) { 248 if (locationBarFieldEditor_.get() == nil) {
216 locationBarFieldEditor_.reset([[LocationBarFieldEditor alloc] init]); 249 locationBarFieldEditor_.reset([[LocationBarFieldEditor alloc] init]);
217 } 250 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 forView:pageButton_]; 343 forView:pageButton_];
311 } 344 }
312 345
313 - (IBAction)showWrenchMenu:(id)sender { 346 - (IBAction)showWrenchMenu:(id)sender {
314 [NSMenu popUpContextMenu:wrenchMenu_ 347 [NSMenu popUpContextMenu:wrenchMenu_
315 withEvent:[NSApp currentEvent] 348 withEvent:[NSApp currentEvent]
316 forView:wrenchButton_]; 349 forView:wrenchButton_];
317 } 350 }
318 351
319 @end 352 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698