| Index: ui/views/cocoa/native_widget_mac_accelerator_handler.mm
|
| diff --git a/ui/views/cocoa/native_widget_mac_accelerator_handler.mm b/ui/views/cocoa/native_widget_mac_accelerator_handler.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..64ed83d469993dcd0c4cc070425cf3078658ba4b
|
| --- /dev/null
|
| +++ b/ui/views/cocoa/native_widget_mac_accelerator_handler.mm
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/views/cocoa/native_widget_mac_accelerator_handler.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "ui/views/cocoa/native_widget_mac_nswindow.h"
|
| +
|
| +@implementation NativeWidgetMacAcceleratorHandler {
|
| + @private
|
| + NSWindow* parent_;
|
| +}
|
| +
|
| +- (instancetype)initWithParentWindow:(NSWindow*)parent {
|
| + if ((self = [super init])) {
|
| + DCHECK(parent);
|
| + parent_ = parent;
|
| + [[NSNotificationCenter defaultCenter]
|
| + addObserver:self
|
| + selector:@selector(parentWindowWillClose:)
|
| + name:NSWindowWillCloseNotification
|
| + object:parent_];
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (void)dealloc {
|
| + [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| + [super dealloc];
|
| +}
|
| +
|
| +- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
|
| + window:(NSWindow*)window {
|
| + if (!parent_)
|
| + return NO;
|
| + id parent = parent_;
|
| + if ([parent respondsToSelector:@selector(validateUserInterfaceItem:)])
|
| + return [parent validateUserInterfaceItem:item];
|
| + return NO;
|
| +}
|
| +
|
| +- (void)commandDispatch:(id)sender window:(NSWindow*)window {
|
| + id parent = parent_;
|
| + if ([parent respondsToSelector:@selector(commandDispatch:)])
|
| + [parent commandDispatch:sender];
|
| +}
|
| +
|
| +- (void)commandDispatchUsingKeyModifiers:(id)sender window:(NSWindow*)window {
|
| + id parent = parent_;
|
| + if ([parent respondsToSelector:@selector(commandDispatchUsingKeyModifiers:)])
|
| + [parent commandDispatchUsingKeyModifiers:sender];
|
| +}
|
| +
|
| +- (void)parentWindowWillClose:(NSNotification*)notification {
|
| + parent_ = nil;
|
| +}
|
| +
|
| +@end
|
|
|