Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / accelerators / platform_accelerator_cocoa.mm
blobce2b4375ff821fccef634e251e021cc39ec7aaf1
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.
5 #import "ui/base/accelerators/platform_accelerator_cocoa.h"
7 #include "base/memory/scoped_ptr.h"
9 namespace ui {
11 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa() : modifier_mask_(0) {
14 PlatformAcceleratorCocoa::PlatformAcceleratorCocoa(NSString* key_code,
15                                                    NSUInteger modifier_mask)
16     : characters_([key_code copy]),
17       modifier_mask_(modifier_mask) {
20 PlatformAcceleratorCocoa::~PlatformAcceleratorCocoa() {
23 scoped_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 make_scoped_ptr(copy.release());
30 bool 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_;
37 }  // namespace ui