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 3// found in the LICENSE file. 4 5#import "ui/base/accelerators/platform_accelerator_cocoa.h" 6 7#include "base/memory/scoped_ptr.h" 8 9namespace ui { 10 11PlatformAcceleratorCocoa::PlatformAcceleratorCocoa() : modifier_mask_(0) { 12} 13 14PlatformAcceleratorCocoa::PlatformAcceleratorCocoa(NSString* key_code, 15 NSUInteger modifier_mask) 16 : characters_([key_code copy]), 17 modifier_mask_(modifier_mask) { 18} 19 20PlatformAcceleratorCocoa::~PlatformAcceleratorCocoa() { 21} 22 23scoped_ptr<PlatformAccelerator> PlatformAcceleratorCocoa::CreateCopy() const { 24 scoped_ptr<PlatformAcceleratorCocoa> copy(new PlatformAcceleratorCocoa); 25 copy->characters_.reset([characters_ copy]); 26 copy->modifier_mask_ = modifier_mask_; 27 return scoped_ptr<PlatformAccelerator>(copy.release()); 28} 29 30bool PlatformAcceleratorCocoa::Equals(const PlatformAccelerator& rhs) const { 31 const PlatformAcceleratorCocoa& rhs_cocoa = 32 static_cast<const PlatformAcceleratorCocoa&>(rhs); 33 return [characters_ isEqualToString:rhs_cocoa.characters_] && 34 modifier_mask_ == rhs_cocoa.modifier_mask_; 35} 36 37} // namespace ui 38