| 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 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ui::Accelerator accelerator = | 144 ui::Accelerator accelerator = |
| 145 AcceleratorFromKeyCode(entry.key_code, entry.modifiers); | 145 AcceleratorFromKeyCode(entry.key_code, entry.modifiers); |
| 146 accelerator_vector_.push_back(accelerator); | 146 accelerator_vector_.push_back(accelerator); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 AcceleratorsCocoa::~AcceleratorsCocoa() {} | 150 AcceleratorsCocoa::~AcceleratorsCocoa() {} |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 AcceleratorsCocoa* AcceleratorsCocoa::GetInstance() { | 153 AcceleratorsCocoa* AcceleratorsCocoa::GetInstance() { |
| 154 return Singleton<AcceleratorsCocoa>::get(); | 154 return base::Singleton<AcceleratorsCocoa>::get(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 const ui::Accelerator* AcceleratorsCocoa::GetAcceleratorForCommand( | 157 const ui::Accelerator* AcceleratorsCocoa::GetAcceleratorForCommand( |
| 158 int command_id) { | 158 int command_id) { |
| 159 AcceleratorMap::iterator it = accelerators_.find(command_id); | 159 AcceleratorMap::iterator it = accelerators_.find(command_id); |
| 160 if (it == accelerators_.end()) | 160 if (it == accelerators_.end()) |
| 161 return NULL; | 161 return NULL; |
| 162 return &it->second; | 162 return &it->second; |
| 163 } | 163 } |
| 164 | 164 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 182 NSUInteger mask = platform_accelerator->modifier_mask(); | 182 NSUInteger mask = platform_accelerator->modifier_mask(); |
| 183 BOOL maskEqual = | 183 BOOL maskEqual = |
| 184 (mask == modifiers) || ((mask & (~NSShiftKeyMask)) == modifiers); | 184 (mask == modifiers) || ((mask & (~NSShiftKeyMask)) == modifiers); |
| 185 NSString* string = [NSString stringWithFormat:@"%C", shifted_character]; | 185 NSString* string = [NSString stringWithFormat:@"%C", shifted_character]; |
| 186 if ([string isEqual:key_equivalent] && maskEqual) | 186 if ([string isEqual:key_equivalent] && maskEqual) |
| 187 return &*it; | 187 return &*it; |
| 188 } | 188 } |
| 189 | 189 |
| 190 return NULL; | 190 return NULL; |
| 191 } | 191 } |
| OLD | NEW |