| 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" |
| 11 #include "base/keyboard_codes.h" |
| 10 #include "base/mac_util.h" | 12 #include "base/mac_util.h" |
| 11 #include "base/nsimage_cache_mac.h" | 13 #include "base/nsimage_cache_mac.h" |
| 14 #include "base/singleton.h" |
| 12 #include "base/sys_string_conversions.h" | 15 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/app/chrome_dll_resource.h" | 16 #include "chrome/app/chrome_dll_resource.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 17 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 15 #include "chrome/browser/browser.h" | 18 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_window.h" | 19 #include "chrome/browser/browser_window.h" |
| 20 #import "chrome/browser/cocoa/accelerators_cocoa.h" |
| 17 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 21 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 18 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 22 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 19 #import "chrome/browser/cocoa/back_forward_menu_controller.h" | 23 #import "chrome/browser/cocoa/back_forward_menu_controller.h" |
| 20 #import "chrome/browser/cocoa/background_gradient_view.h" | 24 #import "chrome/browser/cocoa/background_gradient_view.h" |
| 21 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" | 25 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" |
| 22 #import "chrome/browser/cocoa/extensions/browser_action_button.h" | 26 #import "chrome/browser/cocoa/extensions/browser_action_button.h" |
| 23 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" | 27 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" |
| 24 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" | 28 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" |
| 25 #import "chrome/browser/cocoa/gradient_button_cell.h" | 29 #import "chrome/browser/cocoa/gradient_button_cell.h" |
| 26 #import "chrome/browser/cocoa/location_bar_view_mac.h" | 30 #import "chrome/browser/cocoa/location_bar_view_mac.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 virtual bool IsCommandIdChecked(int command_id) const { | 99 virtual bool IsCommandIdChecked(int command_id) const { |
| 96 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 100 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
| 97 return browser_->profile()->GetPrefs()->GetBoolean( | 101 return browser_->profile()->GetPrefs()->GetBoolean( |
| 98 prefs::kShowBookmarkBar); | 102 prefs::kShowBookmarkBar); |
| 99 } | 103 } |
| 100 return false; | 104 return false; |
| 101 } | 105 } |
| 102 virtual bool IsCommandIdEnabled(int command_id) const { | 106 virtual bool IsCommandIdEnabled(int command_id) const { |
| 103 return browser_->command_updater()->IsCommandEnabled(command_id); | 107 return browser_->command_updater()->IsCommandEnabled(command_id); |
| 104 } | 108 } |
| 105 virtual bool GetAcceleratorForCommandId( | 109 virtual bool GetAcceleratorForCommandId(int command_id, |
| 106 int command_id, | 110 menus::Accelerator* accelerator_generic) { |
| 107 menus::Accelerator* accelerator) { return false; } | 111 // Downcast so that when the copy constructor is invoked below, the key |
| 112 // string gets copied, too. |
| 113 menus::AcceleratorCocoa* out_accelerator = |
| 114 static_cast<menus::AcceleratorCocoa*>(accelerator_generic); |
| 115 AcceleratorsCocoa* keymap = Singleton<AcceleratorsCocoa>::get(); |
| 116 const menus::AcceleratorCocoa* accelerator = |
| 117 keymap->GetAcceleratorForCommand(command_id); |
| 118 if (accelerator) { |
| 119 *out_accelerator = *accelerator; |
| 120 return true; |
| 121 } |
| 122 return false; |
| 123 } |
| 108 virtual void ExecuteCommand(int command_id) { | 124 virtual void ExecuteCommand(int command_id) { |
| 109 browser_->ExecuteCommand(command_id); | 125 browser_->ExecuteCommand(command_id); |
| 110 } | 126 } |
| 111 virtual bool IsLabelForCommandIdDynamic(int command_id) const { | 127 virtual bool IsLabelForCommandIdDynamic(int command_id) const { |
| 112 // On Mac, switch between "Enter Full Screen" and "Exit Full Screen". | 128 // On Mac, switch between "Enter Full Screen" and "Exit Full Screen". |
| 113 return (command_id == IDC_FULLSCREEN); | 129 return (command_id == IDC_FULLSCREEN); |
| 114 } | 130 } |
| 115 virtual string16 GetLabelForCommandId(int command_id) const { | 131 virtual string16 GetLabelForCommandId(int command_id) const { |
| 116 if (command_id == IDC_FULLSCREEN) { | 132 if (command_id == IDC_FULLSCREEN) { |
| 117 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter. | 133 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter. |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 754 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
| 739 // Do nothing. | 755 // Do nothing. |
| 740 } | 756 } |
| 741 | 757 |
| 742 // (URLDropTargetController protocol) | 758 // (URLDropTargetController protocol) |
| 743 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 759 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 744 // Do nothing. | 760 // Do nothing. |
| 745 } | 761 } |
| 746 | 762 |
| 747 @end | 763 @end |
| OLD | NEW |