xref: /aosp_15_r20/external/cronet/base/mac/scoped_sending_event.mm (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1// Copyright 2011 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import "base/mac/scoped_sending_event.h"
6
7#include "base/check.h"
8
9namespace base::mac {
10
11ScopedSendingEvent::ScopedSendingEvent()
12    : app_(static_cast<NSObject<CrAppControlProtocol>*>(NSApp)) {
13  DCHECK([app_ conformsToProtocol:@protocol(CrAppControlProtocol)]);
14  handling_ = [app_ isHandlingSendEvent];
15  [app_ setHandlingSendEvent:YES];
16}
17
18ScopedSendingEvent::~ScopedSendingEvent() {
19  [app_ setHandlingSendEvent:handling_];
20}
21
22}  // namespace base::mac
23