blob: 51514c41a7a61b386ff9239f2647aae7370ff5ce [file] [log] [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/scoped_menu_bar_lock.h"
#import <AppKit/AppKit.h>
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface NSMenu (PrivateAPI)
- (void)_lockMenuPosition;
- (void)_unlockMenuPosition;
@end
ScopedMenuBarLock::ScopedMenuBarLock() {
if ([NSMenu instancesRespondToSelector:@selector(_lockMenuPosition)])
[NSApp.mainMenu _lockMenuPosition];
}
ScopedMenuBarLock::~ScopedMenuBarLock() {
if ([NSMenu instancesRespondToSelector:@selector(_unlockMenuPosition)])
[NSApp.mainMenu _unlockMenuPosition];
}