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

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

Issue 164547: Mac: make save/open dialogs operate as tab-modal sheets.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Painfully (but hopefully correctly) merged ToT. Created 11 years, 2 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
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.mm ('k') | chrome/browser/debugger/devtools_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/nsimage_cache_mac.h" 9 #include "base/nsimage_cache_mac.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DCHECK(model && commands && profile); 94 DCHECK(model && commands && profile);
95 if ((self = [super initWithNibName:@"Toolbar" 95 if ((self = [super initWithNibName:@"Toolbar"
96 bundle:mac_util::MainAppBundle()])) { 96 bundle:mac_util::MainAppBundle()])) {
97 toolbarModel_ = model; 97 toolbarModel_ = model;
98 commands_ = commands; 98 commands_ = commands;
99 profile_ = profile; 99 profile_ = profile;
100 browser_ = browser; 100 browser_ = browser;
101 resizeDelegate_ = resizeDelegate; 101 resizeDelegate_ = resizeDelegate;
102 hasToolbar_ = YES; 102 hasToolbar_ = YES;
103 103
104 // Register for notificaotions about state changes for the toolbar buttons 104 // Register for notifications about state changes for the toolbar buttons.
105 commandObserver_.reset(new CommandObserverBridge(self, commands)); 105 commandObserver_.reset(new CommandObserverBridge(self, commands));
106 commandObserver_->ObserveCommand(IDC_BACK); 106 commandObserver_->ObserveCommand(IDC_BACK);
107 commandObserver_->ObserveCommand(IDC_FORWARD); 107 commandObserver_->ObserveCommand(IDC_FORWARD);
108 commandObserver_->ObserveCommand(IDC_RELOAD); 108 commandObserver_->ObserveCommand(IDC_RELOAD);
109 commandObserver_->ObserveCommand(IDC_HOME); 109 commandObserver_->ObserveCommand(IDC_HOME);
110 commandObserver_->ObserveCommand(IDC_STAR); 110 commandObserver_->ObserveCommand(IDC_STAR);
111 commandObserver_->ObserveCommand(IDC_OPEN_CURRENT_URL);
112 commandObserver_->ObserveCommand(IDC_PAGE_MENU_BUTTON);
113 commandObserver_->ObserveCommand(IDC_WRENCH_MENU_BUTTON);
111 } 114 }
112 return self; 115 return self;
113 } 116 }
114 117
115 - (void)dealloc { 118 - (void)dealloc {
116 // Make sure any code in the base class which assumes [self view] is 119 // Make sure any code in the base class which assumes [self view] is
117 // the "parent" view continues to work. 120 // the "parent" view continues to work.
118 hasToolbar_ = YES; 121 hasToolbar_ = YES;
119 122
120 if (trackingArea_.get()) 123 if (trackingArea_.get())
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // corresponding UI element. 232 // corresponding UI element.
230 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled { 233 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled {
231 NSButton* button = nil; 234 NSButton* button = nil;
232 switch (command) { 235 switch (command) {
233 case IDC_BACK: 236 case IDC_BACK:
234 button = backButton_; 237 button = backButton_;
235 break; 238 break;
236 case IDC_FORWARD: 239 case IDC_FORWARD:
237 button = forwardButton_; 240 button = forwardButton_;
238 break; 241 break;
242 case IDC_RELOAD:
243 button = reloadButton_;
244 break;
239 case IDC_HOME: 245 case IDC_HOME:
240 button = homeButton_; 246 button = homeButton_;
241 break; 247 break;
242 case IDC_STAR: 248 case IDC_STAR:
243 button = starButton_; 249 button = starButton_;
244 break; 250 break;
251 case IDC_OPEN_CURRENT_URL:
252 // We have two things to enable/disable.
253 [locationBar_ setEnabled:enabled];
254 button = goButton_;
255 break;
256 case IDC_PAGE_MENU_BUTTON:
257 button = pageButton_;
258 break;
259 case IDC_WRENCH_MENU_BUTTON:
260 button = wrenchButton_;
261 break;
245 } 262 }
246 [button setEnabled:enabled]; 263 [button setEnabled:enabled];
247 } 264 }
248 265
249 // Init the enabled state of the buttons on the toolbar to match the state in 266 // Init the enabled state of the controls on the toolbar to match the state in
250 // the controller. 267 // the controller.
251 - (void)initCommandStatus:(CommandUpdater*)commands { 268 - (void)initCommandStatus:(CommandUpdater*)commands {
252 [backButton_ setEnabled:commands->IsCommandEnabled(IDC_BACK) ? YES : NO]; 269 [backButton_ setEnabled:commands->IsCommandEnabled(IDC_BACK) ? YES : NO];
253 [forwardButton_ 270 [forwardButton_
254 setEnabled:commands->IsCommandEnabled(IDC_FORWARD) ? YES : NO]; 271 setEnabled:commands->IsCommandEnabled(IDC_FORWARD) ? YES : NO];
255 [reloadButton_ setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO]; 272 [reloadButton_ setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO];
256 [homeButton_ setEnabled:commands->IsCommandEnabled(IDC_HOME) ? YES : NO]; 273 [homeButton_ setEnabled:commands->IsCommandEnabled(IDC_HOME) ? YES : NO];
257 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; 274 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO];
275 [locationBar_ setEnabled:commands->IsCommandEnabled(IDC_OPEN_CURRENT_URL) ?
276 YES : NO];
277 [goButton_ setEnabled:commands->IsCommandEnabled(IDC_OPEN_CURRENT_URL) ?
278 YES : NO];
279 [pageButton_ setEnabled:commands->IsCommandEnabled(IDC_PAGE_MENU_BUTTON) ?
280 YES : NO];
281 [wrenchButton_ setEnabled:commands->IsCommandEnabled(IDC_WRENCH_MENU_BUTTON) ?
282 YES : NO];
258 } 283 }
259 284
260 - (void)updateToolbarWithContents:(TabContents*)tab 285 - (void)updateToolbarWithContents:(TabContents*)tab
261 shouldRestoreState:(BOOL)shouldRestore { 286 shouldRestoreState:(BOOL)shouldRestore {
262 locationBarView_->Update(tab, shouldRestore ? true : false); 287 locationBarView_->Update(tab, shouldRestore ? true : false);
263 } 288 }
264 289
265 - (void)setStarredState:(BOOL)isStarred { 290 - (void)setStarredState:(BOOL)isStarred {
266 NSImage* starImage = nil; 291 NSImage* starImage = nil;
267 NSString* toolTip; 292 NSString* toolTip;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 523
499 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, 524 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX,
500 NSHeight(locationFrame)); 525 NSHeight(locationFrame));
501 gfx::Rect stack_bounds( 526 gfx::Rect stack_bounds(
502 NSRectToCGRect([[self view] convertRect:r toView:nil])); 527 NSRectToCGRect([[self view] convertRect:r toView:nil]));
503 // Inset the bounds to just inside the visible edges (see comment above). 528 // Inset the bounds to just inside the visible edges (see comment above).
504 stack_bounds.Inset(kLocationStackEdgeWidth, 0); 529 stack_bounds.Inset(kLocationStackEdgeWidth, 0);
505 return stack_bounds; 530 return stack_bounds;
506 } 531 }
507 @end 532 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.mm ('k') | chrome/browser/debugger/devtools_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698