| 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 "app/menus/accelerator_cocoa.h" | 10 #include "app/menus/accelerator_cocoa.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #import "chrome/browser/cocoa/extensions/browser_action_button.h" | 24 #import "chrome/browser/cocoa/extensions/browser_action_button.h" |
| 25 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" | 25 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" |
| 26 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" | 26 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" |
| 27 #import "chrome/browser/cocoa/gradient_button_cell.h" | 27 #import "chrome/browser/cocoa/gradient_button_cell.h" |
| 28 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" | 28 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 29 #import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" | 29 #import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" |
| 30 #import "chrome/browser/cocoa/menu_button.h" | 30 #import "chrome/browser/cocoa/menu_button.h" |
| 31 #import "chrome/browser/cocoa/menu_controller.h" | 31 #import "chrome/browser/cocoa/menu_controller.h" |
| 32 #import "chrome/browser/cocoa/reload_button.h" | 32 #import "chrome/browser/cocoa/reload_button.h" |
| 33 #import "chrome/browser/cocoa/toolbar_view.h" | 33 #import "chrome/browser/cocoa/toolbar_view.h" |
| 34 #import "chrome/browser/cocoa/view_id_util.h" |
| 34 #include "chrome/browser/net/url_fixer_upper.h" | 35 #include "chrome/browser/net/url_fixer_upper.h" |
| 35 #include "chrome/browser/pref_service.h" | 36 #include "chrome/browser/pref_service.h" |
| 36 #include "chrome/browser/profile.h" | 37 #include "chrome/browser/profile.h" |
| 37 #include "chrome/browser/search_engines/template_url_model.h" | 38 #include "chrome/browser/search_engines/template_url_model.h" |
| 38 #include "chrome/browser/tab_contents/tab_contents.h" | 39 #include "chrome/browser/tab_contents/tab_contents.h" |
| 39 #include "chrome/browser/toolbar_model.h" | 40 #include "chrome/browser/toolbar_model.h" |
| 40 #include "chrome/browser/wrench_menu_model.h" | 41 #include "chrome/browser/wrench_menu_model.h" |
| 41 #include "chrome/common/notification_details.h" | 42 #include "chrome/common/notification_details.h" |
| 42 #include "chrome/common/notification_observer.h" | 43 #include "chrome/common/notification_observer.h" |
| 43 #include "chrome/common/notification_type.h" | 44 #include "chrome/common/notification_type.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 [reloadButton_ addToolTipRect:[reloadButton_ bounds] owner:self userData:nil]; | 289 [reloadButton_ addToolTipRect:[reloadButton_ bounds] owner:self userData:nil]; |
| 289 | 290 |
| 290 // If the user has any Browser Actions installed, the container view for them | 291 // If the user has any Browser Actions installed, the container view for them |
| 291 // may have to be resized depending on the width of the toolbar frame. | 292 // may have to be resized depending on the width of the toolbar frame. |
| 292 [toolbarView setPostsFrameChangedNotifications:YES]; | 293 [toolbarView setPostsFrameChangedNotifications:YES]; |
| 293 [[NSNotificationCenter defaultCenter] | 294 [[NSNotificationCenter defaultCenter] |
| 294 addObserver:self | 295 addObserver:self |
| 295 selector:@selector(toolbarFrameChanged) | 296 selector:@selector(toolbarFrameChanged) |
| 296 name:NSViewFrameDidChangeNotification | 297 name:NSViewFrameDidChangeNotification |
| 297 object:toolbarView]; | 298 object:toolbarView]; |
| 299 |
| 300 // Set commands for toolbar buttons. |reloadButton_| sets it by itself. |
| 301 [backButton_ setCommand:IDC_BACK]; |
| 302 [forwardButton_ setCommand:IDC_FORWARD]; |
| 303 [homeButton_ setCommand:IDC_HOME]; |
| 304 [wrenchButton_ setCommand:IDC_SHOW_APP_MENU]; |
| 305 |
| 306 // Set View IDs for toolbar elements. It's not necessary for |reloadButton_|, |
| 307 // |locationBar_| and |browserActionsContainerView_|, which override NSView's |
| 308 // tag method directly. |
| 309 [backButton_ setViewID:VIEW_ID_BACK_BUTTON]; |
| 310 [forwardButton_ setViewID:VIEW_ID_FORWARD_BUTTON]; |
| 311 [homeButton_ setViewID:VIEW_ID_HOME_BUTTON]; |
| 312 [wrenchButton_ setViewID:VIEW_ID_APP_MENU]; |
| 298 } | 313 } |
| 299 | 314 |
| 300 - (void)addAccessibilityDescriptions { | 315 - (void)addAccessibilityDescriptions { |
| 301 // Set accessibility descriptions. http://openradar.appspot.com/7496255 | 316 // Set accessibility descriptions. http://openradar.appspot.com/7496255 |
| 302 NSString* description = l10n_util::GetNSStringWithFixup(IDS_ACCNAME_BACK); | 317 NSString* description = l10n_util::GetNSStringWithFixup(IDS_ACCNAME_BACK); |
| 303 [[backButton_ cell] | 318 [[backButton_ cell] |
| 304 accessibilitySetOverrideValue:description | 319 accessibilitySetOverrideValue:description |
| 305 forAttribute:NSAccessibilityDescriptionAttribute]; | 320 forAttribute:NSAccessibilityDescriptionAttribute]; |
| 306 description = l10n_util::GetNSStringWithFixup(IDS_ACCNAME_FORWARD); | 321 description = l10n_util::GetNSStringWithFixup(IDS_ACCNAME_FORWARD); |
| 307 [[forwardButton_ cell] | 322 [[forwardButton_ cell] |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 - (BrowserActionsController*)browserActionsController { | 706 - (BrowserActionsController*)browserActionsController { |
| 692 return browserActionsController_.get(); | 707 return browserActionsController_.get(); |
| 693 } | 708 } |
| 694 | 709 |
| 695 - (NSString*)view:(NSView*)view | 710 - (NSString*)view:(NSView*)view |
| 696 stringForToolTip:(NSToolTipTag)tag | 711 stringForToolTip:(NSToolTipTag)tag |
| 697 point:(NSPoint)point | 712 point:(NSPoint)point |
| 698 userData:(void*)userData { | 713 userData:(void*)userData { |
| 699 DCHECK(view == reloadButton_); | 714 DCHECK(view == reloadButton_); |
| 700 | 715 |
| 701 return l10n_util::GetNSStringWithFixup( | 716 return l10n_util::GetNSStringWithFixup([reloadButton_ command] == IDC_STOP ? |
| 702 [reloadButton_ tag] == IDC_STOP ? IDS_TOOLTIP_STOP : IDS_TOOLTIP_RELOAD); | 717 IDS_TOOLTIP_STOP : IDS_TOOLTIP_RELOAD); |
| 703 } | 718 } |
| 704 | 719 |
| 705 // (URLDropTargetController protocol) | 720 // (URLDropTargetController protocol) |
| 706 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { | 721 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { |
| 707 // TODO(viettrungluu): This code is more or less copied from the code in | 722 // TODO(viettrungluu): This code is more or less copied from the code in |
| 708 // |TabStripController|. I'll refactor this soon to make it common and expand | 723 // |TabStripController|. I'll refactor this soon to make it common and expand |
| 709 // its capabilities (e.g., allow text DnD). | 724 // its capabilities (e.g., allow text DnD). |
| 710 if ([urls count] < 1) { | 725 if ([urls count] < 1) { |
| 711 NOTREACHED(); | 726 NOTREACHED(); |
| 712 return; | 727 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 728 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 743 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
| 729 // Do nothing. | 744 // Do nothing. |
| 730 } | 745 } |
| 731 | 746 |
| 732 // (URLDropTargetController protocol) | 747 // (URLDropTargetController protocol) |
| 733 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 748 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 734 // Do nothing. | 749 // Do nothing. |
| 735 } | 750 } |
| 736 | 751 |
| 737 @end | 752 @end |
| OLD | NEW |