OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/base/accelerators/platform_accelerator_cocoa.h" | 5 #import "ui/base/accelerators/platform_accelerator_cocoa.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
| 9 #include "base/memory/ptr_util.h" |
8 | 10 |
9 namespace ui { | 11 namespace ui { |
10 | 12 |
11 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa() : modifier_mask_(0) { | 13 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa() : modifier_mask_(0) { |
12 } | 14 } |
13 | 15 |
14 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa(NSString* key_code, | 16 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa(NSString* key_code, |
15 NSUInteger modifier_mask) | 17 NSUInteger modifier_mask) |
16 : characters_([key_code copy]), | 18 : characters_([key_code copy]), |
17 modifier_mask_(modifier_mask) { | 19 modifier_mask_(modifier_mask) { |
18 } | 20 } |
19 | 21 |
20 PlatformAcceleratorCocoa::~PlatformAcceleratorCocoa() { | 22 PlatformAcceleratorCocoa::~PlatformAcceleratorCocoa() { |
21 } | 23 } |
22 | 24 |
23 scoped_ptr<PlatformAccelerator> PlatformAcceleratorCocoa::CreateCopy() const { | 25 std::unique_ptr<PlatformAccelerator> PlatformAcceleratorCocoa::CreateCopy() |
24 scoped_ptr<PlatformAcceleratorCocoa> copy(new PlatformAcceleratorCocoa); | 26 const { |
| 27 std::unique_ptr<PlatformAcceleratorCocoa> copy(new PlatformAcceleratorCocoa); |
25 copy->characters_.reset([characters_ copy]); | 28 copy->characters_.reset([characters_ copy]); |
26 copy->modifier_mask_ = modifier_mask_; | 29 copy->modifier_mask_ = modifier_mask_; |
27 return make_scoped_ptr(copy.release()); | 30 return base::WrapUnique(copy.release()); |
28 } | 31 } |
29 | 32 |
30 bool PlatformAcceleratorCocoa::Equals(const PlatformAccelerator& rhs) const { | 33 bool PlatformAcceleratorCocoa::Equals(const PlatformAccelerator& rhs) const { |
31 const PlatformAcceleratorCocoa& rhs_cocoa = | 34 const PlatformAcceleratorCocoa& rhs_cocoa = |
32 static_cast<const PlatformAcceleratorCocoa&>(rhs); | 35 static_cast<const PlatformAcceleratorCocoa&>(rhs); |
33 return [characters_ isEqualToString:rhs_cocoa.characters_] && | 36 return [characters_ isEqualToString:rhs_cocoa.characters_] && |
34 modifier_mask_ == rhs_cocoa.modifier_mask_; | 37 modifier_mask_ == rhs_cocoa.modifier_mask_; |
35 } | 38 } |
36 | 39 |
37 } // namespace ui | 40 } // namespace ui |
OLD | NEW |