summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_window_controller.mm
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 22:04:44 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 22:04:44 +0000
commit88d749436bf04c540448065a1601ece53bfdb312 (patch)
tree4be4d6d86a0884932d13efd92a2a18d60a7f962f /chrome/browser/browser_window_controller.mm
parent1c36b962d877273125d92c4996a136fc1ac7e806 (diff)
downloadchromium_src-88d749436bf04c540448065a1601ece53bfdb312.zip
chromium_src-88d749436bf04c540448065a1601ece53bfdb312.tar.gz
chromium_src-88d749436bf04c540448065a1601ece53bfdb312.tar.bz2
add basic command handling for browser window and for where there are no windows open. Can now create new browser windows.
Review URL: http://codereview.chromium.org/18458 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_window_controller.mm')
-rw-r--r--chrome/browser/browser_window_controller.mm30
1 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/browser_window_controller.mm b/chrome/browser/browser_window_controller.mm
index c5e4abc..bb5b9cc 100644
--- a/chrome/browser/browser_window_controller.mm
+++ b/chrome/browser/browser_window_controller.mm
@@ -58,6 +58,36 @@
return YES;
}
+// Called to validate menu and toolbar items when this window is key. All the
+// items we care about have been set with the |commandDispatch:| action and
+// a target of FirstResponder in IB. If it's not one of those, let it
+// continue up the responder chain to be handled elsewhere. We pull out the
+// tag as the cross-platform constant to differentiate and dispatch the
+// various commands.
+// NOTE: we might have to handle state for app-wide menu items,
+// although we could cheat and directly ask the app controller if our
+// command_updater doesn't support the command. This may or may not be an issue,
+// too early to tell.
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
+ SEL action = [item action];
+ BOOL enable = NO;
+ if (action == @selector(commandDispatch:)) {
+ NSInteger tag = [item tag];
+ if (browser_->command_updater()->SupportsCommand(tag))
+ enable = browser_->command_updater()->IsCommandEnabled(tag) ? YES : NO;
+ }
+ return enable;
+}
+
+// Called when the user picks a menu or toolbar item when this window is key.
+// Calls through to the browser object to execute the command. This assumes that
+// the command is supported and doesn't check, otherwise it would have been
+// disabled in the UI in validateUserInterfaceItem:.
+- (void)commandDispatch:(id)sender {
+ NSInteger tag = [sender tag];
+ browser_->ExecuteCommand(tag);
+}
+
// NSToolbar delegate methods
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {