| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef APP_MENUS_ACCELERATOR_COCOA_H_ | 5 #ifndef APP_MENUS_ACCELERATOR_COCOA_H_ |
| 6 #define APP_MENUS_ACCELERATOR_COCOA_H_ | 6 #define APP_MENUS_ACCELERATOR_COCOA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <Foundation/Foundation.h> | 9 #include <Foundation/Foundation.h> |
| 10 | 10 |
| 11 #include "app/menus/accelerator.h" | 11 #include "app/menus/accelerator.h" |
| 12 #include "base/scoped_nsobject.h" | 12 #include "base/scoped_nsobject.h" |
| 13 | 13 |
| 14 namespace menus { | 14 namespace menus { |
| 15 | 15 |
| 16 // This is a subclass of the cross-platform Accelerator, but with more direct | 16 // This is a subclass of the cross-platform Accelerator, but with more direct |
| 17 // support for Cocoa key equivalents. Note that the typical use case for this | 17 // support for Cocoa key equivalents. Note that the typical use case for this |
| 18 // class is to initialize it with a string literal, which is why it sends | 18 // class is to initialize it with a string literal, which is why it sends |
| 19 // |-copy| to the |key_code| paramater in the constructor. | 19 // |-copy| to the |key_code| paramater in the constructor. |
| 20 class AcceleratorCocoa : public Accelerator { | 20 class AcceleratorCocoa : public Accelerator { |
| 21 public: | 21 public: |
| 22 AcceleratorCocoa(NSString* key_code, NSUInteger mask) | 22 AcceleratorCocoa(NSString* key_code, NSUInteger mask) |
| 23 : Accelerator(app::VKEY_UNKNOWN, mask), | 23 : Accelerator(base::VKEY_UNKNOWN, mask), |
| 24 characters_([key_code copy]) { | 24 characters_([key_code copy]) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 AcceleratorCocoa(const AcceleratorCocoa& accelerator) | 27 AcceleratorCocoa(const AcceleratorCocoa& accelerator) |
| 28 : Accelerator(accelerator) { | 28 : Accelerator(accelerator) { |
| 29 characters_.reset([accelerator.characters_ copy]); | 29 characters_.reset([accelerator.characters_ copy]); |
| 30 } | 30 } |
| 31 | 31 |
| 32 AcceleratorCocoa() : Accelerator() {} | 32 AcceleratorCocoa() : Accelerator() {} |
| 33 virtual ~AcceleratorCocoa() {} | 33 virtual ~AcceleratorCocoa() {} |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // String of characters for the key equivalent. | 53 // String of characters for the key equivalent. |
| 54 scoped_nsobject<NSString> characters_; | 54 scoped_nsobject<NSString> characters_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace menus | 57 } // namespace menus |
| 58 | 58 |
| 59 #endif // APP_MENUS_ACCELERATOR_COCOA_H_ | 59 #endif // APP_MENUS_ACCELERATOR_COCOA_H_ |
| OLD | NEW |