| 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_H_ | 5 #ifndef APP_MENUS_ACCELERATOR_H_ | 
| 6 #define APP_MENUS_ACCELERATOR_H_ | 6 #define APP_MENUS_ACCELERATOR_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include "base/keyboard_codes.h" | 9 #include "app/keyboard_codes.h" | 
| 10 | 10 | 
| 11 namespace menus { | 11 namespace menus { | 
| 12 | 12 | 
| 13 // This is a cross-platform base class for accelerator keys used in menus. It is | 13 // This is a cross-platform base class for accelerator keys used in menus. It is | 
| 14 // meant to be subclassed for concrete toolkit implementations. | 14 // meant to be subclassed for concrete toolkit implementations. | 
| 15 | 15 | 
| 16 class Accelerator { | 16 class Accelerator { | 
| 17  public: | 17  public: | 
| 18   Accelerator() : key_code_(base::VKEY_UNKNOWN), modifiers_(0) {} | 18   Accelerator() : key_code_(app::VKEY_UNKNOWN), modifiers_(0) {} | 
| 19 | 19 | 
| 20   Accelerator(base::KeyboardCode keycode, int modifiers) | 20   Accelerator(app::KeyboardCode keycode, int modifiers) | 
| 21       : key_code_(keycode), | 21       : key_code_(keycode), | 
| 22         modifiers_(modifiers) {} | 22         modifiers_(modifiers) {} | 
| 23 | 23 | 
| 24   Accelerator(const Accelerator& accelerator) { | 24   Accelerator(const Accelerator& accelerator) { | 
| 25     key_code_ = accelerator.key_code_; | 25     key_code_ = accelerator.key_code_; | 
| 26     modifiers_ = accelerator.modifiers_; | 26     modifiers_ = accelerator.modifiers_; | 
| 27   } | 27   } | 
| 28 | 28 | 
| 29   virtual ~Accelerator() {} | 29   virtual ~Accelerator() {} | 
| 30 | 30 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 45   } | 45   } | 
| 46 | 46 | 
| 47   bool operator ==(const Accelerator& rhs) const { | 47   bool operator ==(const Accelerator& rhs) const { | 
| 48     return (key_code_ == rhs.key_code_) && (modifiers_ == rhs.modifiers_); | 48     return (key_code_ == rhs.key_code_) && (modifiers_ == rhs.modifiers_); | 
| 49   } | 49   } | 
| 50 | 50 | 
| 51   bool operator !=(const Accelerator& rhs) const { | 51   bool operator !=(const Accelerator& rhs) const { | 
| 52     return !(*this == rhs); | 52     return !(*this == rhs); | 
| 53   } | 53   } | 
| 54 | 54 | 
| 55   base::KeyboardCode GetKeyCode() const { | 55   app::KeyboardCode GetKeyCode() const { | 
| 56     return key_code_; | 56     return key_code_; | 
| 57   } | 57   } | 
| 58 | 58 | 
| 59   int modifiers() const { | 59   int modifiers() const { | 
| 60     return modifiers_; | 60     return modifiers_; | 
| 61   } | 61   } | 
| 62 | 62 | 
| 63  protected: | 63  protected: | 
| 64   // The keycode (VK_...). | 64   // The keycode (VK_...). | 
| 65   base::KeyboardCode key_code_; | 65   app::KeyboardCode key_code_; | 
| 66 | 66 | 
| 67   // The state of the Shift/Ctrl/Alt keys (platform-dependent). | 67   // The state of the Shift/Ctrl/Alt keys (platform-dependent). | 
| 68   int modifiers_; | 68   int modifiers_; | 
| 69 }; | 69 }; | 
| 70 | 70 | 
| 71 // Since acclerator code is one of the few things that can't be cross platform | 71 // Since acclerator code is one of the few things that can't be cross platform | 
| 72 // in the chrome UI, separate out just the GetAcceleratorForCommandId() from | 72 // in the chrome UI, separate out just the GetAcceleratorForCommandId() from | 
| 73 // the menu delegates. | 73 // the menu delegates. | 
| 74 class AcceleratorProvider { | 74 class AcceleratorProvider { | 
| 75  public: | 75  public: | 
| 76   // Gets the accelerator for the specified command id. Returns true if the | 76   // Gets the accelerator for the specified command id. Returns true if the | 
| 77   // command id has a valid accelerator, false otherwise. | 77   // command id has a valid accelerator, false otherwise. | 
| 78   virtual bool GetAcceleratorForCommandId( | 78   virtual bool GetAcceleratorForCommandId( | 
| 79       int command_id, | 79       int command_id, | 
| 80       menus::Accelerator* accelerator) = 0; | 80       menus::Accelerator* accelerator) = 0; | 
| 81 | 81 | 
| 82  protected: | 82  protected: | 
| 83   virtual ~AcceleratorProvider() {} | 83   virtual ~AcceleratorProvider() {} | 
| 84 }; | 84 }; | 
| 85 | 85 | 
| 86 } | 86 } | 
| 87 | 87 | 
| 88 #endif  // APP_MENUS_ACCELERATOR_H_ | 88 #endif  // APP_MENUS_ACCELERATOR_H_ | 
| 89 | 89 | 
| OLD | NEW | 
|---|