Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / base / mac / scoped_aedesc.h
bloba1323c0cb7d202dfce09d2842a4cac0c5e905926
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
3 // found in the LICENSE file.
5 #ifndef BASE_MAC_SCOPED_AEDESC_H_
6 #define BASE_MAC_SCOPED_AEDESC_H_
8 #import <CoreServices/CoreServices.h>
10 #include "base/basictypes.h"
12 namespace base {
13 namespace mac {
15 // The ScopedAEDesc is used to scope AppleEvent descriptors. On creation,
16 // it will store a NULL descriptor. On destruction, it will dispose of the
17 // descriptor.
19 // This class is parameterized for additional type safety checks. You can use
20 // the generic AEDesc type by not providing a template parameter:
21 // ScopedAEDesc<> desc;
22 template <typename AEDescType = AEDesc>
23 class ScopedAEDesc {
24 public:
25 ScopedAEDesc() {
26 AECreateDesc(typeNull, NULL, 0, &desc_);
29 ~ScopedAEDesc() {
30 AEDisposeDesc(&desc_);
33 // Used for in parameters.
34 operator const AEDescType*() {
35 return &desc_;
38 // Used for out parameters.
39 AEDescType* OutPointer() {
40 return &desc_;
43 private:
44 AEDescType desc_;
46 DISALLOW_COPY_AND_ASSIGN(ScopedAEDesc);
49 } // namespace mac
50 } // namespace base
52 #endif // BASE_MAC_SCOPED_AEDESC_H_